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