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.
Files changed (94) hide show
  1. package/README.md +2 -2
  2. package/cmd/goscript/cmd_compile.go +18 -2
  3. package/compiler/analysis.go +74 -132
  4. package/compiler/analysis_test.go +220 -0
  5. package/compiler/assignment.go +37 -43
  6. package/compiler/builtin_test.go +90 -0
  7. package/compiler/compiler.go +307 -22
  8. package/compiler/composite-lit.go +108 -43
  9. package/compiler/config.go +7 -3
  10. package/compiler/config_test.go +6 -33
  11. package/compiler/decl.go +7 -1
  12. package/compiler/expr-call.go +212 -2
  13. package/compiler/expr-selector.go +66 -41
  14. package/compiler/expr-star.go +57 -65
  15. package/compiler/expr-type.go +1 -1
  16. package/compiler/expr-value.go +1 -1
  17. package/compiler/expr.go +125 -20
  18. package/compiler/field.go +4 -4
  19. package/compiler/primitive.go +11 -10
  20. package/compiler/spec-struct.go +3 -3
  21. package/compiler/spec-value.go +75 -29
  22. package/compiler/spec.go +9 -3
  23. package/compiler/stmt-assign.go +36 -2
  24. package/compiler/stmt-for.go +11 -0
  25. package/compiler/stmt-range.go +314 -1
  26. package/compiler/stmt.go +52 -0
  27. package/compiler/type.go +83 -15
  28. package/dist/gs/builtin/builtin.d.ts +9 -0
  29. package/dist/gs/builtin/builtin.js +46 -0
  30. package/dist/gs/builtin/builtin.js.map +1 -0
  31. package/dist/gs/builtin/channel.d.ts +193 -0
  32. package/dist/gs/builtin/channel.js +471 -0
  33. package/dist/gs/builtin/channel.js.map +1 -0
  34. package/dist/gs/builtin/defer.d.ts +38 -0
  35. package/dist/gs/builtin/defer.js +54 -0
  36. package/dist/gs/builtin/defer.js.map +1 -0
  37. package/dist/gs/builtin/index.d.ts +1 -0
  38. package/dist/gs/builtin/index.js +2 -0
  39. package/dist/gs/builtin/index.js.map +1 -0
  40. package/dist/gs/builtin/io.d.ts +16 -0
  41. package/dist/gs/builtin/io.js +15 -0
  42. package/dist/gs/builtin/io.js.map +1 -0
  43. package/dist/gs/builtin/map.d.ts +33 -0
  44. package/dist/gs/builtin/map.js +44 -0
  45. package/dist/gs/builtin/map.js.map +1 -0
  46. package/dist/gs/builtin/slice.d.ts +173 -0
  47. package/dist/gs/builtin/slice.js +799 -0
  48. package/dist/gs/builtin/slice.js.map +1 -0
  49. package/dist/gs/builtin/type.d.ts +203 -0
  50. package/dist/gs/builtin/type.js +744 -0
  51. package/dist/gs/builtin/type.js.map +1 -0
  52. package/dist/gs/builtin/varRef.d.ts +14 -0
  53. package/dist/gs/builtin/varRef.js +14 -0
  54. package/dist/gs/builtin/varRef.js.map +1 -0
  55. package/dist/gs/cmp/index.d.ts +4 -0
  56. package/dist/gs/cmp/index.js +27 -0
  57. package/dist/gs/cmp/index.js.map +1 -0
  58. package/dist/gs/context/context.d.ts +26 -0
  59. package/dist/gs/context/context.js +305 -0
  60. package/dist/gs/context/context.js.map +1 -0
  61. package/dist/gs/context/index.d.ts +1 -0
  62. package/dist/gs/context/index.js +2 -0
  63. package/dist/gs/context/index.js.map +1 -0
  64. package/dist/gs/internal/goarch/index.d.ts +6 -0
  65. package/dist/gs/internal/goarch/index.js +14 -0
  66. package/dist/gs/internal/goarch/index.js.map +1 -0
  67. package/dist/gs/iter/index.d.ts +1 -0
  68. package/dist/gs/iter/index.js +2 -0
  69. package/dist/gs/iter/index.js.map +1 -0
  70. package/dist/gs/iter/iter.d.ts +4 -0
  71. package/dist/gs/iter/iter.js +91 -0
  72. package/dist/gs/iter/iter.js.map +1 -0
  73. package/dist/gs/math/bits/index.d.ts +47 -0
  74. package/dist/gs/math/bits/index.js +298 -0
  75. package/dist/gs/math/bits/index.js.map +1 -0
  76. package/dist/gs/runtime/index.d.ts +1 -0
  77. package/dist/gs/runtime/index.js +2 -0
  78. package/dist/gs/runtime/index.js.map +1 -0
  79. package/dist/gs/runtime/runtime.d.ts +41 -0
  80. package/dist/gs/runtime/runtime.js +158 -0
  81. package/dist/gs/runtime/runtime.js.map +1 -0
  82. package/dist/gs/slices/index.d.ts +1 -0
  83. package/dist/gs/slices/index.js +2 -0
  84. package/dist/gs/slices/index.js.map +1 -0
  85. package/dist/gs/slices/slices.d.ts +8 -0
  86. package/dist/gs/slices/slices.js +20 -0
  87. package/dist/gs/slices/slices.js.map +1 -0
  88. package/dist/gs/time/index.d.ts +1 -0
  89. package/dist/gs/time/index.js +2 -0
  90. package/dist/gs/time/index.js.map +1 -0
  91. package/dist/gs/time/time.d.ts +57 -0
  92. package/dist/gs/time/time.js +208 -0
  93. package/dist/gs/time/time.js.map +1 -0
  94. package/package.json +3 -2
