nomen-lang 0.2.2 → 0.3.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/core/System/Arena.nm +166 -0
- package/core/System/Array.nm +30 -161
- package/core/System/BigInt.nm +31 -42
- package/core/System/Buffer.nm +67 -249
- package/core/System/ClassBuffer.nm +43 -105
- package/core/System/Controls/LayoutParams.nm +1 -1
- package/core/System/Enumerable.nm +2 -0
- package/core/System/Map.nm +3 -0
- package/core/System/String.nm +256 -19
- package/core/System/StringBuilder.nm +53 -117
- package/core/System/Text/CharIndex.nm +144 -0
- package/core/System/Text/Chars.nm +32 -0
- package/core/System/Text/JsonTree.nm +33 -81
- package/core/System/Text/Regex.nm +726 -40
- package/core/System/Text/Utf8.nm +163 -0
- package/core/System/char.nm +25 -0
- package/dist/index.mjs +3529 -407
- package/package.json +1 -1
- package/src/index.ts +58 -7
|
@@ -36,63 +36,35 @@ pub struct JsonTree {
|
|
|
36
36
|
// empty-string literal) into the slot. JsonTree manages node texts
|
|
37
37
|
// manually (set_text strdup's into the slab; free_text/release frees
|
|
38
38
|
// them; NULL means "no text"), so the slot must start NULL — free the
|
|
39
|
-
// strdup'd default and NULL it, or reset() would leak it.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
ldr x0, [x19, #16]
|
|
53
|
-
ldr x1, [x19, #32]
|
|
54
|
-
sub x1, x1, #1
|
|
55
|
-
mov x3, #56
|
|
56
|
-
madd x1, x1, x3, xzr
|
|
57
|
-
add x0, x0, x1
|
|
58
|
-
add x0, x0, #16
|
|
59
|
-
ldr x1, [x0]
|
|
60
|
-
str xzr, [x0]
|
|
61
|
-
str xzr, [x0, #8]
|
|
62
|
-
cbz x1, .Lalloc_node_text_skip
|
|
63
|
-
mov x0, x1
|
|
64
|
-
bl _free
|
|
65
|
-
.Lalloc_node_text_skip:
|
|
66
|
-
```
|
|
39
|
+
// strdup'd default and NULL it, or reset() would leak it. The slab
|
|
40
|
+
// slot layout: 56-byte JsonNode elements — 7 words — with the text
|
|
41
|
+
// pair at words 2 and 3 of each element.
|
|
42
|
+
unsafe {
|
|
43
|
+
var ptr uint64 slots = self.nodes.data as ptr uint64
|
|
44
|
+
var int t = idx * 7 + 2
|
|
45
|
+
var uint64 old = slots[t]
|
|
46
|
+
if old != 0 {
|
|
47
|
+
free(old)
|
|
48
|
+
}
|
|
49
|
+
slots[t] = 0
|
|
50
|
+
slots[t + 1] = 0
|
|
51
|
+
}
|
|
67
52
|
return idx
|
|
68
53
|
}
|
|
69
54
|
|
|
70
55
|
// Free a node's strdup'd text pointer (set_text writes a heap pointer via
|
|
71
56
|
// raw strdup; this mirrors it). idx is x1, following set_text's layout.
|
|
72
57
|
func free_text = (ref self, int idx) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
madd x1, x1, x3, xzr
|
|
84
|
-
add x0, x0, x1
|
|
85
|
-
add x0, x0, #16
|
|
86
|
-
ldr x2, [x0]
|
|
87
|
-
cbz x2, .Ljsontree_free_text_skip
|
|
88
|
-
str x0, [sp, #-16]!
|
|
89
|
-
mov x0, x2
|
|
90
|
-
bl _free
|
|
91
|
-
ldr x0, [sp], #16
|
|
92
|
-
str xzr, [x0]
|
|
93
|
-
str xzr, [x0, #8]
|
|
94
|
-
.Ljsontree_free_text_skip:
|
|
95
|
-
```
|
|
58
|
+
unsafe {
|
|
59
|
+
var ptr uint64 slots = self.nodes.data as ptr uint64
|
|
60
|
+
var int t = idx * 7 + 2
|
|
61
|
+
var uint64 p = slots[t]
|
|
62
|
+
if p != 0 {
|
|
63
|
+
free(p)
|
|
64
|
+
slots[t] = 0
|
|
65
|
+
slots[t + 1] = 0
|
|
66
|
+
}
|
|
67
|
+
}
|
|
96
68
|
}
|
|
97
69
|
|
|
98
70
|
// Free every strdup'd text pointer before reusing the slab, otherwise
|
|
@@ -121,36 +93,16 @@ pub struct JsonTree {
|
|
|
121
93
|
// emitted behind the _raw_ adapter, so `text` arrives as a thin char*;
|
|
122
94
|
// aarch64 receives the pair x2 = ptr, x3 = len.)
|
|
123
95
|
func set_text = (ref self, int idx, string text) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// text field is at offset 16 in JsonNode (vt[0] + kind[8]); the fat
|
|
135
|
-
// field is ptr@+16, len@+24; sizeof(JsonNode) = 56.
|
|
136
|
-
sub sp, sp, #32
|
|
137
|
-
str x1, [sp, #0]
|
|
138
|
-
str x3, [sp, #8]
|
|
139
|
-
mov x0, x2
|
|
140
|
-
bl _strdup
|
|
141
|
-
str x0, [sp, #16]
|
|
142
|
-
ldr x0, [x19, #16]
|
|
143
|
-
ldr x1, [sp, #0]
|
|
144
|
-
mov x3, #56
|
|
145
|
-
madd x1, x1, x3, xzr
|
|
146
|
-
add x0, x0, x1
|
|
147
|
-
add x0, x0, #16
|
|
148
|
-
ldr x1, [sp, #16]
|
|
149
|
-
str x1, [x0]
|
|
150
|
-
ldr x1, [sp, #8]
|
|
151
|
-
str x1, [x0, #8]
|
|
152
|
-
add sp, sp, #32
|
|
153
|
-
```
|
|
96
|
+
unsafe {
|
|
97
|
+
var int len = text.length
|
|
98
|
+
var uint64 buf = malloc(len + 1)
|
|
99
|
+
memcpy(buf, (text as ptr char) as uint64, len)
|
|
100
|
+
memset(buf + len, 0, 1)
|
|
101
|
+
var ptr uint64 slots = self.nodes.data as ptr uint64
|
|
102
|
+
var int t = idx * 7 + 2
|
|
103
|
+
slots[t] = buf
|
|
104
|
+
slots[t + 1] = len
|
|
105
|
+
}
|
|
154
106
|
}
|
|
155
107
|
|
|
156
108
|
func set_kind = (ref self, int idx, int val) {
|