@@ -142,6 +142,7 @@ let :Blob current_allocated_memory(): U64 = (
142142let .into(b: Bool, tt: Type<String>): String = if b then "true" else "false";
143143let .into(i: U8, tt: Type<String>): String = (i as U64).into(type(String));
144144let .into(i: USize, tt: Type<String>): String = (i as U64).into(type(String));
145+ let .into(i: U32, tt: Type<String>): String = (i as U64).into(type(String));
145146
146147let .into(i: I64, tt: Type<String>): String = (
147148 let od = mk-owned-data(type(U8), 20_sz);
@@ -196,6 +197,8 @@ let .into(i: U64, tt: Type<String>): String = (
196197 String(0 as USize, cs-length, od)
197198);
198199
200+ let .to-hex(i: U32): String = (i as U64).to-hex;
201+
199202let .to-hex(i: U64): String = (
200203 let buff = mk-vector(type(U8), 17);
201204 let rpt = 16_u64;
@@ -2496,7 +2499,45 @@ let .into(l: Tuple<w,x,y,z>, tt: Type<String>): String = (
24962499
24972500type alias U16 suffix _u16 = U64;
24982501
2499- type alias U32 suffix _u32 = U64;
2502+ type opaque alias U32 suffix _u32 = C<"uint32_t">;
2503+
2504+ declare-binop( $"!=", raw-type(U32), raw-type(U32), raw-type(Bool), ( l"("; x; l"!="; y; l")"; ) );
2505+ declare-binop( $"==", raw-type(U32), raw-type(U32), raw-type(Bool), ( l"("; x; l"=="; y; l")"; ) );
2506+ declare-binop( $"<", raw-type(U32), raw-type(U32), raw-type(Bool), ( l"("; x; l"<"; y; l")"; ) );
2507+ declare-binop( $"<=", raw-type(U32), raw-type(U32), raw-type(Bool), ( l"("; x; l"<="; y; l")"; ) );
2508+ declare-binop( $">", raw-type(U32), raw-type(U32), raw-type(Bool), ( l"("; x; l">"; y; l")"; ) );
2509+ declare-binop( $">=", raw-type(U32), raw-type(U32), raw-type(Bool), ( l"("; x; l">="; y; l")"; ) );
2510+
2511+ declare-binop( $"&", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"&"; y; l")"; ) );
2512+ declare-binop( $"|", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"|"; y; l")"; ) );
2513+ declare-binop( $"^", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"^"; y; l")"; ) );
2514+ declare-binop( $"+", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"+"; y; l")"; ) );
2515+ declare-binop( $"-", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"-"; y; l")"; ) );
2516+ declare-binop( $"/", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"/"; y; l")"; ) );
2517+ declare-binop( $"%", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"%"; y; l")"; ) );
2518+ declare-binop( $"*", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"*"; y; l")"; ) );
2519+
2520+ declare-binop( $"<<", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l"<<"; y; l")"; ) );
2521+ declare-binop( $">>", raw-type(U32), raw-type(U32), raw-type(U32), ( l"("; x; l">>"; y; l")"; ) );
2522+
2523+ declare-unop( $"~", raw-type(U32), raw-type(U32), ( l"((uint32_t)(~"; x; l"))"; ) );
2524+
2525+ let non-zero(x: U32): Bool = x != 0;
2526+
2527+ let min(l: U32, r: U32): U32 = (
2528+ if l < r then l else r
2529+ );
2530+ let max(l: U32, r: U32): U32 = (
2531+ if l > r then l else r
2532+ );
2533+
2534+ let cmp(l: U32, r: U32): Ord = (
2535+ if l < r then LessThan
2536+ else if l > r then GreaterThan
2537+ else Equal
2538+ );
2539+
2540+ let hash(x: U32): U64 = x as U64;
25002541
25012542type opaque alias U64 suffix _u64 = C<"uint64_t">;
25022543
@@ -2561,7 +2602,7 @@ let to-u64(s: CString): U64 = (
25612602);
25622603
25632604type opaque alias U8 suffix _u8
2564- implies C<"int">, USize, U64, I64, C<"size_t">
2605+ implies C<"int">, USize, U32, U64, I64, C<"size_t">
25652606 = C<"uint8_t">;
25662607
25672608declare-binop( $"!=", raw-type(U8), raw-type(U8), raw-type(Bool), ( l"("; x; l"!="; y; l")"; ) );
@@ -2603,7 +2644,7 @@ let hash(x: U8): U64 = x as U64;
26032644let non-zero(x: U8): Bool = x != 0;
26042645
26052646type opaque alias USize suffix _sz
2606- implies U64, C<"size_t">
2647+ implies U32, U64, C<"size_t">
26072648 = C<"size_t">;
26082649
26092650declare-binop( $"!=", raw-type(USize), raw-type(USize), raw-type(Bool), ( l"("; x; l"!="; y; l")"; ) );
@@ -6446,7 +6487,7 @@ let .ground-tag-and-arity(tt: Type): (U32,U32) = (
64466487 TGround { tag:interned-tag-array, parameters:[_.. TAny{}..] } => (interned-tag-array.primary, 2_u32);
64476488 TGround { tag:interned-tag-array, parameters:[_.. array-base..] } => (
64486489 let ga = array-base.ground-tag-and-arity;
6449- ( ga.first, ga.second + 1000 )
6490+ ( ga.first, ga.second + 1000_u32 )
64506491 );
64516492 TGround { tag:interned-tag-sized, parameters:[_..] } => (0_u32, 9999999_u32);
64526493 TGround { tag=tag, parameters=parameters } => (tag.primary, parameters.length as U32);
@@ -6487,7 +6528,7 @@ let hash(tt: Type): U64 = (
64876528 result
64886529 );
64896530 TGround{tag=tag,parameters=parameters} => hash(tag) + hash(parameters);
6490- TId{id=id} => id;
6531+ TId{id=id} => id as U64 ;
64916532 }
64926533);
64936534
@@ -6544,7 +6585,7 @@ let intern-type-tag-single(tag: CString): U32 = (
65446585 }
65456586);
65466587
6547- let hash(t: TypeTagIntern): U32 = (
6588+ let hash(t: TypeTagIntern): U64 = (
65486589 if t.second != 0
65496590 then hash(t.second)
65506591 else hash(t.first)
@@ -6903,7 +6944,7 @@ let .simple-tag(tt: Type): CString = (
69036944let .simple-interned-tag(tt: Type): TypeTagIntern = (
69046945 match tt {
69056946 TGround { tag=tag } => tag;
6906- _ => TypeTagIntern(0,0 );
6947+ _ => TypeTagIntern(0_u32,0_u32 );
69076948 }
69086949);
69096950
@@ -11708,15 +11749,15 @@ let std-c-decorate-pointer(tt: Type, ptr: CTerm): Type = (
1170811749let std-c-type-of-integer(i: String): Type = (
1170911750 if i.has-prefix("-") {
1171011751 let n = to-u64(tail(i).into(type(CString)));
11711- if n <= 128 then type-c-uint8 else
11712- if n <= 32768 then type-c-uint16 else
11713- if n <= 2147483648 then type-c-uint32 else
11752+ if n <= 128_u64 then type-c-uint8 else
11753+ if n <= 32768_u64 then type-c-uint16 else
11754+ if n <= 2147483648_u64 then type-c-uint32 else
1171411755 type-c-uint64
1171511756 } else {
1171611757 let n = to-u64(i.into(type(CString)));
11717- if n <= 255 then type-c-int8 else
11718- if n <= 65535 then type-c-int16 else
11719- if n <= 4294967295 then type-c-int32 else
11758+ if n <= 255_u64 then type-c-int8 else
11759+ if n <= 65535_u64 then type-c-int16 else
11760+ if n <= 4294967295_u64 then type-c-int32 else
1172011761 type-c-int64
1172111762 };
1172211763);
@@ -15477,9 +15518,9 @@ let mk-lsts-token(s: String): Token = (
1547715518 ds = tail(ds);
1547815519 };
1547915520 let magnitude = to-u64(ds);
15480- if (is-negative and magnitude <= 128 ) or magnitude <= 255 then order = 8
15481- else if (is-negative and magnitude <= 32768 ) or magnitude <= 65535 then order = 16
15482- else if (is-negative and magnitude <= 2147483648 ) or magnitude <= 4294967295 then order = 32;
15521+ if (is-negative and magnitude <= 128_u64 ) or magnitude <= 255 then order = 8
15522+ else if (is-negative and magnitude <= 32768_u64 ) or magnitude <= 65535_u64 then order = 16
15523+ else if (is-negative and magnitude <= 2147483648_u64 ) or magnitude <= 4294967295_u64 then order = 32;
1548315524 };
1548415525 match (is-negative as U64, order) {
1548515526 Tuple{ first:0_u64, second:8_u64 } => us = us + c"_u8";
0 commit comments