@@ -0,0 +1,471 @@
1
+ /**
2
+ * Helper for 'select' statements. Takes an array of select cases
3
+ * and resolves when one of them completes, following Go's select rules.
4
+ *
5
+ * @param cases Array of SelectCase objects
6
+ * @param hasDefault Whether there is a default case
7
+ * @returns A promise that resolves with the result of the selected case
8
+ */
9
+ export async function selectStatement(cases, hasDefault = false) {
10
+ if (cases.length === 0 && !hasDefault) {
11
+ // Go spec: If there are no cases, the select statement blocks forever.
12
+ // Emulate blocking forever with a promise that never resolves.
13
+ return new Promise(() => { }); // Promise never resolves
14
+ }
15
+ // 1. Check for ready (non-blocking) operations
16
+ const readyCases = [];
17
+ for (const caseObj of cases) {
18
+ if (caseObj.id === -1) {
19
+ // Skip default case in this check
20
+ continue;
21
+ }
22
+ // Skip nil channels - they are never ready in Go
23
+ if (caseObj.channel === null) {
24
+ continue;
25
+ }
26
+ if (caseObj.channel) {
27
+ if (caseObj.isSend && caseObj.channel.canSendNonBlocking()) {
28
+ readyCases.push(caseObj);
29
+ }
30
+ else if (!caseObj.isSend && caseObj.channel.canReceiveNonBlocking()) {
31
+ readyCases.push(caseObj);
32
+ }
33
+ }
34
+ }
35
+ if (readyCases.length > 0) {
36
+ // If one or more cases are ready, choose one pseudo-randomly
37
+ const selectedCase = readyCases[Math.floor(Math.random() * readyCases.length)];
38
+ // Execute the selected operation and its onSelected handler
39
+ // Add check for channel existence
40
+ if (selectedCase.channel) {
41
+ if (selectedCase.isSend) {
42
+ const result = await selectedCase.channel.selectSend(selectedCase.value, selectedCase.id);
43
+ if (selectedCase.onSelected) {
44
+ await selectedCase.onSelected(result); // Await the handler
45
+ }
46
+ }
47
+ else {
48
+ const result = await selectedCase.channel.selectReceive(selectedCase.id);
49
+ if (selectedCase.onSelected) {
50
+ await selectedCase.onSelected(result); // Await the handler
51
+ }
52
+ }
53
+ }
54
+ else {
55
+ // This case should ideally not happen if channel is required for non-default cases
56
+ console.error('Selected case without a channel:', selectedCase);
57
+ }
58
+ return; // Return after executing a ready case
59
+ }
60
+ // 2. If no operations are ready and there's a default case, select default
61
+ if (hasDefault) {
62
+ // Find the default case (it will have id -1)
63
+ const defaultCase = cases.find((c) => c.id === -1);
64
+ if (defaultCase && defaultCase.onSelected) {
65
+ // Execute the onSelected handler for the default case
66
+ await defaultCase.onSelected({
67
+ value: undefined,
68
+ ok: false,
69
+ id: -1,
70
+ }); // Await the handler
71
+ }
72
+ return; // Return after executing the default case
73
+ }
74
+ // 3. If no operations are ready and no default case, block until one is ready
75
+ // Use Promise.race on the blocking promises
76
+ const blockingPromises = cases
77
+ .filter((c) => c.id !== -1) // Exclude default case
78
+ .filter((c) => c.channel !== null) // Exclude nil channels (they would block forever)
79
+ .map((caseObj) => {
80
+ // At this point caseObj.channel is guaranteed to be non-null
81
+ if (caseObj.isSend) {
82
+ return caseObj.channel.selectSend(caseObj.value, caseObj.id);
83
+ }
84
+ else {
85
+ return caseObj.channel.selectReceive(caseObj.id);
86
+ }
87
+ });
88
+ // If all non-default cases have nil channels, we effectively block forever
89
+ if (blockingPromises.length === 0) {
90
+ // No valid channels to operate on, block forever (unless there's a default)
91
+ return new Promise(() => { }); // Promise never resolves
92
+ }
93
+ const result = await Promise.race(blockingPromises);
94
+ // Execute onSelected handler for the selected case
95
+ const selectedCase = cases.find((c) => c.id === result.id);
96
+ if (selectedCase && selectedCase.onSelected) {
97
+ await selectedCase.onSelected(result); // Await the handler
98
+ }
99
+ // No explicit return needed here, as the function will implicitly return after the await
100
+ }
101
+ /**
102
+ * Helper function for channel send operations that handles nil channels correctly.
103
+ * In Go, sending to a nil channel blocks forever.
104
+ * @param channel The channel to send to (can be null)
105
+ * @param value The value to send
106
+ * @returns Promise that never resolves if channel is null, otherwise delegates to channel.send()
107
+ */
108
+ export async function chanSend(channel, value) {
109
+ if (channel === null) {
110
+ // In Go, sending to a nil channel blocks forever
111
+ return new Promise(() => { }); // Promise that never resolves
112
+ }
113
+ return channel.send(value);
114
+ }
115
+ /**
116
+ * Helper function for channel receive operations that handles nil channels correctly.
117
+ * In Go, receiving from a nil channel blocks forever.
118
+ * @param channel The channel to receive from (can be null)
119
+ * @returns Promise that never resolves if channel is null, otherwise delegates to channel.receive()
120
+ */
121
+ export async function chanRecv(channel) {
122
+ if (channel === null) {
123
+ // In Go, receiving from a nil channel blocks forever
124
+ return new Promise(() => { }); // Promise that never resolves
125
+ }
126
+ return channel.receive();
127
+ }
128
+ /**
129
+ * Helper function for channel receive operations with ok value that handles nil channels correctly.
130
+ * In Go, receiving from a nil channel blocks forever.
131
+ * @param channel The channel to receive from (can be null)
132
+ * @returns Promise that never resolves if channel is null, otherwise delegates to channel.receiveWithOk()
133
+ */
134
+ export async function chanRecvWithOk(channel) {
135
+ if (channel === null) {
136
+ // In Go, receiving from a nil channel blocks forever
137
+ return new Promise(() => { }); // Promise that never resolves
138
+ }
139
+ return channel.receiveWithOk();
140
+ }
141
+ /**
142
+ * Creates a new channel with the specified buffer size and zero value.
143
+ * @param bufferSize The size of the channel buffer. If 0, creates an unbuffered channel.
144
+ * @param zeroValue The zero value for the channel's element type.
145
+ * @param direction Optional direction for the channel. Default is 'both' (bidirectional).
146
+ * @returns A new channel instance or channel reference.
147
+ */
148
+ export const makeChannel = (bufferSize, zeroValue, direction = 'both') => {
149
+ const channel = new BufferedChannel(bufferSize, zeroValue);
150
+ // Wrap the channel with the appropriate ChannelRef based on direction
151
+ if (direction === 'send') {
152
+ return new SendOnlyChannelRef(channel);
153
+ }
154
+ else if (direction === 'receive') {
155
+ return new ReceiveOnlyChannelRef(channel);
156
+ }
157
+ else {
158
+ return channel;
159
+ }
160
+ };
161
+ // A simple implementation of buffered channels
162
+ class BufferedChannel {
163
+ buffer = [];
164
+ closed = false;
165
+ capacity;
166
+ zeroValue; // Made public for access by ChannelRef or for type inference
167
+ // Senders queue: stores { value, resolve for send, reject for send }
168
+ senders = [];
169
+ // Receivers queue for receive(): stores { resolve for receive, reject for receive }
170
+ receivers = [];
171
+ // Receivers queue for receiveWithOk(): stores { resolve for receiveWithOk }
172
+ receiversWithOk = [];
173
+ constructor(capacity, zeroValue) {
174
+ if (capacity < 0) {
175
+ throw new Error('Channel capacity cannot be negative');
176
+ }
177
+ this.capacity = capacity;
178
+ this.zeroValue = zeroValue;
179
+ }
180
+ async send(value) {
181
+ if (this.closed) {
182
+ throw new Error('send on closed channel');
183
+ }
184
+ // Attempt to hand off to a waiting receiver (rendezvous)
185
+ if (this.receivers.length > 0) {
186
+ const receiverTask = this.receivers.shift();
187
+ queueMicrotask(() => receiverTask.resolveReceive(value));
188
+ return;
189
+ }
190
+ if (this.receiversWithOk.length > 0) {
191
+ const receiverTask = this.receiversWithOk.shift();
192
+ queueMicrotask(() => receiverTask.resolveReceive({ value, ok: true }));
193
+ return;
194
+ }
195
+ // If no waiting receivers, try to buffer if space is available
196
+ if (this.buffer.length < this.capacity) {
197
+ this.buffer.push(value);
198
+ return;
199
+ }
200
+ // Buffer is full (or capacity is 0 and no receivers are waiting). Sender must block.
201
+ return new Promise((resolve, reject) => {
202
+ this.senders.push({ value, resolveSend: resolve, rejectSend: reject });
203
+ });
204
+ }
205
+ async receive() {
206
+ // Attempt to get from buffer first
207
+ if (this.buffer.length > 0) {
208
+ const value = this.buffer.shift();
209
+ // If a sender was waiting because the buffer was full, unblock it.
210
+ if (this.senders.length > 0) {
211
+ const senderTask = this.senders.shift();
212
+ this.buffer.push(senderTask.value); // Sender's value now goes into buffer
213
+ queueMicrotask(() => senderTask.resolveSend()); // Unblock sender
214
+ }
215
+ return value;
216
+ }
217
+ // Buffer is empty.
218
+ // If channel is closed (and buffer is empty), return zero value.
219
+ if (this.closed) {
220
+ return this.zeroValue;
221
+ }
222
+ // Buffer is empty, channel is open.
223
+ // Attempt to rendezvous with a waiting sender.
224
+ if (this.senders.length > 0) {
225
+ const senderTask = this.senders.shift();
226
+ queueMicrotask(() => senderTask.resolveSend()); // Unblock the sender
227
+ return senderTask.value; // Return the value from sender
228
+ }
229
+ // Buffer is empty, channel is open, no waiting senders. Receiver must block.
230
+ return new Promise((resolve, reject) => {
231
+ this.receivers.push({ resolveReceive: resolve, rejectReceive: reject });
232
+ });
233
+ }
234
+ async receiveWithOk() {
235
+ // Attempt to get from buffer first
236
+ if (this.buffer.length > 0) {
237
+ const value = this.buffer.shift();
238
+ if (this.senders.length > 0) {
239
+ const senderTask = this.senders.shift();
240
+ this.buffer.push(senderTask.value);
241
+ queueMicrotask(() => senderTask.resolveSend());
242
+ }
243
+ return { value, ok: true };
244
+ }
245
+ // Buffer is empty.
246
+ // Attempt to rendezvous with a waiting sender.
247
+ if (this.senders.length > 0) {
248
+ const senderTask = this.senders.shift();
249
+ queueMicrotask(() => senderTask.resolveSend());
250
+ return { value: senderTask.value, ok: true };
251
+ }
252
+ // Buffer is empty, no waiting senders.
253
+ // If channel is closed, return zero value with ok: false.
254
+ if (this.closed) {
255
+ return { value: this.zeroValue, ok: false };
256
+ }
257
+ // Buffer is empty, channel is open, no waiting senders. Receiver must block.
258
+ return new Promise((resolve) => {
259
+ this.receiversWithOk.push({ resolveReceive: resolve });
260
+ });
261
+ }
262
+ async selectReceive(id) {
263
+ if (this.buffer.length > 0) {
264
+ const value = this.buffer.shift();
265
+ if (this.senders.length > 0) {
266
+ const senderTask = this.senders.shift();
267
+ this.buffer.push(senderTask.value);
268
+ queueMicrotask(() => senderTask.resolveSend());
269
+ }
270
+ return { value, ok: true, id };
271
+ }
272
+ if (this.senders.length > 0) {
273
+ const senderTask = this.senders.shift();
274
+ queueMicrotask(() => senderTask.resolveSend());
275
+ return { value: senderTask.value, ok: true, id };
276
+ }
277
+ if (this.closed) {
278
+ return { value: this.zeroValue, ok: false, id };
279
+ }
280
+ return new Promise((resolve) => {
281
+ this.receiversWithOk.push({
282
+ resolveReceive: (result) => {
283
+ resolve({ ...result, id });
284
+ },
285
+ });
286
+ });
287
+ }
288
+ async selectSend(value, id) {
289
+ if (this.closed) {
290
+ // A select case sending on a closed channel panics in Go.
291
+ // This will cause Promise.race in selectStatement to reject.
292
+ throw new Error('send on closed channel');
293
+ }
294
+ if (this.receivers.length > 0) {
295
+ const receiverTask = this.receivers.shift();
296
+ queueMicrotask(() => receiverTask.resolveReceive(value));
297
+ return { value: true, ok: true, id };
298
+ }
299
+ if (this.receiversWithOk.length > 0) {
300
+ const receiverTask = this.receiversWithOk.shift();
301
+ queueMicrotask(() => receiverTask.resolveReceive({ value, ok: true }));
302
+ return { value: true, ok: true, id };
303
+ }
304
+ if (this.buffer.length < this.capacity) {
305
+ this.buffer.push(value);
306
+ return { value: true, ok: true, id };
307
+ }
308
+ return new Promise((resolve, reject) => {
309
+ this.senders.push({
310
+ value,
311
+ resolveSend: () => resolve({ value: true, ok: true, id }),
312
+ rejectSend: (e) => reject(e), // Propagate error if channel closes
313
+ });
314
+ });
315
+ }
316
+ close() {
317
+ if (this.closed) {
318
+ throw new Error('close of closed channel');
319
+ }
320
+ this.closed = true;
321
+ const sendersToNotify = [...this.senders]; // Shallow copy for iteration
322
+ this.senders = [];
323
+ for (const senderTask of sendersToNotify) {
324
+ queueMicrotask(() => senderTask.rejectSend(new Error('send on closed channel')));
325
+ }
326
+ const receiversToNotify = [...this.receivers];
327
+ this.receivers = [];
328
+ for (const receiverTask of receiversToNotify) {
329
+ queueMicrotask(() => receiverTask.resolveReceive(this.zeroValue));
330
+ }
331
+ const receiversWithOkToNotify = [...this.receiversWithOk];
332
+ this.receiversWithOk = [];
333
+ for (const receiverTask of receiversWithOkToNotify) {
334
+ queueMicrotask(() => receiverTask.resolveReceive({ value: this.zeroValue, ok: false }));
335
+ }
336
+ }
337
+ canReceiveNonBlocking() {
338
+ return this.buffer.length > 0 || this.senders.length > 0 || this.closed;
339
+ }
340
+ canSendNonBlocking() {
341
+ if (this.closed) {
342
+ return true; // Ready to panic
343
+ }
344
+ return (this.buffer.length < this.capacity ||
345
+ this.receivers.length > 0 ||
346
+ this.receiversWithOk.length > 0);
347
+ }
348
+ }
349
+ /**
350
+ * A bidirectional channel reference.
351
+ */
352
+ export class BidirectionalChannelRef {
353
+ channel;
354
+ direction = 'both';
355
+ constructor(channel) {
356
+ this.channel = channel;
357
+ }
358
+ // Delegate all methods to the underlying channel
359
+ send(value) {
360
+ return this.channel.send(value);
361
+ }
362
+ receive() {
363
+ return this.channel.receive();
364
+ }
365
+ receiveWithOk() {
366
+ return this.channel.receiveWithOk();
367
+ }
368
+ close() {
369
+ this.channel.close();
370
+ }
371
+ canSendNonBlocking() {
372
+ return this.channel.canSendNonBlocking();
373
+ }
374
+ canReceiveNonBlocking() {
375
+ return this.channel.canReceiveNonBlocking();
376
+ }
377
+ selectSend(value, id) {
378
+ return this.channel.selectSend(value, id);
379
+ }
380
+ selectReceive(id) {
381
+ return this.channel.selectReceive(id);
382
+ }
383
+ }
384
+ /**
385
+ * A send-only channel reference.
386
+ */
387
+ export class SendOnlyChannelRef {
388
+ channel;
389
+ direction = 'send';
390
+ constructor(channel) {
391
+ this.channel = channel;
392
+ }
393
+ // Allow send operations
394
+ send(value) {
395
+ return this.channel.send(value);
396
+ }
397
+ // Allow close operations
398
+ close() {
399
+ this.channel.close();
400
+ }
401
+ canSendNonBlocking() {
402
+ return this.channel.canSendNonBlocking();
403
+ }
404
+ selectSend(value, id) {
405
+ return this.channel.selectSend(value, id);
406
+ }
407
+ // Disallow receive operations
408
+ receive() {
409
+ throw new Error('Cannot receive from send-only channel');
410
+ }
411
+ receiveWithOk() {
412
+ throw new Error('Cannot receive from send-only channel');
413
+ }
414
+ canReceiveNonBlocking() {
415
+ return false;
416
+ }
417
+ selectReceive(id) {
418
+ throw new Error('Cannot receive from send-only channel');
419
+ }
420
+ }
421
+ /**
422
+ * A receive-only channel reference.
423
+ */
424
+ export class ReceiveOnlyChannelRef {
425
+ channel;
426
+ direction = 'receive';
427
+ constructor(channel) {
428
+ this.channel = channel;
429
+ }
430
+ // Allow receive operations
431
+ receive() {
432
+ return this.channel.receive();
433
+ }
434
+ receiveWithOk() {
435
+ return this.channel.receiveWithOk();
436
+ }
437
+ canReceiveNonBlocking() {
438
+ return this.channel.canReceiveNonBlocking();
439
+ }
440
+ selectReceive(id) {
441
+ return this.channel.selectReceive(id);
442
+ }
443
+ // Disallow send operations
444
+ send(value) {
445
+ throw new Error('Cannot send to receive-only channel');
446
+ }
447
+ // Disallow close operations
448
+ close() {
449
+ throw new Error('Cannot close receive-only channel');
450
+ }
451
+ canSendNonBlocking() {
452
+ return false;
453
+ }
454
+ selectSend(value, id) {
455
+ throw new Error('Cannot send to receive-only channel');
456
+ }
457
+ }
458
+ /**
459
+ * Creates a new channel reference with the specified direction.
460
+ */
461
+ export function makeChannelRef(channel, direction) {
462
+ switch (direction) {
463
+ case 'send':
464
+ return new SendOnlyChannelRef(channel);
465
+ case 'receive':
466
+ return new ReceiveOnlyChannelRef(channel);
467
+ default: // 'both'
468
+ return new BidirectionalChannelRef(channel);
469
+ }
470
+ }
471
+ //# sourceMappingURL=channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../gs/builtin/channel.ts"],"names":[],"mappings":"AA6FA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAsB,EACtB,aAAsB,KAAK;IAE3B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QACtC,uEAAuE;QACvE,+DAA+D;QAC/D,OAAO,IAAI,OAAO,CAAO,GAAG,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IAAG,CAAC;IAE1C,2BAA2B;IAC3B,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IAC/B,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAA;IACrC,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAA;IAC7C,CAAC;IAED,aAAa,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IACvC,CAAC;IAED,2BAA2B;IAC3B,IAAI,CAAC,KAAQ;QACX,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IACxD,CAAC;IAED,4BAA4B;IAC5B,KAAK;QACH,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IACtD,CAAC;IAED,kBAAkB;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,UAAU,CAAC,KAAQ,EAAE,EAAU;QAC7B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IACxD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAmB,EACnB,SAAsC;IAEtC,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,IAAI,kBAAkB,CAAI,OAAO,CAAC,CAAA;QAC3C,KAAK,SAAS;YACZ,OAAO,IAAI,qBAAqB,CAAI,OAAO,CAAC,CAAA;QAC9C,SAAS,SAAS;YAChB,OAAO,IAAI,uBAAuB,CAAI,OAAO,CAAC,CAAA;IAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * DisposableStack manages synchronous disposable resources, mimicking Go's defer behavior.
3
+ * Functions added via `defer` are executed in LIFO order when the stack is disposed.
4
+ * Implements the `Disposable` interface for use with `using` declarations.
5
+ */
6
+ export declare class DisposableStack implements Disposable {
7
+ private stack;
8
+ /**
9
+ * Adds a function to be executed when the stack is disposed.
10
+ * @param fn The function to defer.
11
+ */
12
+ defer(fn: () => void): void;
13
+ /**
14
+ * Disposes of the resources in the stack by executing the deferred functions
15
+ * in Last-In, First-Out (LIFO) order.
16
+ * If a deferred function throws an error, disposal stops, and the error is rethrown,
17
+ * similar to Go's panic behavior during defer execution.
18
+ */
19
+ [Symbol.dispose](): void;
20
+ }
21
+ /**
22
+ * AsyncDisposableStack manages asynchronous disposable resources, mimicking Go's defer behavior.
23
+ * Functions added via `defer` are executed sequentially in LIFO order when the stack is disposed.
24
+ * Implements the `AsyncDisposable` interface for use with `await using` declarations.
25
+ */
26
+ export declare class AsyncDisposableStack implements AsyncDisposable {
27
+ private stack;
28
+ /**
29
+ * Adds a synchronous or asynchronous function to be executed when the stack is disposed.
30
+ * @param fn The function to defer. Can return void or a Promise<void>.
31
+ */
32
+ defer(fn: () => Promise<void> | void): void;
33
+ /**
34
+ * Asynchronously disposes of the resources in the stack by executing the deferred functions
35
+ * sequentially in Last-In, First-Out (LIFO) order. It awaits each function if it returns a promise.
36
+ */
37
+ [Symbol.asyncDispose](): Promise<void>;
38
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * DisposableStack manages synchronous disposable resources, mimicking Go's defer behavior.
3
+ * Functions added via `defer` are executed in LIFO order when the stack is disposed.
4
+ * Implements the `Disposable` interface for use with `using` declarations.
5
+ */
6
+ export class DisposableStack {
7
+ stack = [];
8
+ /**
9
+ * Adds a function to be executed when the stack is disposed.
10
+ * @param fn The function to defer.
11
+ */
12
+ defer(fn) {
13
+ this.stack.push(fn);
14
+ }
15
+ /**
16
+ * Disposes of the resources in the stack by executing the deferred functions
17
+ * in Last-In, First-Out (LIFO) order.
18
+ * If a deferred function throws an error, disposal stops, and the error is rethrown,
19
+ * similar to Go's panic behavior during defer execution.
20
+ */
21
+ [Symbol.dispose]() {
22
+ // Emulate Go: if a deferred throws, stop and rethrow
23
+ while (this.stack.length) {
24
+ const fn = this.stack.pop();
25
+ fn();
26
+ }
27
+ }
28
+ }
29
+ /**
30
+ * AsyncDisposableStack manages asynchronous disposable resources, mimicking Go's defer behavior.
31
+ * Functions added via `defer` are executed sequentially in LIFO order when the stack is disposed.
32
+ * Implements the `AsyncDisposable` interface for use with `await using` declarations.
33
+ */
34
+ export class AsyncDisposableStack {
35
+ stack = [];
36
+ /**
37
+ * Adds a synchronous or asynchronous function to be executed when the stack is disposed.
38
+ * @param fn The function to defer. Can return void or a Promise<void>.
39
+ */
40
+ defer(fn) {
41
+ this.stack.push(fn);
42
+ }
43
+ /**
44
+ * Asynchronously disposes of the resources in the stack by executing the deferred functions
45
+ * sequentially in Last-In, First-Out (LIFO) order. It awaits each function if it returns a promise.
46
+ */
47
+ async [Symbol.asyncDispose]() {
48
+ // Execute in LIFO order, awaiting each potentially async function
49
+ for (let i = this.stack.length - 1; i >= 0; --i) {
50
+ await this.stack[i]();
51
+ }
52
+ }
53
+ }
54
+ //# sourceMappingURL=defer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defer.js","sourceRoot":"","sources":["../../../gs/builtin/defer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAClB,KAAK,GAAmB,EAAE,CAAA;IAElC;;;OAGG;IACH,KAAK,CAAC,EAAc;QAClB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAED;;;;;OAKG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,qDAAqD;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAG,CAAA;YAC5B,EAAE,EAAE,CAAA;QACN,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACvB,KAAK,GAAmC,EAAE,CAAA;IAElD;;;OAGG;IACH,KAAK,CAAC,EAA8B;QAClC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,kEAAkE;QAClE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YAChD,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QACvB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export * from './builtin.js';
@@ -0,0 +1,2 @@
1
+ export * from './builtin.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/builtin/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Implementation of Go's built-in println function
3
+ * @param args Arguments to print
4
+ */
5
+ export declare function println(...args: any[]): void;
6
+ /**
7
+ * Implementation of Go's built-in panic function
8
+ * @param args Arguments passed to panic
9
+ */
10
+ export declare function panic(...args: any[]): void;
11
+ /**
12
+ * Represents the Go error type (interface).
13
+ */
14
+ export type GoError = {
15
+ Error(): string;
16
+ } | null;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Implementation of Go's built-in println function
3
+ * @param args Arguments to print
4
+ */
5
+ export function println(...args) {
6
+ console.log(...args);
7
+ }
8
+ /**
9
+ * Implementation of Go's built-in panic function
10
+ * @param args Arguments passed to panic
11
+ */
12
+ export function panic(...args) {
13
+ throw new Error(`panic: ${args.map((arg) => String(arg)).join(' ')}`);
14
+ }
15
+ //# sourceMappingURL=io.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","sourceRoot":"","sources":["../../../gs/builtin/io.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,IAAW;IAClC,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACvE,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Creates a new map (TypeScript Map).
3
+ * @returns A new TypeScript Map.
4
+ */
5
+ export declare const makeMap: <K, V>() => Map<K, V>;
6
+ /**
7
+ * Gets a value from a map, with a default value if the key doesn't exist.
8
+ * @param map The map to get from.
9
+ * @param key The key to get.
10
+ * @param defaultValue The default value to return if the key doesn't exist (defaults to 0).
11
+ * @returns The value for the key, or the default value if the key doesn't exist.
12
+ */
13
+ export declare const mapGet: <K, V>(map: Map<K, V>, key: K, defaultValue?: V | null) => V | null;
14
+ /**
15
+ * Sets a value in a map.
16
+ * @param map The map to set in.
17
+ * @param key The key to set.
18
+ * @param value The value to set.
19
+ */
20
+ export declare const mapSet: <K, V>(map: Map<K, V>, key: K, value: V) => void;
21
+ /**
22
+ * Deletes a key from a map.
23
+ * @param map The map to delete from.
24
+ * @param key The key to delete.
25
+ */
26
+ export declare const deleteMapEntry: <K, V>(map: Map<K, V>, key: K) => void;
27
+ /**
28
+ * Checks if a key exists in a map.
29
+ * @param map The map to check in.
30
+ * @param key The key to check.
31
+ * @returns True if the key exists, false otherwise.
32
+ */
33
+ export declare const mapHas: <K, V>(map: Map<K, V>, key: K) => boolean;