nomen-lang 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/audit_runtime.c +12 -2
- package/core/System/Arena.nm +14 -5
- package/core/System/Array.nm +1 -1
- package/core/System/Atomic.nm +3 -3
- package/core/System/BigInt.nm +182 -23
- package/core/System/Buffer.nm +392 -33
- package/core/System/ClassBuffer.nm +145 -13
- package/core/System/Controls/Alert.nm +3 -3
- package/core/System/Controls/App.nm +17 -17
- package/core/System/Controls/Button.nm +2 -2
- package/core/System/Controls/CheckBox.nm +3 -3
- package/core/System/Controls/ColorPicker.nm +2 -2
- package/core/System/Controls/ComboBox.nm +2 -2
- package/core/System/Controls/Container.nm +39 -33
- package/core/System/Controls/DatePicker.nm +1 -1
- package/core/System/Controls/Form.nm +2 -2
- package/core/System/Controls/GroupBox.nm +2 -2
- package/core/System/Controls/ImageView.nm +2 -2
- package/core/System/Controls/Layout.nm +5 -5
- package/core/System/Controls/LevelIndicator.nm +2 -2
- package/core/System/Controls/ListView.nm +2 -2
- package/core/System/Controls/Menu.nm +2 -2
- package/core/System/Controls/NumberInput.nm +3 -3
- package/core/System/Controls/OtpInput.nm +2 -2
- package/core/System/Controls/OutlineView.nm +2 -2
- package/core/System/Controls/Pagination.nm +14 -14
- package/core/System/Controls/Popover.nm +2 -2
- package/core/System/Controls/Progress.nm +2 -2
- package/core/System/Controls/Radio.nm +3 -3
- package/core/System/Controls/Scrollable.nm +1 -1
- package/core/System/Controls/SearchField.nm +2 -2
- package/core/System/Controls/SecureField.nm +2 -2
- package/core/System/Controls/Segmented.nm +2 -2
- package/core/System/Controls/Select.nm +2 -2
- package/core/System/Controls/Separator.nm +2 -2
- package/core/System/Controls/Sheet.nm +2 -2
- package/core/System/Controls/Slider.nm +2 -2
- package/core/System/Controls/Spinner.nm +5 -5
- package/core/System/Controls/SplitView.nm +3 -3
- package/core/System/Controls/Stepper.nm +2 -2
- package/core/System/Controls/Switch.nm +2 -2
- package/core/System/Controls/Table.nm +2 -2
- package/core/System/Controls/Tabs.nm +2 -2
- package/core/System/Controls/Text.nm +2 -2
- package/core/System/Controls/TextBox.nm +3 -3
- package/core/System/Controls/TextView.nm +2 -2
- package/core/System/Controls/Toggle.nm +3 -3
- package/core/System/Controls/Toolbar.nm +2 -2
- package/core/System/Controls/Window.nm +12 -5
- package/core/System/Fiber.nm +16 -3
- package/core/System/Graph.nm +2 -2
- package/core/System/LinkedList.nm +13 -4
- package/core/System/List.nm +76 -17
- package/core/System/Map.nm +179 -21
- package/core/System/Mutex.nm +4 -4
- package/core/System/Random.nm +6 -7
- package/core/System/Set.nm +99 -23
- package/core/System/StableList.nm +371 -0
- package/core/System/Stream/Directory.nm +2 -2
- package/core/System/Stream/File.nm +18 -18
- package/core/System/Stream/Http.nm +5 -5
- package/core/System/Stream/Tcp.nm +5 -5
- package/core/System/String.nm +10 -5
- package/core/System/StringBuilder.nm +223 -12
- package/core/System/Task.nm +56 -64
- package/core/System/Test.nm +18 -18
- package/core/System/Text/CharIndex.nm +9 -9
- package/core/System/Text/Chars.nm +1 -1
- package/core/System/Text/Json.nm +72 -58
- package/core/System/Text/JsonTree.nm +126 -98
- package/core/System/Text/Regex.nm +43 -38
- package/core/System/Text/Utf8.nm +5 -5
- package/core/System/Thread.nm +26 -3
- package/core/System/Tree.nm +19 -3
- package/core/System/float.nm +36 -22
- package/core/System/int.nm +80 -28
- package/core/System/int16.nm +11 -0
- package/core/System/int32.nm +11 -0
- package/core/System/int64.nm +11 -0
- package/core/System/int8.nm +11 -0
- package/core/System/uint.nm +11 -0
- package/core/System/uint16.nm +11 -0
- package/core/System/uint32.nm +11 -0
- package/core/System/uint64.nm +11 -0
- package/core/System/uint8.nm +11 -0
- package/core/docs/System/StringBuilder.md +6 -0
- package/core/docs/System/Text/JsonTree.md +3 -2
- package/dist/index.mjs +37622 -30603
- package/package.json +1 -1
- package/src/bench_loop.nm +9 -9
package/core/System/Tree.nm
CHANGED
|
@@ -13,7 +13,7 @@ pub mv struct Tree<T>: Enumerable {
|
|
|
13
13
|
var parents = Buffer<int>()
|
|
14
14
|
var count = 0
|
|
15
15
|
|
|
16
|
-
pub func add = (ref self, mv T value) {
|
|
16
|
+
pub func add = (ref self { lefts, parents, rights, values }, mv T value) {
|
|
17
17
|
const int idx = self.count
|
|
18
18
|
self.values.grow_int(idx + 1)
|
|
19
19
|
const int v = value
|
|
@@ -27,12 +27,12 @@ pub mv struct Tree<T>: Enumerable {
|
|
|
27
27
|
self.count = self.count + 1
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
pub func set_left = (ref self, int idx, int left) {
|
|
30
|
+
pub func set_left = (ref self { lefts, parents }, int idx, int left) {
|
|
31
31
|
self.lefts.store_int(idx, left)
|
|
32
32
|
self.parents.store_int(left, idx)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
pub func set_right = (ref self, int idx, int right) {
|
|
35
|
+
pub func set_right = (ref self { parents, rights }, int idx, int right) {
|
|
36
36
|
self.rights.store_int(idx, right)
|
|
37
37
|
self.parents.store_int(right, idx)
|
|
38
38
|
}
|
|
@@ -57,6 +57,22 @@ pub mv struct Tree<T>: Enumerable {
|
|
|
57
57
|
return self.values.load_int(idx)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
// Bounds-checked access: `fallback` when idx is outside [0, self.count).
|
|
61
|
+
pub func at_or = (self, int idx, T fallback, out T) {
|
|
62
|
+
if idx >= 0 && idx < self.count {
|
|
63
|
+
return self.at(idx)
|
|
64
|
+
}
|
|
65
|
+
return fallback
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Bounds-checked access that traps when idx is outside [0, self.count).
|
|
69
|
+
pub func at_or_panic = (self, int idx, out T) {
|
|
70
|
+
if idx >= 0 && idx < self.count {
|
|
71
|
+
return self.at(idx)
|
|
72
|
+
}
|
|
73
|
+
panic("index out of range")
|
|
74
|
+
}
|
|
75
|
+
|
|
60
76
|
pub func count_nodes = (self, int idx, out int) {
|
|
61
77
|
if idx == -1 {
|
|
62
78
|
return 0
|
package/core/System/float.nm
CHANGED
|
@@ -5,37 +5,51 @@ pub struct float: Stringable {
|
|
|
5
5
|
pub func to_string = (self, mv out string) {
|
|
6
6
|
```
|
|
7
7
|
#arch: c
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// Single snprintf into a stack scratch (360 bytes covers "%f" of the
|
|
9
|
+
// largest double: 309 integer digits + '.' + 6 decimals + sign), then
|
|
10
|
+
// one malloc + memcpy — no sizing pass, no second format.
|
|
11
|
+
char tmp[360];
|
|
12
|
+
int length = snprintf(tmp, sizeof(tmp), "%f", self);
|
|
13
|
+
char* str = (char*)malloc((size_t)length + 1);
|
|
14
|
+
memcpy(str, tmp, (size_t)length);
|
|
15
|
+
str[length] = 0;
|
|
12
16
|
return (nomen_string){ str, length };
|
|
13
17
|
```
|
|
14
18
|
```
|
|
15
19
|
#arch: aarch64
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
mov
|
|
23
|
-
mov x1, xzr
|
|
20
|
+
// x19 = self (the double). Render into a 360-byte scratch at
|
|
21
|
+
// [sp+16]; [sp+0] is snprintf's variadic stack slot (Darwin passes
|
|
22
|
+
// variadic args on the stack), reused after the call for the
|
|
23
|
+
// length; [sp+8] holds buf.
|
|
24
|
+
sub sp, sp, #400
|
|
25
|
+
add x0, sp, #16
|
|
26
|
+
mov x1, #360
|
|
24
27
|
adr x2, .Lfmt_float_f
|
|
25
28
|
fmov d0, x19
|
|
29
|
+
str d0, [sp, #0] // variadic double slot
|
|
26
30
|
bl _snprintf
|
|
31
|
+
str x0, [sp, #0] // length
|
|
27
32
|
add x0, x0, #1
|
|
28
|
-
str x0, [sp, #64]
|
|
29
33
|
bl _malloc
|
|
30
|
-
str x0, [sp, #
|
|
31
|
-
ldr
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
add
|
|
34
|
+
str x0, [sp, #8] // buf
|
|
35
|
+
ldr x1, [sp, #0]
|
|
36
|
+
add x2, sp, #16 // src
|
|
37
|
+
mov x3, x1
|
|
38
|
+
.Lft_cl:
|
|
39
|
+
cbz x3, .Lft_done
|
|
40
|
+
ldrb w4, [x2]
|
|
41
|
+
strb w4, [x0]
|
|
42
|
+
add x2, x2, #1
|
|
43
|
+
add x0, x0, #1
|
|
44
|
+
sub x3, x3, #1
|
|
45
|
+
b .Lft_cl
|
|
46
|
+
.Lft_done:
|
|
47
|
+
ldr x0, [sp, #8]
|
|
48
|
+
add x2, x0, x1
|
|
49
|
+
strb wzr, [x2] // buf[length] = 0
|
|
50
|
+
ldr x0, [sp, #8]
|
|
51
|
+
ldr x1, [sp, #0]
|
|
52
|
+
add sp, sp, #400
|
|
39
53
|
b .Lend_float_to_string
|
|
40
54
|
.Lfmt_float_f: .asciz "%f"
|
|
41
55
|
.p2align 2
|
package/core/System/int.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A signed integer — the default integer type
|
|
3
3
|
**/
|
|
4
4
|
pub struct int: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, int divisor: divisor != 0, out int) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, int divisor: divisor != 0, out int) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
|
@@ -9,39 +20,80 @@ pub struct int: Stringable, Hashable, Equatable {
|
|
|
9
20
|
pub func to_string = (self, mv out string) {
|
|
10
21
|
```
|
|
11
22
|
#arch: c
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
snprintf
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
// Single pass: render the digits into a stack scratch (24 bytes
|
|
24
|
+
// covers INT64_MIN's sign + 19 digits + slack), then one malloc and
|
|
25
|
+
// one memcpy. The old body paid two snprintf passes over the value.
|
|
26
|
+
long v = self;
|
|
27
|
+
char tmp[24];
|
|
28
|
+
int pos = 24;
|
|
29
|
+
// Magnitude via the two's-complement negate (correct for INT64_MIN,
|
|
30
|
+
// whose positive counterpart is not representable).
|
|
31
|
+
unsigned long long u = v < 0 ? (unsigned long long)(-(v + 1)) + 1ULL : (unsigned long long)v;
|
|
32
|
+
do {
|
|
33
|
+
tmp[--pos] = (char)('0' + (int)(u % 10));
|
|
34
|
+
u /= 10;
|
|
35
|
+
} while (u != 0);
|
|
36
|
+
if (v < 0) tmp[--pos] = '-';
|
|
37
|
+
long len = 24 - pos;
|
|
38
|
+
char* str = (char*)malloc((size_t)len + 1);
|
|
39
|
+
memcpy(str, tmp + pos, (size_t)len);
|
|
40
|
+
str[len] = 0;
|
|
41
|
+
return (nomen_string){ str, len };
|
|
17
42
|
```
|
|
18
43
|
```
|
|
19
44
|
#arch: aarch64
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
mov
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
add
|
|
31
|
-
|
|
45
|
+
// x19 = self (the value). Render digits into a 24-byte scratch, then
|
|
46
|
+
// malloc(len + 1) + copy. [sp]=len, [sp+8]=buf, [sp+16]=pos across
|
|
47
|
+
// the malloc call.
|
|
48
|
+
sub sp, sp, #48
|
|
49
|
+
mov x9, x19
|
|
50
|
+
mov x10, x9
|
|
51
|
+
cmp x9, #0
|
|
52
|
+
b.ge .Lit_pos
|
|
53
|
+
neg x10, x10 // magnitude (wraps correctly for INT64_MIN)
|
|
54
|
+
.Lit_pos:
|
|
55
|
+
add x11, sp, #48
|
|
56
|
+
mov x12, x11
|
|
57
|
+
.Lit_digit:
|
|
58
|
+
mov x13, #10
|
|
59
|
+
udiv x14, x10, x13
|
|
60
|
+
msub x15, x14, x13, x10
|
|
61
|
+
add x15, x15, #48
|
|
62
|
+
sub x12, x12, #1
|
|
63
|
+
strb w15, [x12]
|
|
64
|
+
mov x10, x14
|
|
65
|
+
cbnz x10, .Lit_digit
|
|
66
|
+
cmp x9, #0
|
|
67
|
+
b.ge .Lit_store
|
|
68
|
+
sub x12, x12, #1
|
|
69
|
+
mov w15, #45 // '-'
|
|
70
|
+
strb w15, [x12]
|
|
71
|
+
.Lit_store:
|
|
72
|
+
sub x1, x11, x12 // len
|
|
73
|
+
str x12, [sp, #16] // pos
|
|
74
|
+
str x1, [sp, #0] // len
|
|
75
|
+
add x0, x1, #1
|
|
32
76
|
bl _malloc
|
|
33
|
-
str x0, [sp, #
|
|
34
|
-
ldr
|
|
35
|
-
ldr
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
add
|
|
77
|
+
str x0, [sp, #8] // buf
|
|
78
|
+
ldr x1, [sp, #0]
|
|
79
|
+
ldr x12, [sp, #16]
|
|
80
|
+
mov x3, x1
|
|
81
|
+
.Lit_cl:
|
|
82
|
+
cbz x3, .Lit_done
|
|
83
|
+
ldrb w4, [x12]
|
|
84
|
+
strb w4, [x0]
|
|
85
|
+
add x12, x12, #1
|
|
86
|
+
add x0, x0, #1
|
|
87
|
+
sub x3, x3, #1
|
|
88
|
+
b .Lit_cl
|
|
89
|
+
.Lit_done:
|
|
90
|
+
ldr x0, [sp, #8]
|
|
91
|
+
add x2, x0, x1
|
|
92
|
+
strb wzr, [x2] // buf[len] = 0
|
|
93
|
+
ldr x0, [sp, #8]
|
|
94
|
+
ldr x1, [sp, #0]
|
|
95
|
+
add sp, sp, #48
|
|
42
96
|
b .Lend_int_to_string
|
|
43
|
-
.Lfmt_int_ld: .asciz "%ld"
|
|
44
|
-
.p2align 2
|
|
45
97
|
.Lend_int_to_string:
|
|
46
98
|
```
|
|
47
99
|
}
|
package/core/System/int16.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A 16-bit signed integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct int16: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, int16 divisor: divisor != 0, out int16) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, int16 divisor: divisor != 0, out int16) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/int32.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A 32-bit signed integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct int32: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, int32 divisor: divisor != 0, out int32) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, int32 divisor: divisor != 0, out int32) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/int64.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A 64-bit signed integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct int64: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, int64 divisor: divisor != 0, out int64) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, int64 divisor: divisor != 0, out int64) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/int8.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* An 8-bit signed integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct int8: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, int8 divisor: divisor != 0, out int8) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, int8 divisor: divisor != 0, out int8) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/uint.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* An unsigned integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct uint: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, uint divisor: divisor != 0, out uint) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, uint divisor: divisor != 0, out uint) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self
|
|
7
18
|
}
|
package/core/System/uint16.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A 16-bit unsigned integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct uint16: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, uint16 divisor: divisor != 0, out uint16) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, uint16 divisor: divisor != 0, out uint16) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/uint32.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A 32-bit unsigned integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct uint32: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, uint32 divisor: divisor != 0, out uint32) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, uint32 divisor: divisor != 0, out uint32) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/uint64.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* A 64-bit unsigned integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct uint64: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, uint64 divisor: divisor != 0, out uint64) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, uint64 divisor: divisor != 0, out uint64) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
package/core/System/uint8.nm
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* An 8-bit unsigned integer
|
|
3
3
|
**/
|
|
4
4
|
pub struct uint8: Stringable, Hashable, Equatable {
|
|
5
|
+
|
|
6
|
+
// The divisor contract (SPEC, Division and Modulo by Zero): scalar
|
|
7
|
+
// arithmetic lowers natively, so these declarations are the contract
|
|
8
|
+
// signatures the checker enforces at every `/` and `%` site.
|
|
9
|
+
func #op_div = (self, uint8 divisor: divisor != 0, out uint8) {
|
|
10
|
+
return self / divisor
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func #op_mod = (self, uint8 divisor: divisor != 0, out uint8) {
|
|
14
|
+
return self % divisor
|
|
15
|
+
}
|
|
5
16
|
pub func hash = (self, out uint) {
|
|
6
17
|
return self as uint
|
|
7
18
|
}
|
|
@@ -8,5 +8,11 @@ A growable byte buffer for incrementally building strings (O(1) amortized append
|
|
|
8
8
|
|
|
9
9
|
- `ensure(int needed)`
|
|
10
10
|
- `append_char(char c)`
|
|
11
|
+
- `append_int(int n)`
|
|
12
|
+
- `append_float(float f)`
|
|
11
13
|
- `append_string(string s)`
|
|
14
|
+
- `append(view string s)`
|
|
15
|
+
- `append(int n)`
|
|
16
|
+
- `append(float f)`
|
|
17
|
+
- `append(char c)`
|
|
12
18
|
- `to_string() -> string`
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## `struct JsonTree`
|
|
4
4
|
|
|
5
|
-
A flat,
|
|
5
|
+
A flat, pool-backed set of JSON tree nodes — the parsed representation `Json.parse` produces
|
|
6
6
|
|
|
7
7
|
**Members:**
|
|
8
8
|
|
|
9
9
|
- `alloc_node() -> int`
|
|
10
|
-
- `free_text(int idx)`
|
|
11
10
|
- `reset()`
|
|
12
11
|
- `set_text(int idx, string text)`
|
|
13
12
|
- `set_kind(int idx, int val)`
|
|
@@ -16,6 +15,8 @@ A flat, buffer-backed pool of JSON tree nodes — the parsed representation `Jso
|
|
|
16
15
|
- `set_val(int idx, int val)`
|
|
17
16
|
- `get_kind(int idx) -> int`
|
|
18
17
|
- `get_text(int idx) -> string`
|
|
18
|
+
- `get_text_view(int idx) -> view string`
|
|
19
|
+
- `take_text(int idx, ref StringBuilder sb)`
|
|
19
20
|
- `get_child(int idx) -> int`
|
|
20
21
|
- `get_next(int idx) -> int`
|
|
21
22
|
- `get_val(int idx) -> int`
|