goscript 0.0.24 → 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 +1 -1
- package/cmd/goscript/cmd_compile.go +17 -1
- package/compiler/analysis.go +1 -1
- package/compiler/builtin_test.go +2 -14
- package/compiler/compiler.go +231 -11
- package/compiler/decl.go +7 -1
- package/compiler/expr-call.go +212 -2
- package/compiler/expr.go +46 -2
- package/compiler/field.go +4 -4
- package/compiler/stmt-range.go +204 -1
- package/compiler/type.go +47 -4
- package/dist/gs/builtin/builtin.d.ts +9 -0
- package/dist/gs/builtin/builtin.js +9 -0
- package/dist/gs/builtin/builtin.js.map +1 -1
- package/dist/gs/builtin/channel.d.ts +193 -0
- package/dist/gs/builtin/channel.js.map +1 -1
- package/dist/gs/builtin/defer.d.ts +38 -0
- package/dist/gs/builtin/defer.js.map +1 -1
- 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.map +1 -1
- package/dist/gs/builtin/map.d.ts +33 -0
- package/dist/gs/builtin/map.js.map +1 -1
- package/dist/gs/builtin/slice.d.ts +173 -0
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/builtin/type.d.ts +203 -0
- package/dist/gs/builtin/type.js +1 -2
- package/dist/gs/builtin/type.js.map +1 -1
- package/dist/gs/builtin/varRef.d.ts +14 -0
- package/dist/gs/builtin/varRef.js.map +1 -1
- 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 +287 -37
- package/dist/gs/context/context.js.map +1 -1
- package/dist/gs/context/index.d.ts +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/runtime.d.ts +41 -0
- package/dist/gs/runtime/runtime.js.map +1 -1
- 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/time.d.ts +57 -0
- package/dist/gs/time/time.js +103 -10
- package/dist/gs/time/time.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,55 +1,305 @@
|
|
|
1
1
|
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
canceled = false;
|
|
2
|
+
export const Canceled = new Error("context canceled");
|
|
3
|
+
Canceled.name = "CanceledError";
|
|
4
|
+
export class DeadlineExceededError extends Error {
|
|
6
5
|
constructor() {
|
|
7
|
-
|
|
6
|
+
super("context deadline exceeded");
|
|
7
|
+
this.name = "DeadlineExceededError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const DeadlineExceeded = new DeadlineExceededError();
|
|
11
|
+
// Base implementation for all contexts
|
|
12
|
+
class baseContext {
|
|
13
|
+
}
|
|
14
|
+
// Background/TODO context that is never canceled
|
|
15
|
+
class backgroundContext extends baseContext {
|
|
16
|
+
static neverClosedChannel = $.makeChannel(0, {}, 'both');
|
|
17
|
+
static getNeverClosedChannel() {
|
|
18
|
+
return backgroundContext.neverClosedChannel;
|
|
19
|
+
}
|
|
20
|
+
Deadline() {
|
|
21
|
+
return [null, false];
|
|
22
|
+
}
|
|
23
|
+
Done() {
|
|
24
|
+
return backgroundContext.neverClosedChannel;
|
|
25
|
+
}
|
|
26
|
+
Err() {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
Value(key) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Value context wraps a parent and adds a key-value pair
|
|
34
|
+
class valueContext extends baseContext {
|
|
35
|
+
parent;
|
|
36
|
+
key;
|
|
37
|
+
val;
|
|
38
|
+
constructor(parent, key, val) {
|
|
39
|
+
super();
|
|
40
|
+
this.parent = parent;
|
|
41
|
+
this.key = key;
|
|
42
|
+
this.val = val;
|
|
43
|
+
}
|
|
44
|
+
getParent() {
|
|
45
|
+
return this.parent;
|
|
46
|
+
}
|
|
47
|
+
Deadline() {
|
|
48
|
+
return this.parent.Deadline();
|
|
49
|
+
}
|
|
50
|
+
Done() {
|
|
51
|
+
return this.parent.Done();
|
|
52
|
+
}
|
|
53
|
+
Err() {
|
|
54
|
+
return this.parent.Err();
|
|
55
|
+
}
|
|
56
|
+
Value(key) {
|
|
57
|
+
if (this.key === key) {
|
|
58
|
+
return this.val;
|
|
59
|
+
}
|
|
60
|
+
return this.parent.Value(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Cancel context that can be canceled
|
|
64
|
+
class cancelContext extends baseContext {
|
|
65
|
+
doneChannel;
|
|
66
|
+
err = null;
|
|
67
|
+
cause = null;
|
|
68
|
+
children = new Set();
|
|
69
|
+
parent;
|
|
70
|
+
parentCancelCtx = null;
|
|
71
|
+
removeFromParent = null;
|
|
72
|
+
constructor(parent) {
|
|
73
|
+
super();
|
|
74
|
+
this.parent = parent;
|
|
8
75
|
this.doneChannel = $.makeChannel(0, {}, 'both');
|
|
9
76
|
}
|
|
10
|
-
|
|
77
|
+
Deadline() {
|
|
78
|
+
return this.parent.Deadline();
|
|
79
|
+
}
|
|
11
80
|
Done() {
|
|
12
81
|
return this.doneChannel;
|
|
13
82
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
83
|
+
Err() {
|
|
84
|
+
return this.err;
|
|
85
|
+
}
|
|
86
|
+
Value(key) {
|
|
87
|
+
return this.parent.Value(key);
|
|
88
|
+
}
|
|
89
|
+
getCause() {
|
|
90
|
+
if (this.cause !== null) {
|
|
91
|
+
return this.cause;
|
|
92
|
+
}
|
|
93
|
+
return this.err;
|
|
94
|
+
}
|
|
95
|
+
cancel(removeFromParent, err, cause) {
|
|
96
|
+
if (this.err !== null) {
|
|
97
|
+
return; // Already canceled
|
|
98
|
+
}
|
|
99
|
+
this.err = err;
|
|
100
|
+
this.cause = cause;
|
|
101
|
+
this.doneChannel.close();
|
|
102
|
+
// Cancel all children
|
|
103
|
+
for (const child of this.children) {
|
|
104
|
+
child.cancel(false, err, cause);
|
|
105
|
+
}
|
|
106
|
+
this.children.clear();
|
|
107
|
+
// Remove from parent's children if requested
|
|
108
|
+
if (removeFromParent && this.removeFromParent) {
|
|
109
|
+
this.removeFromParent();
|
|
110
|
+
this.removeFromParent = null;
|
|
21
111
|
}
|
|
22
112
|
}
|
|
23
|
-
|
|
24
|
-
|
|
113
|
+
propagateCancel() {
|
|
114
|
+
// Find parent cancelContext if any
|
|
115
|
+
let parent = this.parent;
|
|
116
|
+
while (parent instanceof valueContext) {
|
|
117
|
+
parent = parent.getParent();
|
|
118
|
+
}
|
|
119
|
+
if (parent instanceof cancelContext) {
|
|
120
|
+
// Parent is a cancel context, register as child
|
|
121
|
+
this.parentCancelCtx = parent;
|
|
122
|
+
if (parent.err !== null) {
|
|
123
|
+
// Parent already canceled
|
|
124
|
+
this.cancel(false, parent.err, parent.cause);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
parent.children.add(this);
|
|
128
|
+
this.removeFromParent = () => {
|
|
129
|
+
parent.children.delete(this);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Watch parent's Done channel
|
|
135
|
+
this.watchParentDone();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
watchParentDone() {
|
|
139
|
+
const parentDone = this.parent.Done();
|
|
140
|
+
(async () => {
|
|
141
|
+
try {
|
|
142
|
+
await parentDone.receive();
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Channel closed
|
|
146
|
+
}
|
|
147
|
+
// Parent is done, cancel this context
|
|
148
|
+
const parentErr = this.parent.Err();
|
|
149
|
+
if (parentErr && this.err === null) {
|
|
150
|
+
this.cancel(false, parentErr, null);
|
|
151
|
+
}
|
|
152
|
+
})();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Timer context with deadline
|
|
156
|
+
class timerContext extends cancelContext {
|
|
157
|
+
deadline;
|
|
158
|
+
timer;
|
|
159
|
+
constructor(parent, deadline) {
|
|
160
|
+
super(parent);
|
|
161
|
+
this.deadline = deadline;
|
|
162
|
+
}
|
|
163
|
+
Deadline() {
|
|
164
|
+
return [this.deadline, true];
|
|
165
|
+
}
|
|
166
|
+
startTimer() {
|
|
167
|
+
const now = Date.now();
|
|
168
|
+
const duration = this.deadline.getTime() - now;
|
|
169
|
+
if (duration <= 0) {
|
|
170
|
+
// Already expired
|
|
171
|
+
this.cancel(true, DeadlineExceeded, null);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.timer = setTimeout(() => {
|
|
175
|
+
this.cancel(true, DeadlineExceeded, null);
|
|
176
|
+
}, duration);
|
|
177
|
+
}
|
|
178
|
+
cancel(removeFromParent, err, cause) {
|
|
179
|
+
super.cancel(removeFromParent, err, cause);
|
|
180
|
+
if (this.timer) {
|
|
181
|
+
clearTimeout(this.timer);
|
|
182
|
+
this.timer = null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Without cancel context - inherits values but not cancellation
|
|
187
|
+
class withoutCancelContext extends baseContext {
|
|
188
|
+
parent;
|
|
189
|
+
constructor(parent) {
|
|
190
|
+
super();
|
|
191
|
+
this.parent = parent;
|
|
192
|
+
}
|
|
193
|
+
Deadline() {
|
|
194
|
+
return [null, false];
|
|
195
|
+
}
|
|
196
|
+
Done() {
|
|
197
|
+
return backgroundContext.getNeverClosedChannel();
|
|
198
|
+
}
|
|
199
|
+
Err() {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
Value(key) {
|
|
203
|
+
return this.parent.Value(key);
|
|
25
204
|
}
|
|
26
205
|
}
|
|
27
|
-
//
|
|
206
|
+
// Singleton contexts
|
|
207
|
+
const background = new backgroundContext();
|
|
208
|
+
const todo = new backgroundContext();
|
|
209
|
+
// Background returns a non-nil, empty Context that is never canceled
|
|
28
210
|
export function Background() {
|
|
29
|
-
return
|
|
211
|
+
return background;
|
|
212
|
+
}
|
|
213
|
+
// TODO returns a non-nil, empty Context
|
|
214
|
+
export function TODO() {
|
|
215
|
+
return todo;
|
|
30
216
|
}
|
|
31
217
|
// WithCancel returns a copy of parent with a new Done channel
|
|
32
|
-
// The returned context's Done channel is closed when the returned cancel function
|
|
33
|
-
// is called or when the parent context's Done channel is closed, whichever happens first
|
|
34
218
|
export function WithCancel(parent) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
219
|
+
const ctx = new cancelContext(parent);
|
|
220
|
+
ctx.propagateCancel();
|
|
221
|
+
return [ctx, () => {
|
|
222
|
+
ctx.cancel(true, Canceled, null);
|
|
223
|
+
}];
|
|
224
|
+
}
|
|
225
|
+
// WithCancelCause returns a copy of parent with a new Done channel and cause recording
|
|
226
|
+
export function WithCancelCause(parent) {
|
|
227
|
+
const ctx = new cancelContext(parent);
|
|
228
|
+
ctx.propagateCancel();
|
|
229
|
+
return [ctx, (cause) => {
|
|
230
|
+
ctx.cancel(true, Canceled, cause);
|
|
231
|
+
}];
|
|
232
|
+
}
|
|
233
|
+
// WithDeadline returns a copy of parent with the deadline adjusted to be no later than d
|
|
234
|
+
export function WithDeadline(parent, d) {
|
|
235
|
+
return WithDeadlineCause(parent, d, null);
|
|
236
|
+
}
|
|
237
|
+
// WithDeadlineCause is like WithDeadline but also sets the cause
|
|
238
|
+
export function WithDeadlineCause(parent, d, cause) {
|
|
239
|
+
// Check if parent deadline is already earlier
|
|
240
|
+
const [parentDeadline, ok] = parent.Deadline();
|
|
241
|
+
if (ok && parentDeadline && parentDeadline <= d) {
|
|
242
|
+
// Parent deadline is already sooner
|
|
243
|
+
return WithCancel(parent);
|
|
244
|
+
}
|
|
245
|
+
const ctx = new timerContext(parent, d);
|
|
246
|
+
ctx.propagateCancel();
|
|
247
|
+
ctx.startTimer();
|
|
248
|
+
return [ctx, () => {
|
|
249
|
+
ctx.cancel(true, Canceled, cause);
|
|
250
|
+
}];
|
|
251
|
+
}
|
|
252
|
+
// WithTimeout returns WithDeadline(parent, Date.now() + timeout)
|
|
253
|
+
export function WithTimeout(parent, timeout) {
|
|
254
|
+
return WithDeadline(parent, new Date(Date.now() + timeout));
|
|
255
|
+
}
|
|
256
|
+
// WithTimeoutCause is like WithTimeout but also sets the cause
|
|
257
|
+
export function WithTimeoutCause(parent, timeout, cause) {
|
|
258
|
+
return WithDeadlineCause(parent, new Date(Date.now() + timeout), cause);
|
|
259
|
+
}
|
|
260
|
+
// WithValue returns a copy of parent with the value associated with key
|
|
261
|
+
export function WithValue(parent, key, val) {
|
|
262
|
+
return new valueContext(parent, key, val);
|
|
263
|
+
}
|
|
264
|
+
// WithoutCancel returns a context that inherits values but not cancellation
|
|
265
|
+
export function WithoutCancel(parent) {
|
|
266
|
+
return new withoutCancelContext(parent);
|
|
267
|
+
}
|
|
268
|
+
// Cause returns the underlying cause of the context's cancellation
|
|
269
|
+
export function Cause(ctx) {
|
|
270
|
+
let c = ctx;
|
|
271
|
+
// Unwrap value contexts
|
|
272
|
+
while (c instanceof valueContext) {
|
|
273
|
+
c = c.getParent();
|
|
274
|
+
}
|
|
275
|
+
if (c instanceof cancelContext) {
|
|
276
|
+
return c.getCause();
|
|
52
277
|
}
|
|
53
|
-
return
|
|
278
|
+
return c.Err();
|
|
279
|
+
}
|
|
280
|
+
// AfterFunc runs f in a separate goroutine after ctx is done
|
|
281
|
+
export function AfterFunc(ctx, f) {
|
|
282
|
+
let stopped = false;
|
|
283
|
+
let done = false;
|
|
284
|
+
const promise = (async () => {
|
|
285
|
+
try {
|
|
286
|
+
await ctx.Done().receive();
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
// Channel closed
|
|
290
|
+
}
|
|
291
|
+
if (!stopped) {
|
|
292
|
+
done = true;
|
|
293
|
+
// Run in next tick to simulate goroutine
|
|
294
|
+
setImmediate(f);
|
|
295
|
+
}
|
|
296
|
+
})();
|
|
297
|
+
return () => {
|
|
298
|
+
if (!done) {
|
|
299
|
+
stopped = true;
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
};
|
|
54
304
|
}
|
|
55
305
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../gs/context/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../gs/context/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAGlD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;A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,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,GAAG,IAAI,CAAC;YACZ,yCAAyC;YACzC,YAAY,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './context.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Architecture constants for JavaScript/WebAssembly target
|
|
2
|
+
// This replaces the auto-generated version with appropriate values for JS
|
|
3
|
+
// Pointer size in bytes (64-bit in modern JavaScript environments)
|
|
4
|
+
export const PtrSize = 8;
|
|
5
|
+
// JavaScript is little-endian
|
|
6
|
+
export const BigEndian = false;
|
|
7
|
+
// Architecture family
|
|
8
|
+
export const ArchFamily = "wasm";
|
|
9
|
+
// Other common architecture constants
|
|
10
|
+
export const Int64Align = 8;
|
|
11
|
+
export const MinFrameSize = 0;
|
|
12
|
+
// CPU cache line size (not really applicable in JS, but some code might reference it)
|
|
13
|
+
export const CacheLineSize = 64;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/internal/goarch/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,0EAA0E;AAE1E,mEAAmE;AACnE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AAEzB,8BAA8B;AAC9B,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAE/B,sBAAsB;AACtB,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,sCAAsC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './iter.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/iter/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type Seq<V> = (_yield: (value: V) => boolean) => void;
|
|
2
|
+
export type Seq2<K, V> = (_yield: (key: K, value: V) => boolean) => void;
|
|
3
|
+
export declare function Pull<V>(seq: Seq<V>): [() => [V | undefined, boolean], () => void];
|
|
4
|
+
export declare function Pull2<K, V>(seq: Seq2<K, V>): [() => [K | undefined, V | undefined, boolean], () => void];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// TypeScript implementation of Go's iter package
|
|
2
|
+
// This provides iterator types and functions
|
|
3
|
+
// Pull converts the "push-style" iterator sequence seq into a "pull-style" iterator
|
|
4
|
+
// Returns a function that returns the next value and a boolean indicating if iteration should continue
|
|
5
|
+
export function Pull(seq) {
|
|
6
|
+
let done = false;
|
|
7
|
+
let nextValue;
|
|
8
|
+
let hasNext = false;
|
|
9
|
+
const iterator = seq(function (value) {
|
|
10
|
+
nextValue = value;
|
|
11
|
+
hasNext = true;
|
|
12
|
+
return false; // Stop iteration after getting one value
|
|
13
|
+
});
|
|
14
|
+
const next = () => {
|
|
15
|
+
if (done) {
|
|
16
|
+
return [undefined, false];
|
|
17
|
+
}
|
|
18
|
+
if (hasNext) {
|
|
19
|
+
const value = nextValue;
|
|
20
|
+
hasNext = false;
|
|
21
|
+
nextValue = undefined;
|
|
22
|
+
return [value, true];
|
|
23
|
+
}
|
|
24
|
+
// Try to get next value
|
|
25
|
+
seq(function (value) {
|
|
26
|
+
nextValue = value;
|
|
27
|
+
hasNext = true;
|
|
28
|
+
return false; // Stop after getting one value
|
|
29
|
+
});
|
|
30
|
+
if (hasNext) {
|
|
31
|
+
const value = nextValue;
|
|
32
|
+
hasNext = false;
|
|
33
|
+
nextValue = undefined;
|
|
34
|
+
return [value, true];
|
|
35
|
+
}
|
|
36
|
+
done = true;
|
|
37
|
+
return [undefined, false];
|
|
38
|
+
};
|
|
39
|
+
const stop = () => {
|
|
40
|
+
done = true;
|
|
41
|
+
hasNext = false;
|
|
42
|
+
nextValue = undefined;
|
|
43
|
+
};
|
|
44
|
+
return [next, stop];
|
|
45
|
+
}
|
|
46
|
+
// Pull2 converts the "push-style" iterator sequence seq into a "pull-style" iterator
|
|
47
|
+
// Returns a function that returns the next key-value pair and a boolean indicating if iteration should continue
|
|
48
|
+
export function Pull2(seq) {
|
|
49
|
+
let done = false;
|
|
50
|
+
let nextKey;
|
|
51
|
+
let nextValue;
|
|
52
|
+
let hasNext = false;
|
|
53
|
+
const next = () => {
|
|
54
|
+
if (done) {
|
|
55
|
+
return [undefined, undefined, false];
|
|
56
|
+
}
|
|
57
|
+
if (hasNext) {
|
|
58
|
+
const key = nextKey;
|
|
59
|
+
const value = nextValue;
|
|
60
|
+
hasNext = false;
|
|
61
|
+
nextKey = undefined;
|
|
62
|
+
nextValue = undefined;
|
|
63
|
+
return [key, value, true];
|
|
64
|
+
}
|
|
65
|
+
// Try to get next value
|
|
66
|
+
seq(function (key, value) {
|
|
67
|
+
nextKey = key;
|
|
68
|
+
nextValue = value;
|
|
69
|
+
hasNext = true;
|
|
70
|
+
return false; // Stop after getting one value
|
|
71
|
+
});
|
|
72
|
+
if (hasNext) {
|
|
73
|
+
const key = nextKey;
|
|
74
|
+
const value = nextValue;
|
|
75
|
+
hasNext = false;
|
|
76
|
+
nextKey = undefined;
|
|
77
|
+
nextValue = undefined;
|
|
78
|
+
return [key, value, true];
|
|
79
|
+
}
|
|
80
|
+
done = true;
|
|
81
|
+
return [undefined, undefined, false];
|
|
82
|
+
};
|
|
83
|
+
const stop = () => {
|
|
84
|
+
done = true;
|
|
85
|
+
hasNext = false;
|
|
86
|
+
nextKey = undefined;
|
|
87
|
+
nextValue = undefined;
|
|
88
|
+
};
|
|
89
|
+
return [next, stop];
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=iter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iter.js","sourceRoot":"","sources":["../../../gs/iter/iter.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,6CAA6C;AAQ7C,oFAAoF;AACpF,uGAAuG;AACvG,MAAM,UAAU,IAAI,CAAI,GAAW;IACjC,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,SAAwB,CAAC;IAC7B,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAS,KAAQ;QACpC,SAAS,GAAG,KAAK,CAAC;QAClB,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,yCAAyC;IACzD,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,GAA6B,EAAE;QAC1C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,SAAS,CAAC;YACxB,OAAO,GAAG,KAAK,CAAC;YAChB,SAAS,GAAG,SAAS,CAAC;YACtB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC;QAED,wBAAwB;QACxB,GAAG,CAAC,UAAS,KAAQ;YACnB,SAAS,GAAG,KAAK,CAAC;YAClB,OAAO,GAAG,IAA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,CAAC;YACd,SAAS,GAAG,KAAK,CAAC;YAClB,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,KAAK,CAAC,CAAC,+BAA+B;QAC/C,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,GAAG,GAAG,OAAO,CAAC;YACpB,MAAM,KAAK,GAAG,SAAS,CAAC;YACxB,OAAO,GAAG,KAAK,CAAC;YAChB,OAAO,GAAG,SAAS,CAAC;YACpB,SAAS,GAAG,SAAS,CAAC;YACtB,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,GAAG,IAAI,CAAC;QACZ,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,GAAG,IAAI,CAAC;QACZ,OAAO,GAAG,KAAK,CAAC;QAChB,OAAO,GAAG,SAAS,CAAC;QACpB,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -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];
|