replace x86.T with native.T
This commit is contained in:
parent
e29a5a3475
commit
f67f8c0118
12 changed files with 91 additions and 91 deletions
|
@ -14,8 +14,8 @@ ldmc:
|
|||
|
||||
posint-dec-to-hex-generated.c: ldmc target
|
||||
ldmc \
|
||||
"ℕ~<PosInt 10 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 10>~Char~Ascii~x86.UInt8>" \
|
||||
"ℕ~<PosInt 16 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 16>~Char~Ascii~x86.UInt8>" \
|
||||
"ℕ~<PosInt 10 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 10>~Char~Ascii~native.UInt8>" \
|
||||
"ℕ~<PosInt 16 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 16>~Char~Ascii~native.UInt8>" \
|
||||
../morphisms/*.morphism-base >| target/$@
|
||||
|
||||
posint-dec-to-hex-generated-gcc: posint-dec-to-hex-generated.c target
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
```
|
||||
|
||||
morph_digit_as_char_to_uint8 (Radix:ℤ)
|
||||
<Digit Radix> ~ Char ~ Ascii ~ x86.UInt8
|
||||
--> <Digit Radix> ~ x86.UInt8
|
||||
<Digit Radix> ~ Char ~ Ascii ~ native.UInt8
|
||||
--> <Digit Radix> ~ native.UInt8
|
||||
```
|
||||
if( *src >= '0' && *src <= '9' )
|
||||
*dst = *src - '0';
|
||||
|
@ -26,8 +26,8 @@ morph_digit_as_char_to_uint8 (Radix:ℤ)
|
|||
```
|
||||
|
||||
morph_digit_as_char_to_uint64 (Radix:ℤ)
|
||||
<Digit Radix> ~ Char ~ Ascii ~ x86.UInt8
|
||||
--> <Digit Radix> ~ x86.UInt64
|
||||
<Digit Radix> ~ Char ~ Ascii ~ native.UInt8
|
||||
--> <Digit Radix> ~ native.UInt64
|
||||
```
|
||||
if( *src >= '0' && *src <= '9' )
|
||||
*dst = *src - '0';
|
||||
|
@ -49,8 +49,8 @@ morph_digit_as_char_to_uint64 (Radix:ℤ)
|
|||
```
|
||||
|
||||
morph_digit_as_uint8_to_char (Radix:ℤ_16)
|
||||
<Digit Radix> ~ x86.UInt8
|
||||
--> <Digit Radix> ~ Char ~ Ascii ~ x86.UInt8
|
||||
<Digit Radix> ~ native.UInt8
|
||||
--> <Digit Radix> ~ Char ~ Ascii ~ native.UInt8
|
||||
```
|
||||
if ( *src < 10 )
|
||||
*dst = *src + '0';
|
||||
|
@ -65,8 +65,8 @@ morph_digit_as_uint8_to_char (Radix:ℤ_16)
|
|||
```
|
||||
|
||||
morph_digit_as_uint64_to_char (Radix:ℤ_16)
|
||||
<Digit Radix> ~ x86.UInt64
|
||||
--> <Digit Radix> ~ Char ~ Ascii ~ x86.UInt8
|
||||
<Digit Radix> ~ native.UInt64
|
||||
--> <Digit Radix> ~ Char ~ Ascii ~ native.UInt8
|
||||
```
|
||||
if ( *src < 10 )
|
||||
*dst = *src + '0';
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include <array/length-prefix.h>
|
||||
```
|
||||
|
||||
morph_array_as_valterm_to_lenpfx (Terminator:x86.UInt8)
|
||||
<Seq~<ValueTerminated Terminator> x86.UInt8>
|
||||
--> <Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
||||
morph_array_as_valterm_to_lenpfx (Terminator:native.UInt8)
|
||||
<Seq~<ValueTerminated Terminator> native.UInt8>
|
||||
--> <Seq~<LengthPrefix native.UInt64> native.UInt8>
|
||||
```
|
||||
length_prefix_uint64_t_array_uint8_t_clear(dst);
|
||||
while( *src != Terminator )
|
||||
|
@ -15,9 +15,9 @@ morph_array_as_valterm_to_lenpfx (Terminator:x86.UInt8)
|
|||
```
|
||||
|
||||
|
||||
morph_array_as_lenpfx_to_valterm (Terminator:x86.UInt8)
|
||||
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
||||
--> <Seq~<ValueTerminated Terminator> x86.UInt8>
|
||||
morph_array_as_lenpfx_to_valterm (Terminator:native.UInt8)
|
||||
<Seq~<LengthPrefix native.UInt64> native.UInt8>
|
||||
--> <Seq~<ValueTerminated Terminator> native.UInt8>
|
||||
```
|
||||
for( uint64_t i = 0; i < src->len; ++i )
|
||||
*dst++ = src->items[i];
|
||||
|
@ -28,8 +28,8 @@ morph_array_as_lenpfx_to_valterm (Terminator:x86.UInt8)
|
|||
```
|
||||
|
||||
morph_array_as_lenpfx_to_continuation_bit_8 ()
|
||||
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
||||
--> <Seq~MsbCont x86.UInt8>
|
||||
<Seq~<LengthPrefix native.UInt64> native.UInt8>
|
||||
--> <Seq~MsbCont native.UInt8>
|
||||
```
|
||||
for( uint64_t i = 0; i < src->len; ++i ) {
|
||||
if( src->items[i] & (1<<7) ) {
|
||||
|
@ -46,8 +46,8 @@ morph_array_as_lenpfx_to_continuation_bit_8 ()
|
|||
```
|
||||
|
||||
morph_array_as_lenpfx_to_continuation_bit_16 ()
|
||||
<Seq~<LengthPrefix x86.UInt64> x86.UInt16>
|
||||
--> <Seq~MsbCont x86.UInt16>
|
||||
<Seq~<LengthPrefix native.UInt64> native.UInt16>
|
||||
--> <Seq~MsbCont native.UInt16>
|
||||
```
|
||||
for( uint64_t i = 0; i < src->len; ++i ) {
|
||||
if( src->items[i] & (1<<15) ) {
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
morph_nat_as_u64_to_pos ()
|
||||
ℕ
|
||||
~ x86.UInt64
|
||||
~ native.UInt64
|
||||
--> ℕ
|
||||
~ <PosInt 0 LittleEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit 0>~x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit 0>~native.UInt64>
|
||||
```
|
||||
dst->len = 1;
|
||||
dst->items[0] = *src;
|
||||
|
@ -17,9 +17,9 @@ morph_nat_as_u64_to_pos ()
|
|||
morph_nat_as_pos_to_u64 (Endianness:Type)
|
||||
ℕ
|
||||
~ <PosInt 0 Endianness>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit 0>~x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit 0>~native.UInt64>
|
||||
--> ℕ
|
||||
~ x86.UInt64
|
||||
~ native.UInt64
|
||||
```
|
||||
*dst = src->items[0];
|
||||
return 0;
|
||||
|
@ -28,10 +28,10 @@ morph_nat_as_pos_to_u64 (Endianness:Type)
|
|||
morph_posint_radix_le (SrcRadix:ℤ, DstRadix:ℤ)
|
||||
ℕ
|
||||
~ <PosInt SrcRadix LittleEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit SrcRadix>~x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit SrcRadix>~native.UInt64>
|
||||
--> ℕ
|
||||
~ <PosInt DstRadix LittleEndian>
|
||||
~ <Seq~<LenghtPrefix x86.UInt64> <Digit DstRadix>~x86.UInt64>
|
||||
~ <Seq~<LenghtPrefix native.UInt64> <Digit DstRadix>~native.UInt64>
|
||||
```
|
||||
uint64_t value = 0;
|
||||
|
||||
|
@ -59,10 +59,10 @@ morph_posint_radix_le (SrcRadix:ℤ, DstRadix:ℤ)
|
|||
morph_posint_radix_be (SrcRadix:ℤ, DstRadix:ℤ)
|
||||
ℕ
|
||||
~ <PosInt SrcRadix BigEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit SrcRadix>~x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit SrcRadix>~native.UInt64>
|
||||
--> ℕ
|
||||
~ <PosInt DstRadix BigEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit DstRadix>~x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit DstRadix>~native.UInt64>
|
||||
```
|
||||
uint64_t value = 0;
|
||||
|
||||
|
@ -98,10 +98,10 @@ morph_posint_radix_be (SrcRadix:ℤ, DstRadix:ℤ)
|
|||
morph_posint_endianness (Radix:ℤ)
|
||||
ℕ
|
||||
~ <PosInt Radix LittleEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit Radix> ~ x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit Radix> ~ native.UInt64>
|
||||
--> ℕ
|
||||
~ <PosInt Radix BigEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit Radix> ~ x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit Radix> ~ native.UInt64>
|
||||
```
|
||||
return length_prefix_uint64_t_array_uint64_t_reverse( src, dst );
|
||||
```
|
||||
|
@ -109,10 +109,10 @@ morph_posint_endianness (Radix:ℤ)
|
|||
morph_posint_endianness (Radix:ℤ)
|
||||
ℕ
|
||||
~ <PosInt Radix BigEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit Radix> ~ x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit Radix> ~ native.UInt64>
|
||||
--> ℕ
|
||||
~ <PosInt Radix LittleEndian>
|
||||
~ <Seq~<LengthPrefix x86.UInt64> <Digit Radix> ~ x86.UInt64>
|
||||
~ <Seq~<LengthPrefix native.UInt64> <Digit Radix> ~ native.UInt64>
|
||||
```
|
||||
return length_prefix_uint64_t_array_uint64_t_reverse( src, dst );
|
||||
```
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
```
|
||||
|
||||
morph_real_as_decimalstr_to_float ()
|
||||
ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~x86.UInt8>
|
||||
ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
|
||||
--> ℝ ~ native.Float
|
||||
```
|
||||
sscanf(src, "%f", dst);
|
||||
|
@ -11,7 +11,7 @@ morph_real_as_decimalstr_to_float ()
|
|||
```
|
||||
|
||||
morph_real_as_decimalstr_to_double ()
|
||||
ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~x86.UInt8>
|
||||
ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
|
||||
--> ℝ ~ native.Double
|
||||
```
|
||||
sscanf(src, "%lf", dst);
|
||||
|
@ -20,7 +20,7 @@ morph_real_as_decimalstr_to_double ()
|
|||
|
||||
morph_real_as_float_to_decimalstr ()
|
||||
ℝ ~ native.Float
|
||||
--> ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~x86.UInt8>
|
||||
--> ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
|
||||
```
|
||||
sprintf(dst, "%f", *src);
|
||||
return 0;
|
||||
|
@ -28,7 +28,7 @@ morph_real_as_float_to_decimalstr ()
|
|||
|
||||
morph_real_as_double_to_decimalstr ()
|
||||
ℝ ~ native.Double
|
||||
--> ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~x86.UInt8>
|
||||
--> ℝ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
|
||||
```
|
||||
sprintf(dst, "%f", *src);
|
||||
return 0;
|
||||
|
@ -53,7 +53,7 @@ morph_real_as_double_to_float ()
|
|||
```
|
||||
|
||||
morph_real_as_u64_to_float ()
|
||||
ℝ ~ ℕ ~ x86.UInt64
|
||||
ℝ ~ ℕ ~ native.UInt64
|
||||
--> ℝ ~ native.Float
|
||||
```
|
||||
fprintf(stderr, "Warning: morphin UInt64 -> Float. Precision loss!");
|
||||
|
@ -62,7 +62,7 @@ morph_real_as_u64_to_float ()
|
|||
```
|
||||
|
||||
morph_real_as_u64_to_double ()
|
||||
ℝ ~ ℕ ~ x86.UInt64
|
||||
ℝ ~ ℕ ~ native.UInt64
|
||||
--> ℝ ~ native.Double
|
||||
```
|
||||
fprintf(stderr, "Warning: morphin UInt64 -> Double. Precision loss!");
|
||||
|
@ -71,7 +71,7 @@ morph_real_as_u64_to_double ()
|
|||
```
|
||||
|
||||
morph_real_as_quantized_linear_to_float (Begin: ℝ, End: ℝ, Steps: ℤ)
|
||||
ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ x86.UInt64
|
||||
ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ native.UInt64
|
||||
--> ℝ ~ native.Float
|
||||
```
|
||||
*dst = (float)Begin + ( *src * ((float)End - (float)Begin) ) / (float)Steps;
|
||||
|
@ -80,7 +80,7 @@ morph_real_as_quantized_linear_to_float (Begin: ℝ, End: ℝ, Steps: ℤ)
|
|||
|
||||
morph_real_as_float_to_quantized_linear (Begin: ℝ, End: ℝ, Steps: ℤ)
|
||||
ℝ ~ native.Float
|
||||
--> ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ x86.UInt64
|
||||
--> ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ native.UInt64
|
||||
```
|
||||
*dst = ((*src - (float)Begin) * (float)Steps) / ((float)End - (float)Begin);
|
||||
return 0;
|
||||
|
@ -89,7 +89,7 @@ morph_real_as_float_to_quantized_linear (Begin: ℝ, End: ℝ, Steps: ℤ)
|
|||
|
||||
|
||||
morph_real_as_quantized_linear_to_double (Begin: ℝ, End: ℝ, Steps: ℤ)
|
||||
ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ x86.UInt64
|
||||
ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ native.UInt64
|
||||
--> ℝ ~ native.Double
|
||||
```
|
||||
*dst = (double)Begin + ( *src * ((double)End - (double)Begin) ) / (double)Steps;
|
||||
|
@ -98,7 +98,7 @@ morph_real_as_quantized_linear_to_double (Begin: ℝ, End: ℝ, Steps: ℤ)
|
|||
|
||||
morph_real_as_double_to_quantized_linear (Begin: ℝ, End: ℝ, Steps: ℤ)
|
||||
ℝ ~ native.Double
|
||||
--> ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ x86.UInt64
|
||||
--> ℝ ~ <QuantizedLinear Begin End Steps> ~ ℕ ~ native.UInt64
|
||||
```
|
||||
*dst = ((*src - (double)Begin) * (double)Steps) / ((double)End - (double)Begin);
|
||||
return 0;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
```
|
||||
|
||||
morph_unixtime_to_iso ()
|
||||
TimePoint ~ <TimeSince UnixEpoch> ~ Duration ~ Seconds ~ ℝ ~ <QuantizedLinear 0 1 1> ~ ℕ ~ x86.UInt64
|
||||
--> TimePoint ~ ISO8601 ~ <Seq~<ValueTerminated 0> Char~Ascii~x86.UInt8>
|
||||
TimePoint ~ <TimeSince UnixEpoch> ~ Duration ~ Seconds ~ ℝ ~ <QuantizedLinear 0 1 1> ~ ℕ ~ native.UInt64
|
||||
--> TimePoint ~ ISO8601 ~ <Seq~<ValueTerminated 0> Char~Ascii~native.UInt8>
|
||||
```
|
||||
time_t rawtime = (time_t)(*src);
|
||||
struct tm *timeinfo = gmtime(&rawtime);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
```
|
||||
|
||||
morph_string_as_ascii_to_utf8 ()
|
||||
<Seq ~ <ValueTerminated 0> Char~Ascii~x86.UInt8>
|
||||
<Seq ~ <ValueTerminated 0> Char~Ascii~native.UInt8>
|
||||
--> <Seq Char~Unicode>
|
||||
~ UTF-8
|
||||
~ <Seq~<ValueTerminated 0> x86.UInt8>
|
||||
~ <Seq~<ValueTerminated 0> native.UInt8>
|
||||
```
|
||||
while( *src ) { *dst++ = *src++; }
|
||||
*dst = 0;
|
||||
|
@ -16,8 +16,8 @@ morph_string_as_ascii_to_utf8 ()
|
|||
morph_string_as_utf8_to_ascii ()
|
||||
<Seq Char~Unicode>
|
||||
~ UTF-8
|
||||
~ <Seq~<ValueTerminated 0> x86.UInt8>
|
||||
--> <Seq ~ <ValueTerminated 0> Char~Ascii~x86.UInt8>
|
||||
~ <Seq~<ValueTerminated 0> native.UInt8>
|
||||
--> <Seq ~ <ValueTerminated 0> Char~Ascii~native.UInt8>
|
||||
```
|
||||
while( *src ) {
|
||||
if( *src < 128 ) {
|
||||
|
@ -32,10 +32,10 @@ morph_string_as_utf8_to_ascii ()
|
|||
```
|
||||
|
||||
morph_string_as_ascii_to_utf32 ()
|
||||
<Seq ~ <ValueTerminated 0> Char~Ascii~x86.UInt8>
|
||||
<Seq ~ <ValueTerminated 0> Char~Ascii~native.UInt8>
|
||||
--> <Seq Char~Unicode>
|
||||
~ UTF-32LE
|
||||
~ <Seq~<ValueTerminated 0> x86.UInt32>
|
||||
~ <Seq~<ValueTerminated 0> native.UInt32>
|
||||
```
|
||||
while( *src ) { *dst++ = *src++; }
|
||||
*dst = 0;
|
||||
|
@ -46,11 +46,11 @@ morph_string_as_utf8_to_utf32 ()
|
|||
|
||||
<Seq Char~Unicode>
|
||||
~ UTF-8
|
||||
~ <Seq~<ValueTerminated 0> x86.UInt8>
|
||||
~ <Seq~<ValueTerminated 0> native.UInt8>
|
||||
|
||||
--> <Seq Char~Unicode>
|
||||
~ UTF-32LE
|
||||
~ <Seq~<ValueTerminated 0> x86.UInt32>
|
||||
~ <Seq~<ValueTerminated 0> native.UInt32>
|
||||
|
||||
```
|
||||
bool has_multibyte = false;
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
morph_seqseq_valsep_uint8 (T: Type, SrcDelim: T, DstDelim: T)
|
||||
< Seq <Seq T> >
|
||||
~ < ValueSep SrcDelim T >
|
||||
~ < Seq~<LengthPrefix x86.UInt64> T >
|
||||
~ < Seq~<LengthPrefix native.UInt64> T >
|
||||
|
||||
--> < Seq <Seq T> >
|
||||
~ < ValueSep DstDelim T >
|
||||
~ < Seq~<LengthPrefix x86.UInt64> T >
|
||||
~ < Seq~<LengthPrefix native.UInt64> T >
|
||||
```
|
||||
length_prefix_uint64_t_array_uint8_t_clear( dst );
|
||||
|
||||
|
@ -35,13 +35,13 @@ morph_seqseq_valsep_uint8 (T: Type, SrcDelim: T, DstDelim: T)
|
|||
morph_seqseq_as_valsep_to_lenpfx (T: Type, Delim: T, EscKey: T)
|
||||
< Seq <Seq T> >
|
||||
~ < ValueSep T Delim >
|
||||
~ < Seq~<LengthPrefix x86.UInt64> T >
|
||||
~ < Seq~<LengthPrefix native.UInt64> T >
|
||||
|
||||
--> < Seq~<LengthPrefix x86.UInt64>
|
||||
<Seq~<LengthPrefix x86.UInt64> T >
|
||||
~ <RefMut < Seq~<LengthPrefix x86.UInt64> T>>
|
||||
~ x86.Address
|
||||
~ x86.UInt64
|
||||
--> < Seq~<LengthPrefix native.UInt64>
|
||||
<Seq~<LengthPrefix native.UInt64> T >
|
||||
~ <RefMut < Seq~<LengthPrefix native.UInt64> T>>
|
||||
~ native.Address
|
||||
~ native.UInt64
|
||||
>
|
||||
```
|
||||
length_prefix_uint64_t_array_uint64_t_clear( dst );
|
||||
|
@ -71,15 +71,15 @@ morph_seqseq_as_valsep_to_lenpfx (T: Type, Delim: T, EscKey: T)
|
|||
```
|
||||
|
||||
morph_seqeq_as_lenpfx_to_valsep (T: Type, Delim: T, EscKey: T)
|
||||
< Seq~<LengthPrefix x86.UInt64>
|
||||
<Seq~<LengthPrefix x86.UInt64> T >
|
||||
~ <RefMut < Seq~<LengthPrefix x86.UInt64> T>>
|
||||
~ x86.Address
|
||||
~ x86.UInt64
|
||||
< Seq~<LengthPrefix native.UInt64>
|
||||
<Seq~<LengthPrefix native.UInt64> T >
|
||||
~ <RefMut < Seq~<LengthPrefix native.UInt64> T>>
|
||||
~ native.Address
|
||||
~ native.UInt64
|
||||
>
|
||||
--> < Seq <Seq T> >
|
||||
~ < ValueSep T Delim >
|
||||
~ < Seq~<LengthPrefix x86.UInt64> T >
|
||||
~ < Seq~<LengthPrefix native.UInt64> T >
|
||||
```
|
||||
length_prefix_uint64_t_array_uint8_t_clear( dst );
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
```
|
||||
|
||||
morph_i64_as_twos_complement_to_zigzag ()
|
||||
ℤ ~ x86.Int64
|
||||
--> ℤ ~ ZigZagInt ~ ℕ ~ x86.UInt64
|
||||
ℤ ~ native.Int64
|
||||
--> ℤ ~ ZigZagInt ~ ℕ ~ native.UInt64
|
||||
```
|
||||
if( *src >= 0 ) {
|
||||
*dst = (2 * (uint64_t)*src)
|
||||
|
@ -15,8 +15,8 @@ morph_i64_as_twos_complement_to_zigzag ()
|
|||
```
|
||||
|
||||
morph_i64_as_zigzag_to_twos_complement ()
|
||||
ℤ ~ ZigZagInt ~ ℕ ~ x86.UInt64
|
||||
--> ℤ ~ x86.Int64
|
||||
ℤ ~ ZigZagInt ~ ℕ ~ native.UInt64
|
||||
--> ℤ ~ native.Int64
|
||||
```
|
||||
if( *src % 2 == 0 ) {
|
||||
*dst = *src / 2;
|
||||
|
|
12
src/c_gen.rs
12
src/c_gen.rs
|
@ -20,15 +20,15 @@ pub fn get_c_repr_type(dict: &mut impl TypeDict, t: laddertypes::TypeTerm, skip_
|
|||
match lnf.last() {
|
||||
Some(t) => {
|
||||
if t == &dict.parse("Byte").expect("parse")
|
||||
|| t == &dict.parse("x86.UInt8").expect("parse")
|
||||
|| t == &dict.parse("native.UInt8").expect("parse")
|
||||
|| t == &dict.parse("<StaticLength 8 Bit>").expect("parse")
|
||||
{
|
||||
Some("uint8_t".into())
|
||||
} else if t == &dict.parse("x86.UInt16").expect("parse") {
|
||||
} else if t == &dict.parse("native.UInt16").expect("parse") {
|
||||
Some("uint16_t".into())
|
||||
} else if t == &dict.parse("x86.UInt32").expect("parse") {
|
||||
} else if t == &dict.parse("native.UInt32").expect("parse") {
|
||||
Some("uint32_t".into())
|
||||
} else if t == &dict.parse("x86.UInt64").expect("parse") {
|
||||
} else if t == &dict.parse("native.UInt64").expect("parse") {
|
||||
Some("uint64_t".into())
|
||||
} else if t == &dict.parse("native.Float").expect("parse") {
|
||||
Some("float".into())
|
||||
|
@ -221,13 +221,13 @@ halo Ψ = {}
|
|||
let is_string = false;
|
||||
if let Ok((halo, σ)) = laddertypes::subtype_unify(
|
||||
&dst_type,
|
||||
&type_dict.parse("<Seq~<ValueTerminated 0> x86.UInt8>").unwrap()
|
||||
&type_dict.parse("<Seq~<ValueTerminated 0> native.UInt8>").unwrap()
|
||||
) {
|
||||
println!(r#"
|
||||
printf("%s\n", {});"#, out_buf);
|
||||
} else if let Ok((halo, σ)) = laddertypes::subtype_unify(
|
||||
&dst_type,
|
||||
&type_dict.parse("<Seq~<LengthPrefix x86.UInt64> x86.UInt8>").unwrap()
|
||||
&type_dict.parse("<Seq~<LengthPrefix native.UInt64> native.UInt8>").unwrap()
|
||||
) {
|
||||
println!(r#"
|
||||
/* write output
|
||||
|
|
|
@ -25,7 +25,7 @@ fn main() {
|
|||
let mut morphism_base = laddertypes::MorphismBase::<LdmcMorphism>::new(vec![
|
||||
//type_dict.parse("Seq~MsbCont").expect(""),
|
||||
//type_dict.parse("Seq~<ValueTerminated '\\0'>").expect(""),
|
||||
type_dict.parse("Seq~<LengthPrefix x86.UInt64>").expect("")
|
||||
type_dict.parse("Seq~<LengthPrefix native.UInt64>").expect("")
|
||||
]);
|
||||
|
||||
let mut args = std::env::args().skip(1);
|
||||
|
|
28
test/test.sh
28
test/test.sh
|
@ -34,50 +34,50 @@ Running test case ${TEST_NAME}"
|
|||
}
|
||||
|
||||
TEST_NAME=test-radix-convert
|
||||
SRC_TYPE="ℕ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10> ~ Char ~ Ascii ~ x86.UInt8>"
|
||||
DST_TYPE="ℕ ~ <PosInt 16 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 16> ~ Char ~ Ascii ~ x86.UInt8>"
|
||||
SRC_TYPE="ℕ ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10> ~ Char ~ Ascii ~ native.UInt8>"
|
||||
DST_TYPE="ℕ ~ <PosInt 16 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 16> ~ Char ~ Ascii ~ native.UInt8>"
|
||||
INPUT="255"
|
||||
EXPECT="ff"
|
||||
run_test_case
|
||||
|
||||
TEST_NAME=test-msb-cont
|
||||
SRC_TYPE="<Seq~<ValueTerminated 0> x86.UInt8>"
|
||||
DST_TYPE="<Seq~MsbCont x86.UInt8>"
|
||||
SRC_TYPE="<Seq~<ValueTerminated 0> native.UInt8>"
|
||||
DST_TYPE="<Seq~MsbCont native.UInt8>"
|
||||
INPUT=$(printf '\x01\x02\x03')
|
||||
EXPECT=$(printf '\x81\x82\x03')
|
||||
run_test_case
|
||||
|
||||
TEST_NAME=test-value-sep1
|
||||
SRC_TYPE="<Seq <Seq Char~x86.UInt8>> ~ <ValueSep ':' Char~x86.UInt8> ~ <Seq~<ValueTerminated 0> Char~x86.UInt8>"
|
||||
DST_TYPE="<Seq <Seq Char~x86.UInt8>> ~ <ValueSep ',' Char~x86.UInt8> ~ <Seq~<ValueTerminated 0> Char~x86.UInt8>"
|
||||
SRC_TYPE="<Seq <Seq Char~native.UInt8>> ~ <ValueSep ':' Char~native.UInt8> ~ <Seq~<ValueTerminated 0> Char~native.UInt8>"
|
||||
DST_TYPE="<Seq <Seq Char~native.UInt8>> ~ <ValueSep ',' Char~native.UInt8> ~ <Seq~<ValueTerminated 0> Char~native.UInt8>"
|
||||
INPUT="abc:def:hello world:test"
|
||||
EXPECT="abc,def,hello world,test"
|
||||
run_test_case
|
||||
|
||||
TEST_NAME=test-value-sep2
|
||||
SRC_TYPE="<Seq <Seq x86.UInt8>> ~ <ValueSep ':' x86.UInt8> ~ <Seq~<ValueTerminated 0> x86.UInt8>"
|
||||
DST_TYPE="<Seq <Seq x86.UInt8>> ~ <ValueSep '\\n' x86.UInt8> ~ <Seq~<ValueTerminated 0> x86.UInt8>"
|
||||
SRC_TYPE="<Seq <Seq native.UInt8>> ~ <ValueSep ':' native.UInt8> ~ <Seq~<ValueTerminated 0> native.UInt8>"
|
||||
DST_TYPE="<Seq <Seq native.UInt8>> ~ <ValueSep '\\n' native.UInt8> ~ <Seq~<ValueTerminated 0> native.UInt8>"
|
||||
INPUT="abc:def:hello world:test"
|
||||
EXPECT=$(echo -en "abc\ndef\nhello world\ntest")
|
||||
run_test_case
|
||||
|
||||
TEST_NAME=test-value-sep-digit
|
||||
SRC_TYPE="<Seq <Seq <Digit 16>~Char~Ascii~x86.UInt8>> ~ <ValueSep ':' Char~Ascii~x86.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~x86.UInt8>"
|
||||
DST_TYPE="<Seq <Seq <Digit 16>~Char~Ascii~x86.UInt8>> ~ <ValueSep '.' Char~Ascii~x86.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~x86.UInt8>"
|
||||
SRC_TYPE="<Seq <Seq <Digit 16>~Char~Ascii~native.UInt8>> ~ <ValueSep ':' Char~Ascii~native.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~native.UInt8>"
|
||||
DST_TYPE="<Seq <Seq <Digit 16>~Char~Ascii~native.UInt8>> ~ <ValueSep '.' Char~Ascii~native.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~native.UInt8>"
|
||||
INPUT="c0:ff:ee"
|
||||
EXPECT=$(echo -en "c0.ff.ee")
|
||||
run_test_case
|
||||
|
||||
TEST_NAME=test-utf8-to-ascii
|
||||
SRC_TYPE="<Seq Char~Unicode> ~ UTF-8 ~ <Seq ~ <ValueTerminated 0> x86.UInt8>"
|
||||
DST_TYPE="<Seq~<ValueTerminated 0> Char ~ Ascii ~ x86.UInt8>"
|
||||
SRC_TYPE="<Seq Char~Unicode> ~ UTF-8 ~ <Seq ~ <ValueTerminated 0> native.UInt8>"
|
||||
DST_TYPE="<Seq~<ValueTerminated 0> Char ~ Ascii ~ native.UInt8>"
|
||||
INPUT="Hℵelαlo WΓΓΓorl⇒d"
|
||||
EXPECT="Hello World"
|
||||
run_test_case
|
||||
|
||||
TEST_NAME=test-value-sep-posint
|
||||
SRC_TYPE="<Seq ℕ~<PosInt 16 BigEndian>~<Seq <Digit 16>~Char~Ascii~x86.UInt8>> ~ <ValueSep ':' Char~Ascii~x86.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~x86.UInt8>"
|
||||
DST_TYPE="<Seq ℕ~<PosInt 16 BigEndian>~<Seq <Digit 16>~Char~Ascii~x86.UInt8>> ~ <ValueSep '.' Char~Ascii~x86.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~x86.UInt8>"
|
||||
SRC_TYPE="<Seq ℕ~<PosInt 16 BigEndian>~<Seq <Digit 16>~Char~Ascii~native.UInt8>> ~ <ValueSep ':' Char~Ascii~native.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~native.UInt8>"
|
||||
DST_TYPE="<Seq ℕ~<PosInt 16 BigEndian>~<Seq <Digit 16>~Char~Ascii~native.UInt8>> ~ <ValueSep '.' Char~Ascii~native.UInt8> ~ <Seq~<ValueTerminated '\0'> Char~Ascii~native.UInt8>"
|
||||
INPUT="c0:ff:ee"
|
||||
EXPECT=$(echo -en "c0.ff.ee")
|
||||
run_test_case
|
||||
|
|
Loading…
Add table
Reference in a new issue