goscript 0.0.23 → 0.0.25
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/README.md +2 -2
- package/cmd/goscript/cmd_compile.go +18 -2
- package/compiler/analysis.go +74 -132
- package/compiler/analysis_test.go +220 -0
- package/compiler/assignment.go +37 -43
- package/compiler/builtin_test.go +90 -0
- package/compiler/compiler.go +307 -22
- package/compiler/composite-lit.go +108 -43
- package/compiler/config.go +7 -3
- package/compiler/config_test.go +6 -33
- package/compiler/decl.go +7 -1
- package/compiler/expr-call.go +212 -2
- package/compiler/expr-selector.go +66 -41
- package/compiler/expr-star.go +57 -65
- package/compiler/expr-type.go +1 -1
- package/compiler/expr-value.go +1 -1
- package/compiler/expr.go +125 -20
- package/compiler/field.go +4 -4
- package/compiler/primitive.go +11 -10
- package/compiler/spec-struct.go +3 -3
- package/compiler/spec-value.go +75 -29
- package/compiler/spec.go +9 -3
- package/compiler/stmt-assign.go +36 -2
- package/compiler/stmt-for.go +11 -0
- package/compiler/stmt-range.go +314 -1
- package/compiler/stmt.go +52 -0
- package/compiler/type.go +83 -15
- package/dist/gs/builtin/builtin.d.ts +9 -0
- package/dist/gs/builtin/builtin.js +46 -0
- package/dist/gs/builtin/builtin.js.map +1 -0
- package/dist/gs/builtin/channel.d.ts +193 -0
- package/dist/gs/builtin/channel.js +471 -0
- package/dist/gs/builtin/channel.js.map +1 -0
- package/dist/gs/builtin/defer.d.ts +38 -0
- package/dist/gs/builtin/defer.js +54 -0
- package/dist/gs/builtin/defer.js.map +1 -0
- package/dist/gs/builtin/index.d.ts +1 -0
- package/dist/gs/builtin/index.js +2 -0
- package/dist/gs/builtin/index.js.map +1 -0
- package/dist/gs/builtin/io.d.ts +16 -0
- package/dist/gs/builtin/io.js +15 -0
- package/dist/gs/builtin/io.js.map +1 -0
- package/dist/gs/builtin/map.d.ts +33 -0
- package/dist/gs/builtin/map.js +44 -0
- package/dist/gs/builtin/map.js.map +1 -0
- package/dist/gs/builtin/slice.d.ts +173 -0
- package/dist/gs/builtin/slice.js +799 -0
- package/dist/gs/builtin/slice.js.map +1 -0
- package/dist/gs/builtin/type.d.ts +203 -0
- package/dist/gs/builtin/type.js +744 -0
- package/dist/gs/builtin/type.js.map +1 -0
- package/dist/gs/builtin/varRef.d.ts +14 -0
- package/dist/gs/builtin/varRef.js +14 -0
- package/dist/gs/builtin/varRef.js.map +1 -0
- package/dist/gs/cmp/index.d.ts +4 -0
- package/dist/gs/cmp/index.js +27 -0
- package/dist/gs/cmp/index.js.map +1 -0
- package/dist/gs/context/context.d.ts +26 -0
- package/dist/gs/context/context.js +305 -0
- package/dist/gs/context/context.js.map +1 -0
- package/dist/gs/context/index.d.ts +1 -0
- package/dist/gs/context/index.js +2 -0
- package/dist/gs/context/index.js.map +1 -0
- package/dist/gs/internal/goarch/index.d.ts +6 -0
- package/dist/gs/internal/goarch/index.js +14 -0
- package/dist/gs/internal/goarch/index.js.map +1 -0
- package/dist/gs/iter/index.d.ts +1 -0
- package/dist/gs/iter/index.js +2 -0
- package/dist/gs/iter/index.js.map +1 -0
- package/dist/gs/iter/iter.d.ts +4 -0
- package/dist/gs/iter/iter.js +91 -0
- package/dist/gs/iter/iter.js.map +1 -0
- package/dist/gs/math/bits/index.d.ts +47 -0
- package/dist/gs/math/bits/index.js +298 -0
- package/dist/gs/math/bits/index.js.map +1 -0
- package/dist/gs/runtime/index.d.ts +1 -0
- package/dist/gs/runtime/index.js +2 -0
- package/dist/gs/runtime/index.js.map +1 -0
- package/dist/gs/runtime/runtime.d.ts +41 -0
- package/dist/gs/runtime/runtime.js +158 -0
- package/dist/gs/runtime/runtime.js.map +1 -0
- package/dist/gs/slices/index.d.ts +1 -0
- package/dist/gs/slices/index.js +2 -0
- package/dist/gs/slices/index.js.map +1 -0
- package/dist/gs/slices/slices.d.ts +8 -0
- package/dist/gs/slices/slices.js +20 -0
- package/dist/gs/slices/slices.js.map +1 -0
- package/dist/gs/time/index.d.ts +1 -0
- package/dist/gs/time/index.js +2 -0
- package/dist/gs/time/index.js.map +1 -0
- package/dist/gs/time/time.d.ts +57 -0
- package/dist/gs/time/time.js +208 -0
- package/dist/gs/time/time.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const UintSize = 32;
|
|
2
|
+
export declare function LeadingZeros(x: number): number;
|
|
3
|
+
export declare function LeadingZeros8(x: number): number;
|
|
4
|
+
export declare function LeadingZeros16(x: number): number;
|
|
5
|
+
export declare function LeadingZeros32(x: number): number;
|
|
6
|
+
export declare function LeadingZeros64(x: bigint): number;
|
|
7
|
+
export declare function TrailingZeros(x: number): number;
|
|
8
|
+
export declare function TrailingZeros8(x: number): number;
|
|
9
|
+
export declare function TrailingZeros16(x: number): number;
|
|
10
|
+
export declare function TrailingZeros32(x: number): number;
|
|
11
|
+
export declare function TrailingZeros64(x: bigint): number;
|
|
12
|
+
export declare function OnesCount(x: number): number;
|
|
13
|
+
export declare function OnesCount8(x: number): number;
|
|
14
|
+
export declare function OnesCount16(x: number): number;
|
|
15
|
+
export declare function OnesCount32(x: number): number;
|
|
16
|
+
export declare function OnesCount64(x: bigint): number;
|
|
17
|
+
export declare function RotateLeft(x: number, k: number): number;
|
|
18
|
+
export declare function RotateLeft8(x: number, k: number): number;
|
|
19
|
+
export declare function RotateLeft16(x: number, k: number): number;
|
|
20
|
+
export declare function RotateLeft32(x: number, k: number): number;
|
|
21
|
+
export declare function RotateLeft64(x: bigint, k: number): bigint;
|
|
22
|
+
export declare function Reverse(x: number): number;
|
|
23
|
+
export declare function Reverse8(x: number): number;
|
|
24
|
+
export declare function Reverse16(x: number): number;
|
|
25
|
+
export declare function Reverse32(x: number): number;
|
|
26
|
+
export declare function Reverse64(x: bigint): bigint;
|
|
27
|
+
export declare function ReverseBytes(x: number): number;
|
|
28
|
+
export declare function ReverseBytes16(x: number): number;
|
|
29
|
+
export declare function ReverseBytes32(x: number): number;
|
|
30
|
+
export declare function ReverseBytes64(x: bigint): bigint;
|
|
31
|
+
export declare function Len(x: number): number;
|
|
32
|
+
export declare function Len8(x: number): number;
|
|
33
|
+
export declare function Len16(x: number): number;
|
|
34
|
+
export declare function Len32(x: number): number;
|
|
35
|
+
export declare function Len64(x: bigint): number;
|
|
36
|
+
export declare function Mul(x: number, y: number): [number, number];
|
|
37
|
+
export declare function Mul32(x: number, y: number): [number, number];
|
|
38
|
+
export declare function Mul64(x: bigint, y: bigint): [bigint, bigint];
|
|
39
|
+
export declare function Div(hi: number, lo: number, y: number): [number, number];
|
|
40
|
+
export declare function Div32(hi: number, lo: number, y: number): [number, number];
|
|
41
|
+
export declare function Div64(hi: bigint, lo: bigint, y: bigint): [bigint, bigint];
|
|
42
|
+
export declare function Add(x: number, y: number, carry: number): [number, number];
|
|
43
|
+
export declare function Add32(x: number, y: number, carry: number): [number, number];
|
|
44
|
+
export declare function Add64(x: bigint, y: bigint, carry: bigint): [bigint, bigint];
|
|
45
|
+
export declare function Sub(x: number, y: number, borrow: number): [number, number];
|
|
46
|
+
export declare function Sub32(x: number, y: number, borrow: number): [number, number];
|
|
47
|
+
export declare function Sub64(x: bigint, y: bigint, borrow: bigint): [bigint, bigint];
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// Minimal stub for math/bits package
|
|
2
|
+
// This replaces the auto-generated version that has TypeScript syntax errors
|
|
3
|
+
// UintSize is the size of a uint in bits
|
|
4
|
+
export const UintSize = 32; // Assuming 32-bit for JavaScript numbers
|
|
5
|
+
// --- Leading zeros ---
|
|
6
|
+
export function LeadingZeros(x) {
|
|
7
|
+
return Math.clz32(x >>> 0);
|
|
8
|
+
}
|
|
9
|
+
export function LeadingZeros8(x) {
|
|
10
|
+
return Math.clz32((x & 0xFF) << 24);
|
|
11
|
+
}
|
|
12
|
+
export function LeadingZeros16(x) {
|
|
13
|
+
return Math.clz32((x & 0xFFFF) << 16);
|
|
14
|
+
}
|
|
15
|
+
export function LeadingZeros32(x) {
|
|
16
|
+
return Math.clz32(x >>> 0);
|
|
17
|
+
}
|
|
18
|
+
export function LeadingZeros64(x) {
|
|
19
|
+
// For 64-bit, we need to handle it differently
|
|
20
|
+
if (x === 0n)
|
|
21
|
+
return 64;
|
|
22
|
+
let count = 0;
|
|
23
|
+
let mask = 1n << 63n;
|
|
24
|
+
while ((x & mask) === 0n && count < 64) {
|
|
25
|
+
count++;
|
|
26
|
+
mask >>= 1n;
|
|
27
|
+
}
|
|
28
|
+
return count;
|
|
29
|
+
}
|
|
30
|
+
// --- Trailing zeros ---
|
|
31
|
+
export function TrailingZeros(x) {
|
|
32
|
+
if (x === 0)
|
|
33
|
+
return UintSize;
|
|
34
|
+
return TrailingZeros32(x);
|
|
35
|
+
}
|
|
36
|
+
export function TrailingZeros8(x) {
|
|
37
|
+
if (x === 0)
|
|
38
|
+
return 8;
|
|
39
|
+
return Math.min(8, TrailingZeros32(x));
|
|
40
|
+
}
|
|
41
|
+
export function TrailingZeros16(x) {
|
|
42
|
+
if (x === 0)
|
|
43
|
+
return 16;
|
|
44
|
+
return Math.min(16, TrailingZeros32(x));
|
|
45
|
+
}
|
|
46
|
+
export function TrailingZeros32(x) {
|
|
47
|
+
if (x === 0)
|
|
48
|
+
return 32;
|
|
49
|
+
let count = 0;
|
|
50
|
+
while ((x & 1) === 0) {
|
|
51
|
+
count++;
|
|
52
|
+
x >>>= 1;
|
|
53
|
+
}
|
|
54
|
+
return count;
|
|
55
|
+
}
|
|
56
|
+
export function TrailingZeros64(x) {
|
|
57
|
+
if (x === 0n)
|
|
58
|
+
return 64;
|
|
59
|
+
let count = 0;
|
|
60
|
+
while ((x & 1n) === 0n && count < 64) {
|
|
61
|
+
count++;
|
|
62
|
+
x >>= 1n;
|
|
63
|
+
}
|
|
64
|
+
return count;
|
|
65
|
+
}
|
|
66
|
+
// --- Ones count ---
|
|
67
|
+
export function OnesCount(x) {
|
|
68
|
+
return OnesCount32(x);
|
|
69
|
+
}
|
|
70
|
+
export function OnesCount8(x) {
|
|
71
|
+
return OnesCount32(x & 0xFF);
|
|
72
|
+
}
|
|
73
|
+
export function OnesCount16(x) {
|
|
74
|
+
return OnesCount32(x & 0xFFFF);
|
|
75
|
+
}
|
|
76
|
+
export function OnesCount32(x) {
|
|
77
|
+
// Brian Kernighan's algorithm
|
|
78
|
+
let count = 0;
|
|
79
|
+
x = x >>> 0; // Ensure unsigned
|
|
80
|
+
while (x) {
|
|
81
|
+
count++;
|
|
82
|
+
x &= x - 1;
|
|
83
|
+
}
|
|
84
|
+
return count;
|
|
85
|
+
}
|
|
86
|
+
export function OnesCount64(x) {
|
|
87
|
+
let count = 0;
|
|
88
|
+
while (x > 0n) {
|
|
89
|
+
count++;
|
|
90
|
+
x &= x - 1n;
|
|
91
|
+
}
|
|
92
|
+
return count;
|
|
93
|
+
}
|
|
94
|
+
// --- Rotate left ---
|
|
95
|
+
export function RotateLeft(x, k) {
|
|
96
|
+
return RotateLeft32(x, k);
|
|
97
|
+
}
|
|
98
|
+
export function RotateLeft8(x, k) {
|
|
99
|
+
const n = 8;
|
|
100
|
+
k = k % n;
|
|
101
|
+
x = x & 0xFF;
|
|
102
|
+
return ((x << k) | (x >> (n - k))) & 0xFF;
|
|
103
|
+
}
|
|
104
|
+
export function RotateLeft16(x, k) {
|
|
105
|
+
const n = 16;
|
|
106
|
+
k = k % n;
|
|
107
|
+
x = x & 0xFFFF;
|
|
108
|
+
return ((x << k) | (x >> (n - k))) & 0xFFFF;
|
|
109
|
+
}
|
|
110
|
+
export function RotateLeft32(x, k) {
|
|
111
|
+
const n = 32;
|
|
112
|
+
k = k % n;
|
|
113
|
+
x = x >>> 0; // Ensure unsigned
|
|
114
|
+
return ((x << k) | (x >>> (n - k))) >>> 0;
|
|
115
|
+
}
|
|
116
|
+
export function RotateLeft64(x, k) {
|
|
117
|
+
const n = 64;
|
|
118
|
+
k = k % n;
|
|
119
|
+
const mask = (1n << 64n) - 1n;
|
|
120
|
+
x = x & mask;
|
|
121
|
+
return ((x << BigInt(k)) | (x >> BigInt(n - k))) & mask;
|
|
122
|
+
}
|
|
123
|
+
// --- Reverse ---
|
|
124
|
+
export function Reverse(x) {
|
|
125
|
+
return Reverse32(x);
|
|
126
|
+
}
|
|
127
|
+
export function Reverse8(x) {
|
|
128
|
+
x = x & 0xFF;
|
|
129
|
+
x = ((x & 0xF0) >> 4) | ((x & 0x0F) << 4);
|
|
130
|
+
x = ((x & 0xCC) >> 2) | ((x & 0x33) << 2);
|
|
131
|
+
x = ((x & 0xAA) >> 1) | ((x & 0x55) << 1);
|
|
132
|
+
return x;
|
|
133
|
+
}
|
|
134
|
+
export function Reverse16(x) {
|
|
135
|
+
x = x & 0xFFFF;
|
|
136
|
+
x = ((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8);
|
|
137
|
+
x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);
|
|
138
|
+
x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);
|
|
139
|
+
x = ((x & 0xAAAA) >> 1) | ((x & 0x5555) << 1);
|
|
140
|
+
return x;
|
|
141
|
+
}
|
|
142
|
+
export function Reverse32(x) {
|
|
143
|
+
x = x >>> 0; // Ensure unsigned
|
|
144
|
+
x = ((x & 0xFFFF0000) >>> 16) | ((x & 0x0000FFFF) << 16);
|
|
145
|
+
x = ((x & 0xFF00FF00) >>> 8) | ((x & 0x00FF00FF) << 8);
|
|
146
|
+
x = ((x & 0xF0F0F0F0) >>> 4) | ((x & 0x0F0F0F0F) << 4);
|
|
147
|
+
x = ((x & 0xCCCCCCCC) >>> 2) | ((x & 0x33333333) << 2);
|
|
148
|
+
x = ((x & 0xAAAAAAAA) >>> 1) | ((x & 0x55555555) << 1);
|
|
149
|
+
return x >>> 0;
|
|
150
|
+
}
|
|
151
|
+
export function Reverse64(x) {
|
|
152
|
+
// Implement 64-bit reverse using similar bit manipulation
|
|
153
|
+
const mask = (1n << 64n) - 1n;
|
|
154
|
+
x = x & mask;
|
|
155
|
+
// Swap 32-bit halves
|
|
156
|
+
x = ((x & 0xffffffff00000000n) >> 32n) | ((x & 0x00000000ffffffffn) << 32n);
|
|
157
|
+
// Swap 16-bit chunks
|
|
158
|
+
x = ((x & 0xffff0000ffff0000n) >> 16n) | ((x & 0x0000ffff0000ffffn) << 16n);
|
|
159
|
+
// Swap 8-bit chunks
|
|
160
|
+
x = ((x & 0xff00ff00ff00ff00n) >> 8n) | ((x & 0x00ff00ff00ff00ffn) << 8n);
|
|
161
|
+
// Swap 4-bit chunks
|
|
162
|
+
x = ((x & 0xf0f0f0f0f0f0f0f0n) >> 4n) | ((x & 0x0f0f0f0f0f0f0f0fn) << 4n);
|
|
163
|
+
// Swap 2-bit chunks
|
|
164
|
+
x = ((x & 0xccccccccccccccccn) >> 2n) | ((x & 0x3333333333333333n) << 2n);
|
|
165
|
+
// Swap 1-bit chunks
|
|
166
|
+
x = ((x & 0xaaaaaaaaaaaaaaaan) >> 1n) | ((x & 0x5555555555555555n) << 1n);
|
|
167
|
+
return x & mask;
|
|
168
|
+
}
|
|
169
|
+
// --- ReverseBytes ---
|
|
170
|
+
export function ReverseBytes(x) {
|
|
171
|
+
return ReverseBytes32(x);
|
|
172
|
+
}
|
|
173
|
+
export function ReverseBytes16(x) {
|
|
174
|
+
return ((x & 0xFF) << 8) | ((x & 0xFF00) >> 8);
|
|
175
|
+
}
|
|
176
|
+
export function ReverseBytes32(x) {
|
|
177
|
+
x = x >>> 0; // Ensure unsigned
|
|
178
|
+
return (((x & 0xFF) << 24) |
|
|
179
|
+
((x & 0xFF00) << 8) |
|
|
180
|
+
((x & 0xFF0000) >> 8) |
|
|
181
|
+
((x & 0xFF000000) >>> 24)) >>> 0;
|
|
182
|
+
}
|
|
183
|
+
export function ReverseBytes64(x) {
|
|
184
|
+
const mask = (1n << 64n) - 1n;
|
|
185
|
+
x = x & mask;
|
|
186
|
+
return (((x & 0xffn) << 56n) |
|
|
187
|
+
((x & 0xff00n) << 40n) |
|
|
188
|
+
((x & 0xff0000n) << 24n) |
|
|
189
|
+
((x & 0xff000000n) << 8n) |
|
|
190
|
+
((x & 0xff00000000n) >> 8n) |
|
|
191
|
+
((x & 0xff0000000000n) >> 24n) |
|
|
192
|
+
((x & 0xff000000000000n) >> 40n) |
|
|
193
|
+
((x & 0xff00000000000000n) >> 56n)) & mask;
|
|
194
|
+
}
|
|
195
|
+
// --- Len ---
|
|
196
|
+
export function Len(x) {
|
|
197
|
+
return Len32(x);
|
|
198
|
+
}
|
|
199
|
+
export function Len8(x) {
|
|
200
|
+
return 8 - LeadingZeros8(x);
|
|
201
|
+
}
|
|
202
|
+
export function Len16(x) {
|
|
203
|
+
return 16 - LeadingZeros16(x);
|
|
204
|
+
}
|
|
205
|
+
export function Len32(x) {
|
|
206
|
+
return 32 - LeadingZeros32(x);
|
|
207
|
+
}
|
|
208
|
+
export function Len64(x) {
|
|
209
|
+
return 64 - LeadingZeros64(x);
|
|
210
|
+
}
|
|
211
|
+
// --- Multiplication functions ---
|
|
212
|
+
export function Mul(x, y) {
|
|
213
|
+
return Mul32(x, y);
|
|
214
|
+
}
|
|
215
|
+
export function Mul32(x, y) {
|
|
216
|
+
// For 32-bit multiplication, we can use JavaScript's number precision
|
|
217
|
+
const result = (x >>> 0) * (y >>> 0);
|
|
218
|
+
const hi = Math.floor(result / 0x100000000) >>> 0;
|
|
219
|
+
const lo = result >>> 0;
|
|
220
|
+
return [hi, lo];
|
|
221
|
+
}
|
|
222
|
+
export function Mul64(x, y) {
|
|
223
|
+
const mask32 = 0xffffffffn;
|
|
224
|
+
// Split into 32-bit parts
|
|
225
|
+
const x0 = x & mask32;
|
|
226
|
+
const x1 = x >> 32n;
|
|
227
|
+
const y0 = y & mask32;
|
|
228
|
+
const y1 = y >> 32n;
|
|
229
|
+
// Multiply parts
|
|
230
|
+
const p00 = x0 * y0;
|
|
231
|
+
const p01 = x0 * y1;
|
|
232
|
+
const p10 = x1 * y0;
|
|
233
|
+
const p11 = x1 * y1;
|
|
234
|
+
// Combine results
|
|
235
|
+
const lo = p00 + ((p01 + p10) << 32n);
|
|
236
|
+
const hi = p11 + ((p01 + p10) >> 32n) + (lo < p00 ? 1n : 0n);
|
|
237
|
+
return [hi, lo];
|
|
238
|
+
}
|
|
239
|
+
// --- Division functions ---
|
|
240
|
+
export function Div(hi, lo, y) {
|
|
241
|
+
return Div32(hi, lo, y);
|
|
242
|
+
}
|
|
243
|
+
export function Div32(hi, lo, y) {
|
|
244
|
+
if (y === 0) {
|
|
245
|
+
throw new Error("division by zero");
|
|
246
|
+
}
|
|
247
|
+
// Combine hi and lo into a 64-bit value using BigInt for precision
|
|
248
|
+
const dividend = (BigInt(hi >>> 0) << 32n) | BigInt(lo >>> 0);
|
|
249
|
+
const divisor = BigInt(y >>> 0);
|
|
250
|
+
const quotient = dividend / divisor;
|
|
251
|
+
const remainder = dividend % divisor;
|
|
252
|
+
return [Number(quotient), Number(remainder)];
|
|
253
|
+
}
|
|
254
|
+
export function Div64(hi, lo, y) {
|
|
255
|
+
if (y === 0n) {
|
|
256
|
+
throw new Error("division by zero");
|
|
257
|
+
}
|
|
258
|
+
// Combine hi and lo into a 128-bit value (simulated)
|
|
259
|
+
// For simplicity, we'll use a basic implementation
|
|
260
|
+
const dividend = (hi << 64n) | lo;
|
|
261
|
+
const quotient = dividend / y;
|
|
262
|
+
const remainder = dividend % y;
|
|
263
|
+
return [quotient, remainder];
|
|
264
|
+
}
|
|
265
|
+
// --- Add and Sub with carry ---
|
|
266
|
+
export function Add(x, y, carry) {
|
|
267
|
+
return Add32(x, y, carry);
|
|
268
|
+
}
|
|
269
|
+
export function Add32(x, y, carry) {
|
|
270
|
+
const sum = (x >>> 0) + (y >>> 0) + (carry >>> 0);
|
|
271
|
+
const result = sum >>> 0;
|
|
272
|
+
const carryOut = sum > 0xFFFFFFFF ? 1 : 0;
|
|
273
|
+
return [result, carryOut];
|
|
274
|
+
}
|
|
275
|
+
export function Add64(x, y, carry) {
|
|
276
|
+
const mask = (1n << 64n) - 1n;
|
|
277
|
+
const sum = (x & mask) + (y & mask) + (carry & mask);
|
|
278
|
+
const result = sum & mask;
|
|
279
|
+
const carryOut = sum > mask ? 1n : 0n;
|
|
280
|
+
return [result, carryOut];
|
|
281
|
+
}
|
|
282
|
+
export function Sub(x, y, borrow) {
|
|
283
|
+
return Sub32(x, y, borrow);
|
|
284
|
+
}
|
|
285
|
+
export function Sub32(x, y, borrow) {
|
|
286
|
+
const diff = (x >>> 0) - (y >>> 0) - (borrow >>> 0);
|
|
287
|
+
const result = diff >>> 0;
|
|
288
|
+
const borrowOut = diff < 0 ? 1 : 0;
|
|
289
|
+
return [result, borrowOut];
|
|
290
|
+
}
|
|
291
|
+
export function Sub64(x, y, borrow) {
|
|
292
|
+
const mask = (1n << 64n) - 1n;
|
|
293
|
+
const diff = (x & mask) - (y & mask) - (borrow & mask);
|
|
294
|
+
const result = diff & mask;
|
|
295
|
+
const borrowOut = diff < 0n ? 1n : 0n;
|
|
296
|
+
return [result, borrowOut];
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/math/bits/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,6EAA6E;AAE7E,yCAAyC;AACzC,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC,CAAC,yCAAyC;AAErE,wBAAwB;AACxB,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAS;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;A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CAAC,EAAE,CAAC;IACtC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const GOOS = "js";
|
|
2
|
+
export declare const GOARCH = "wasm";
|
|
3
|
+
export declare function Version(): string;
|
|
4
|
+
export declare function GOMAXPROCS(n: number): number;
|
|
5
|
+
export declare function NumCPU(): number;
|
|
6
|
+
export declare function GC(): void;
|
|
7
|
+
export declare function Gosched(): Promise<void>;
|
|
8
|
+
export declare function NumGoroutine(): number;
|
|
9
|
+
export declare function _incrementGoroutineCount(): void;
|
|
10
|
+
export declare function _decrementGoroutineCount(): void;
|
|
11
|
+
export declare function Caller(skip: number): [number, string, number, boolean];
|
|
12
|
+
export declare function Stack(): Uint8Array;
|
|
13
|
+
export declare class MemStats {
|
|
14
|
+
Alloc: number;
|
|
15
|
+
TotalAlloc: number;
|
|
16
|
+
Sys: number;
|
|
17
|
+
Lookups: number;
|
|
18
|
+
Mallocs: number;
|
|
19
|
+
Frees: number;
|
|
20
|
+
constructor();
|
|
21
|
+
private updateMemoryStats;
|
|
22
|
+
}
|
|
23
|
+
export declare function ReadMemStats(m: MemStats): void;
|
|
24
|
+
export interface Error {
|
|
25
|
+
Error(): string;
|
|
26
|
+
}
|
|
27
|
+
export declare class TypeAssertionError implements Error {
|
|
28
|
+
readonly interfaceType: string;
|
|
29
|
+
readonly concrete: string;
|
|
30
|
+
readonly assertedType: string;
|
|
31
|
+
readonly missingMethod?: string | undefined;
|
|
32
|
+
constructor(interfaceType: string, concrete: string, assertedType: string, missingMethod?: string | undefined);
|
|
33
|
+
Error(): string;
|
|
34
|
+
}
|
|
35
|
+
export declare class PanicError implements Error {
|
|
36
|
+
readonly value: any;
|
|
37
|
+
constructor(value: any);
|
|
38
|
+
Error(): string;
|
|
39
|
+
}
|
|
40
|
+
export declare function SetFinalizer(obj: object, finalizer: ((obj: object) => void) | null): void;
|
|
41
|
+
export declare function KeepAlive(obj: any): void;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Runtime constants for the JavaScript/WebAssembly target
|
|
2
|
+
export const GOOS = "js";
|
|
3
|
+
export const GOARCH = "wasm";
|
|
4
|
+
// Version returns the Go version as a string
|
|
5
|
+
export function Version() {
|
|
6
|
+
return "go1.22.0"; // Static version for goscript compatibility
|
|
7
|
+
}
|
|
8
|
+
// GOMAXPROCS sets the maximum number of operating system threads
|
|
9
|
+
// In JavaScript/browser environment, this is mostly informational
|
|
10
|
+
export function GOMAXPROCS(n) {
|
|
11
|
+
// In browser/JS environment, we can't actually control OS threads
|
|
12
|
+
// Return number of logical CPUs available, or previous value
|
|
13
|
+
if (n < 1) {
|
|
14
|
+
// Return current "setting" (number of logical CPUs)
|
|
15
|
+
return NumCPU();
|
|
16
|
+
}
|
|
17
|
+
// In a real implementation, we would set the max procs
|
|
18
|
+
// For JS/browser, we just return the requested value
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
// NumCPU returns the number of logical CPUs usable by the current process
|
|
22
|
+
export function NumCPU() {
|
|
23
|
+
// In browser environment, use navigator.hardwareConcurrency if available
|
|
24
|
+
if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {
|
|
25
|
+
return navigator.hardwareConcurrency;
|
|
26
|
+
}
|
|
27
|
+
// Default to 1 if we can't determine
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
// GC runs a garbage collection and blocks the caller until the
|
|
31
|
+
// garbage collection is complete. In JavaScript, we can suggest GC but not force it.
|
|
32
|
+
export function GC() {
|
|
33
|
+
// In JavaScript, we can't force garbage collection
|
|
34
|
+
// Some engines have gc() function in development, but it's not standard
|
|
35
|
+
if (typeof globalThis.gc === 'function') {
|
|
36
|
+
globalThis.gc();
|
|
37
|
+
}
|
|
38
|
+
// Otherwise, this is a no-op
|
|
39
|
+
}
|
|
40
|
+
// Gosched yields the processor, allowing other goroutines to run.
|
|
41
|
+
// In JavaScript, we can use setTimeout(0) or queueMicrotask for similar effect
|
|
42
|
+
export function Gosched() {
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
queueMicrotask(resolve);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// NumGoroutine returns the number of goroutines that currently exist.
|
|
48
|
+
// In goscript, this is informational only
|
|
49
|
+
let goroutineCount = 1; // Start with main goroutine
|
|
50
|
+
export function NumGoroutine() {
|
|
51
|
+
return goroutineCount;
|
|
52
|
+
}
|
|
53
|
+
// Internal function to track goroutine creation (called by goscript runtime)
|
|
54
|
+
export function _incrementGoroutineCount() {
|
|
55
|
+
goroutineCount++;
|
|
56
|
+
}
|
|
57
|
+
// Internal function to track goroutine completion (called by goscript runtime)
|
|
58
|
+
export function _decrementGoroutineCount() {
|
|
59
|
+
if (goroutineCount > 0) {
|
|
60
|
+
goroutineCount--;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Caller returns details about the calling goroutine's stack.
|
|
64
|
+
// This is a simplified version for goscript
|
|
65
|
+
export function Caller(skip) {
|
|
66
|
+
// In JavaScript, we can use Error stack trace, but it's limited
|
|
67
|
+
// Return dummy values for goscript compatibility
|
|
68
|
+
const pc = 0; // program counter (not meaningful in JS)
|
|
69
|
+
const file = "unknown";
|
|
70
|
+
const line = 0;
|
|
71
|
+
const ok = false; // indicate we don't have real stack info
|
|
72
|
+
return [pc, file, line, ok];
|
|
73
|
+
}
|
|
74
|
+
// Stack returns a formatted stack trace of the calling goroutine.
|
|
75
|
+
// In JavaScript, we use Error.stack
|
|
76
|
+
export function Stack() {
|
|
77
|
+
const stack = new Error().stack || "stack trace unavailable";
|
|
78
|
+
const encoder = new TextEncoder();
|
|
79
|
+
return encoder.encode(stack);
|
|
80
|
+
}
|
|
81
|
+
// MemStats represents memory allocation statistics
|
|
82
|
+
export class MemStats {
|
|
83
|
+
// Simplified memory stats for goscript
|
|
84
|
+
Alloc = 0; // bytes allocated and not yet freed
|
|
85
|
+
TotalAlloc = 0; // bytes allocated (even if freed)
|
|
86
|
+
Sys = 0; // bytes obtained from system
|
|
87
|
+
Lookups = 0; // number of pointer lookups
|
|
88
|
+
Mallocs = 0; // number of mallocs
|
|
89
|
+
Frees = 0; // number of frees
|
|
90
|
+
constructor() {
|
|
91
|
+
// Initialize with some default values
|
|
92
|
+
// In a real environment, these would be obtained from the JS runtime
|
|
93
|
+
this.updateMemoryStats();
|
|
94
|
+
}
|
|
95
|
+
updateMemoryStats() {
|
|
96
|
+
// Use performance.memory if available (Chrome/Edge)
|
|
97
|
+
if (typeof performance !== 'undefined' && performance.memory) {
|
|
98
|
+
const mem = performance.memory;
|
|
99
|
+
this.Alloc = mem.usedJSHeapSize || 0;
|
|
100
|
+
this.Sys = mem.totalJSHeapSize || 0;
|
|
101
|
+
this.TotalAlloc = this.Alloc; // Simplified
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// ReadMemStats populates m with memory allocator statistics
|
|
106
|
+
export function ReadMemStats(m) {
|
|
107
|
+
// Update the provided MemStats object with current values
|
|
108
|
+
if (typeof performance !== 'undefined' && performance.memory) {
|
|
109
|
+
const mem = performance.memory;
|
|
110
|
+
m.Alloc = mem.usedJSHeapSize || 0;
|
|
111
|
+
m.Sys = mem.totalJSHeapSize || 0;
|
|
112
|
+
m.TotalAlloc = m.Alloc; // Simplified
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// TypeAssertionError represents a failed type assertion
|
|
116
|
+
export class TypeAssertionError {
|
|
117
|
+
interfaceType;
|
|
118
|
+
concrete;
|
|
119
|
+
assertedType;
|
|
120
|
+
missingMethod;
|
|
121
|
+
constructor(interfaceType, concrete, assertedType, missingMethod) {
|
|
122
|
+
this.interfaceType = interfaceType;
|
|
123
|
+
this.concrete = concrete;
|
|
124
|
+
this.assertedType = assertedType;
|
|
125
|
+
this.missingMethod = missingMethod;
|
|
126
|
+
}
|
|
127
|
+
Error() {
|
|
128
|
+
if (this.missingMethod) {
|
|
129
|
+
return `interface conversion: ${this.interfaceType} is ${this.concrete}, not ${this.assertedType} (missing ${this.missingMethod} method)`;
|
|
130
|
+
}
|
|
131
|
+
return `interface conversion: ${this.interfaceType} is ${this.concrete}, not ${this.assertedType}`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// PanicError represents a panic
|
|
135
|
+
export class PanicError {
|
|
136
|
+
value;
|
|
137
|
+
constructor(value) {
|
|
138
|
+
this.value = value;
|
|
139
|
+
}
|
|
140
|
+
Error() {
|
|
141
|
+
return `panic: ${this.value}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// SetFinalizer sets the finalizer associated with obj to the provided finalizer function.
|
|
145
|
+
// In goscript/TypeScript environment, finalizers are not supported, so this throws an error.
|
|
146
|
+
export function SetFinalizer(obj, finalizer) {
|
|
147
|
+
throw new Error("runtime.SetFinalizer is not supported in goscript TypeScript environment");
|
|
148
|
+
}
|
|
149
|
+
// KeepAlive keeps obj reachable until the point where KeepAlive is called
|
|
150
|
+
export function KeepAlive(obj) {
|
|
151
|
+
// In JavaScript, just accessing the object keeps it alive for this call
|
|
152
|
+
// This is mostly a no-op but we touch the object to ensure it's not optimized away
|
|
153
|
+
if (obj !== null && obj !== undefined) {
|
|
154
|
+
// Touch the object to keep it alive
|
|
155
|
+
void obj;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../gs/runtime/runtime.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC;AACzB,MAAM,CAAC,MA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IACrG,CAAC;CACF;AAED,gCAAgC;AAChC,MAAM,OAAO,UAAU;IACO;IAA5B,YAA4B,KAAU;QAAV,UAAK,GAAL,KAAK,CAAK;IAAG,CAAC;IAE1C,KAAK;QACH,OAAO,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACF;AAED,0FAA0F;AAC1F,6FAA6F;AAC7F,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,SAAyC;IACjF,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;AAC9F,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,SAAS,CAAC,GAAQ;IAChC,wEAAwE;IACxE,mFAAmF;IACnF,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,oCAAoC;QACpC,KAAK,GAAG,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './slices.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/slices/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
/**
|
|
3
|
+
* All returns an iterator over index-value pairs in the slice.
|
|
4
|
+
* This is equivalent to Go's slices.All function.
|
|
5
|
+
* @param s The slice to iterate over
|
|
6
|
+
* @returns An iterator function that yields index-value pairs
|
|
7
|
+
*/
|
|
8
|
+
export declare function All<T>(s: $.Slice<T>): (yieldFunc: (index: number, value: T) => boolean) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// TypeScript implementation of Go's slices package
|
|
2
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
3
|
+
/**
|
|
4
|
+
* All returns an iterator over index-value pairs in the slice.
|
|
5
|
+
* This is equivalent to Go's slices.All function.
|
|
6
|
+
* @param s The slice to iterate over
|
|
7
|
+
* @returns An iterator function that yields index-value pairs
|
|
8
|
+
*/
|
|
9
|
+
export function All(s) {
|
|
10
|
+
return function (_yield) {
|
|
11
|
+
const length = $.len(s);
|
|
12
|
+
for (let i = 0; i < length; i++) {
|
|
13
|
+
const value = s[i]; // Use proper indexing to avoid type issues
|
|
14
|
+
if (!_yield(i, value)) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=slices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slices.js","sourceRoot":"","sources":["../../../gs/slices/slices.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAI,CAAa;IAClC,OAAO,UAAS,MAA4C;QAC1D,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,KAAK,GAAI,CAAS,CAAC,CAAC,CAAM,CAAC,CAAC,2CAA2C;YAC7E,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;gBACtB,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './time.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/time/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|