goscript 0.0.38 → 0.0.39

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 (116) hide show
  1. package/compiler/expr-call.go +12 -0
  2. package/compiler/lit.go +17 -6
  3. package/dist/gs/builtin/builtin.d.ts +45 -0
  4. package/dist/gs/builtin/builtin.js +197 -0
  5. package/dist/gs/builtin/builtin.js.map +1 -1
  6. package/dist/gs/bytes/buffer.gs.d.ts +56 -0
  7. package/dist/gs/bytes/buffer.gs.js +611 -0
  8. package/dist/gs/bytes/buffer.gs.js.map +1 -0
  9. package/dist/gs/bytes/bytes.gs.d.ts +78 -0
  10. package/dist/gs/bytes/bytes.gs.js +1011 -0
  11. package/dist/gs/bytes/bytes.gs.js.map +1 -0
  12. package/dist/gs/bytes/index.d.ts +4 -0
  13. package/dist/gs/bytes/index.js +5 -0
  14. package/dist/gs/bytes/index.js.map +1 -0
  15. package/dist/gs/bytes/iter.gs.d.ts +9 -0
  16. package/dist/gs/bytes/iter.gs.js +143 -0
  17. package/dist/gs/bytes/iter.gs.js.map +1 -0
  18. package/dist/gs/bytes/reader.gs.d.ts +34 -0
  19. package/dist/gs/bytes/reader.gs.js +198 -0
  20. package/dist/gs/bytes/reader.gs.js.map +1 -0
  21. package/dist/gs/internal/bytealg/index.d.ts +14 -2
  22. package/dist/gs/internal/bytealg/index.js +114 -8
  23. package/dist/gs/internal/bytealg/index.js.map +1 -1
  24. package/dist/gs/reflect/deepequal.d.ts +2 -1
  25. package/dist/gs/reflect/deepequal.js +5 -53
  26. package/dist/gs/reflect/deepequal.js.map +1 -1
  27. package/dist/gs/reflect/map.d.ts +14 -8
  28. package/dist/gs/reflect/map.js +15 -11
  29. package/dist/gs/reflect/map.js.map +1 -1
  30. package/dist/gs/reflect/type.d.ts +17 -9
  31. package/dist/gs/reflect/type.js +1 -1
  32. package/dist/gs/reflect/type.js.map +1 -1
  33. package/dist/gs/reflect/value.js +2 -1
  34. package/dist/gs/reflect/value.js.map +1 -1
  35. package/dist/gs/reflect/visiblefields.js +18 -12
  36. package/dist/gs/reflect/visiblefields.js.map +1 -1
  37. package/dist/gs/unicode/utf8/utf8.d.ts +1 -1
  38. package/dist/gs/unicode/utf8/utf8.js +4 -2
  39. package/dist/gs/unicode/utf8/utf8.js.map +1 -1
  40. package/gs/builtin/builtin.ts +219 -0
  41. package/gs/bytes/buffer.gs.ts +614 -0
  42. package/gs/bytes/bytes.gs.ts +1180 -0
  43. package/gs/bytes/godoc.txt +69 -0
  44. package/gs/bytes/index.ts +69 -0
  45. package/gs/bytes/iter.gs.ts +149 -0
  46. package/gs/bytes/reader.gs.ts +230 -0
  47. package/gs/internal/bytealg/index.ts +125 -10
  48. package/gs/reflect/deepequal.test.ts +41 -0
  49. package/gs/reflect/deepequal.ts +19 -4
  50. package/gs/reflect/map.test.ts +30 -0
  51. package/gs/reflect/map.ts +22 -18
  52. package/gs/reflect/type.ts +19 -15
  53. package/gs/reflect/value.ts +8 -2
  54. package/gs/reflect/visiblefields.ts +17 -13
  55. package/gs/unicode/utf8/utf8.ts +8 -5
  56. package/package.json +1 -1
  57. package/dist/gs/internal/testlog/index.d.ts +0 -1
  58. package/dist/gs/internal/testlog/index.js +0 -5
  59. package/dist/gs/internal/testlog/index.js.map +0 -1
  60. package/dist/gs/maps/iter.gs.d.ts +0 -7
  61. package/dist/gs/maps/iter.gs.js +0 -65
  62. package/dist/gs/maps/iter.gs.js.map +0 -1
  63. package/dist/gs/maps/maps.gs.d.ts +0 -7
  64. package/dist/gs/maps/maps.gs.js +0 -79
  65. package/dist/gs/maps/maps.gs.js.map +0 -1
  66. package/dist/gs/reflect/abi.d.ts +0 -59
  67. package/dist/gs/reflect/abi.gs.d.ts +0 -59
  68. package/dist/gs/reflect/abi.gs.js +0 -79
  69. package/dist/gs/reflect/abi.gs.js.map +0 -1
  70. package/dist/gs/reflect/abi.js +0 -79
  71. package/dist/gs/reflect/abi.js.map +0 -1
  72. package/dist/gs/reflect/badlinkname.d.ts +0 -52
  73. package/dist/gs/reflect/badlinkname.gs.d.ts +0 -52
  74. package/dist/gs/reflect/badlinkname.gs.js +0 -72
  75. package/dist/gs/reflect/badlinkname.gs.js.map +0 -1
  76. package/dist/gs/reflect/badlinkname.js +0 -72
  77. package/dist/gs/reflect/badlinkname.js.map +0 -1
  78. package/dist/gs/reflect/deepequal.gs.d.ts +0 -25
  79. package/dist/gs/reflect/deepequal.gs.js +0 -308
  80. package/dist/gs/reflect/deepequal.gs.js.map +0 -1
  81. package/dist/gs/reflect/float32reg_generic.gs.d.ts +0 -2
  82. package/dist/gs/reflect/float32reg_generic.gs.js +0 -10
  83. package/dist/gs/reflect/float32reg_generic.gs.js.map +0 -1
  84. package/dist/gs/reflect/index.gs.d.ts +0 -1
  85. package/dist/gs/reflect/index.gs.js +0 -3
  86. package/dist/gs/reflect/index.gs.js.map +0 -1
  87. package/dist/gs/reflect/iter.gs.d.ts +0 -3
  88. package/dist/gs/reflect/iter.gs.js +0 -24
  89. package/dist/gs/reflect/iter.gs.js.map +0 -1
  90. package/dist/gs/reflect/makefunc.gs.d.ts +0 -34
  91. package/dist/gs/reflect/makefunc.gs.js +0 -288
  92. package/dist/gs/reflect/makefunc.gs.js.map +0 -1
  93. package/dist/gs/reflect/map_swiss.gs.d.ts +0 -14
  94. package/dist/gs/reflect/map_swiss.gs.js +0 -70
  95. package/dist/gs/reflect/map_swiss.gs.js.map +0 -1
  96. package/dist/gs/reflect/reflect.gs.d.ts +0 -132
  97. package/dist/gs/reflect/reflect.gs.js +0 -437
  98. package/dist/gs/reflect/reflect.gs.js.map +0 -1
  99. package/dist/gs/reflect/swapper.gs.d.ts +0 -1
  100. package/dist/gs/reflect/swapper.gs.js +0 -32
  101. package/dist/gs/reflect/swapper.gs.js.map +0 -1
  102. package/dist/gs/reflect/type.gs.d.ts +0 -4
  103. package/dist/gs/reflect/type.gs.js +0 -21
  104. package/dist/gs/reflect/type.gs.js.map +0 -1
  105. package/dist/gs/reflect/value.gs.d.ts +0 -4
  106. package/dist/gs/reflect/value.gs.js +0 -12
  107. package/dist/gs/reflect/value.gs.js.map +0 -1
  108. package/dist/gs/reflect/visiblefields.gs.d.ts +0 -3
  109. package/dist/gs/reflect/visiblefields.gs.js +0 -123
  110. package/dist/gs/reflect/visiblefields.gs.js.map +0 -1
  111. package/dist/gs/stringslite/index.d.ts +0 -1
  112. package/dist/gs/stringslite/index.js +0 -2
  113. package/dist/gs/stringslite/index.js.map +0 -1
  114. package/dist/gs/stringslite/strings.d.ts +0 -11
  115. package/dist/gs/stringslite/strings.js +0 -67
  116. package/dist/gs/stringslite/strings.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { DeepEqual } from './deepequal.js'
3
+ import { Value, BasicType, Int, String as StringType } from './type.js'
4
+
5
+ describe('DeepEqual', () => {
6
+ it('should compare primitive values correctly', () => {
7
+ expect(DeepEqual(5, 5)).toBe(true)
8
+ expect(DeepEqual(5, 10)).toBe(false)
9
+
10
+ expect(DeepEqual('hello', 'hello')).toBe(true)
11
+ expect(DeepEqual('hello', 'world')).toBe(false)
12
+
13
+ expect(DeepEqual(true, true)).toBe(true)
14
+ expect(DeepEqual(true, false)).toBe(false)
15
+
16
+ expect(DeepEqual(null, null)).toBe(true)
17
+ expect(DeepEqual(undefined, undefined)).toBe(true)
18
+ expect(DeepEqual(null, undefined)).toBe(false)
19
+ })
20
+
21
+ it('should compare arrays correctly', () => {
22
+ expect(DeepEqual([1, 2, 3], [1, 2, 3])).toBe(true)
23
+ expect(DeepEqual([1, 2, 3], [1, 2, 4])).toBe(false)
24
+ expect(DeepEqual([1, 2, 3], [1, 2])).toBe(false)
25
+ })
26
+
27
+ it('should compare objects correctly', () => {
28
+ expect(DeepEqual({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(true)
29
+ expect(DeepEqual({ a: 1, b: 2 }, { a: 1, b: 3 })).toBe(false)
30
+ expect(DeepEqual({ a: 1, b: 2 }, { a: 1 })).toBe(false)
31
+ })
32
+
33
+ it('should compare Value objects correctly', () => {
34
+ const v1 = new Value(42, new BasicType(Int, 'int'))
35
+ const v2 = new Value(42, new BasicType(Int, 'int'))
36
+ const v3 = new Value('hello', new BasicType(StringType, 'string'))
37
+
38
+ expect(DeepEqual(v1, v2)).toBe(true)
39
+ expect(DeepEqual(v1, v3)).toBe(false)
40
+ })
41
+ })
@@ -49,7 +49,12 @@
49
49
  // values that have been compared before, it treats the values as
50
50
  // equal rather than examining the values to which they point.
51
51
  // This ensures that DeepEqual terminates.
52
- export function DeepEqual(x: null | any, y: null | any): boolean {
52
+ import { ReflectValue } from './types.js'
53
+
54
+ export function DeepEqual(
55
+ x: ReflectValue | null | undefined,
56
+ y: ReflectValue | null | undefined,
57
+ ): boolean {
53
58
  // Handle null/undefined cases
54
59
  if (x === y) {
55
60
  return true
@@ -112,7 +117,12 @@ export function DeepEqual(x: null | any, y: null | any): boolean {
112
117
 
113
118
  // Compare elements
114
119
  for (let i = 0; i < xMeta.length; i++) {
115
- if (!DeepEqual(xMeta.backing[i], yMeta.backing[i])) {
120
+ if (
121
+ !DeepEqual(
122
+ xMeta.backing[i] as ReflectValue,
123
+ yMeta.backing[i] as ReflectValue,
124
+ )
125
+ ) {
116
126
  return false
117
127
  }
118
128
  }
@@ -127,7 +137,10 @@ export function DeepEqual(x: null | any, y: null | any): boolean {
127
137
  return false
128
138
  }
129
139
  for (const [key, value] of x) {
130
- if (!y.has(key) || !DeepEqual(value, y.get(key))) {
140
+ if (
141
+ !y.has(key) ||
142
+ !DeepEqual(value as ReflectValue, y.get(key) as ReflectValue)
143
+ ) {
131
144
  return false
132
145
  }
133
146
  }
@@ -142,7 +155,9 @@ export function DeepEqual(x: null | any, y: null | any): boolean {
142
155
  return false
143
156
  }
144
157
  for (const key of keysX) {
145
- if (!keysY.includes(key) || !DeepEqual(x[key], y[key])) {
158
+ const xObj = x as Record<string, ReflectValue>
159
+ const yObj = y as Record<string, ReflectValue>
160
+ if (!keysY.includes(key) || !DeepEqual(xObj[key], yObj[key])) {
146
161
  return false
147
162
  }
148
163
  }
@@ -0,0 +1,30 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { MapIter } from './map.js'
3
+
4
+ describe('MapIter', () => {
5
+ it('should iterate over map entries with proper typing', () => {
6
+ const map = new Map<string, number>()
7
+ map.set('one', 1)
8
+ map.set('two', 2)
9
+ map.set('three', 3)
10
+
11
+ const iter = new MapIter<string, number>(map)
12
+
13
+ expect(iter.current?.done === false).toBe(true)
14
+ expect(iter.Key()).toBe('one')
15
+ expect(iter.Value()).toBe(1)
16
+
17
+ expect(iter.Next()).toBe(true)
18
+ expect(iter.current?.done === false).toBe(true)
19
+ expect(typeof iter.Key()).toBe('string')
20
+ expect(typeof iter.Value()).toBe('number')
21
+
22
+ const newMap = new Map<string, number>()
23
+ newMap.set('reset', 100)
24
+ iter.Reset(newMap)
25
+
26
+ expect(iter.current?.done === false).toBe(true)
27
+ expect(iter.Key()).toBe('reset')
28
+ expect(iter.Value()).toBe(100)
29
+ })
30
+ })
package/gs/reflect/map.ts CHANGED
@@ -37,35 +37,39 @@ class MapType implements Type {
37
37
  }
38
38
  }
39
39
 
40
- // Simple map iterator using JavaScript Map
41
- export class MapIter {
42
- private iterator: Iterator<[any, any]>
43
- private currentEntry: IteratorResult<[any, any]> | null = null
44
-
45
- constructor(private map: Map<any, any>) {
40
+ /**
41
+ * MapIter provides an iterator interface for Go maps.
42
+ * It wraps a JavaScript Map iterator and provides methods to iterate over key-value pairs.
43
+ * @template K - The type of keys in the map
44
+ * @template V - The type of values in the map
45
+ */
46
+ export class MapIter<K = unknown, V = unknown> {
47
+ public iterator: Iterator<[K, V]>
48
+ public current: IteratorResult<[K, V]> | null = null
49
+
50
+ constructor(public map: Map<K, V>) {
46
51
  this.iterator = map.entries()
47
52
  this.Next()
48
53
  }
49
54
 
50
55
  public Next(): boolean {
51
- this.currentEntry = this.iterator.next()
52
- return !this.currentEntry.done
56
+ this.current = this.iterator.next()
57
+ return !this.current.done
53
58
  }
54
59
 
55
- public Key(): any {
56
- return this.currentEntry?.value?.[0]
60
+ public Key(): K | null {
61
+ return this.current?.value?.[0] ?? null
57
62
  }
58
63
 
59
- public Value(): any {
60
- return this.currentEntry?.value?.[1]
64
+ public Value(): V | null {
65
+ return this.current?.value?.[1] ?? null
61
66
  }
62
67
 
63
- public Reset(m: any): void {
64
- if (m instanceof Map) {
65
- this.map = m
66
- this.iterator = m.entries()
67
- this.Next()
68
- }
68
+ public Reset(m: Map<K, V>): void {
69
+ this.map = m
70
+ this.iterator = m.entries()
71
+ this.current = null
72
+ this.Next()
69
73
  }
70
74
  }
71
75
 
@@ -1,4 +1,5 @@
1
- import { ReflectValue, ChanDir } from './types.js'
1
+ import { ReflectValue, ChanDir, StructField } from './types.js'
2
+ import { MapIter } from './map.js'
2
3
 
3
4
  // rtype is the common implementation of most values
4
5
  export class rtype {
@@ -181,7 +182,7 @@ export interface Type {
181
182
  PkgPath?(): string
182
183
 
183
184
  // Field returns a struct type's i'th field.
184
- Field?(i: number): any
185
+ Field?(i: number): StructField | null
185
186
 
186
187
  // common returns the common type implementation.
187
188
  common?(): rtype
@@ -351,15 +352,15 @@ export class Value {
351
352
  }
352
353
 
353
354
  // Additional methods needed by various parts of the codebase
354
- public UnsafePointer(): any {
355
+ public UnsafePointer(): unknown {
355
356
  return this._value
356
357
  }
357
358
 
358
- public pointer(): any {
359
+ public pointer(): unknown {
359
360
  return this._value
360
361
  }
361
362
 
362
- public get ptr(): any {
363
+ public get ptr(): unknown {
363
364
  return this._value
364
365
  }
365
366
 
@@ -383,7 +384,7 @@ export class Value {
383
384
  return 0
384
385
  }
385
386
 
386
- public MapRange(): any {
387
+ public MapRange(): MapIter<unknown, unknown> | null {
387
388
  // Placeholder for map iteration
388
389
  return null
389
390
  }
@@ -393,9 +394,9 @@ export class Value {
393
394
  return new Value(null, new BasicType(Invalid, 'invalid'))
394
395
  }
395
396
 
396
- public Complex(): any {
397
+ public Complex(): number | { real: number; imag: number } | null {
397
398
  // Placeholder for complex number support
398
- return this._value
399
+ return this._value as number | { real: number; imag: number } | null
399
400
  }
400
401
 
401
402
  // Send sends a value to a channel
@@ -459,7 +460,7 @@ export class BasicType implements Type {
459
460
  return ''
460
461
  }
461
462
 
462
- public Field?(_i: number): any {
463
+ public Field?(_i: number): StructField | null {
463
464
  return null
464
465
  }
465
466
 
@@ -532,7 +533,7 @@ class ArrayType implements Type {
532
533
  return ''
533
534
  }
534
535
 
535
- public Field?(_i: number): any {
536
+ public Field?(_i: number): StructField | null {
536
537
  return null
537
538
  }
538
539
 
@@ -569,7 +570,7 @@ class PointerType implements Type {
569
570
  return ''
570
571
  }
571
572
 
572
- public Field?(_i: number): any {
573
+ public Field?(_i: number): StructField | null {
573
574
  return null
574
575
  }
575
576
 
@@ -606,7 +607,7 @@ class FunctionType implements Type {
606
607
  return ''
607
608
  }
608
609
 
609
- public Field?(_i: number): any {
610
+ public Field?(_i: number): StructField | null {
610
611
  return null
611
612
  }
612
613
 
@@ -650,7 +651,7 @@ class MapType implements Type {
650
651
  return ''
651
652
  }
652
653
 
653
- public Field?(_i: number): any {
654
+ public Field?(_i: number): StructField | null {
654
655
  return null
655
656
  }
656
657
 
@@ -780,7 +781,7 @@ function getTypeOf(value: ReflectValue): Type {
780
781
  if (funcWithMeta.__typeInfo) {
781
782
  const typeInfo = funcWithMeta.__typeInfo
782
783
  if (
783
- typeInfo.kind === 'function' &&
784
+ (typeInfo.kind === 'function' || typeInfo.kind === 'Function') &&
784
785
  typeInfo.params &&
785
786
  typeInfo.results
786
787
  ) {
@@ -1003,7 +1004,10 @@ export function canRangeFunc2(t: Type): boolean {
1003
1004
  return kind === 21 // map
1004
1005
  }
1005
1006
 
1006
- export function funcLayout(_t: Type, _rcvr: Type | null): any {
1007
+ export function funcLayout(
1008
+ _t: Type,
1009
+ _rcvr: Type | null,
1010
+ ): { Type: Type | null; InCount: number; OutCount: number } {
1007
1011
  return {
1008
1012
  Type: null,
1009
1013
  InCount: 0,
@@ -28,6 +28,11 @@ import {
28
28
  import { ReflectValue, SelectCase, SelectRecv, SelectDefault } from './types.js'
29
29
  import * as $ from '@goscript/builtin/builtin.js'
30
30
 
31
+ interface ChannelObject {
32
+ _sendQueue?: unknown[]
33
+ send?: (value: unknown) => void
34
+ }
35
+
31
36
  // Re-export ValueOf from type.ts for compatibility
32
37
  export { ValueOf } from './type'
33
38
 
@@ -218,7 +223,8 @@ export function Select(cases: $.Slice<SelectCase>): [number, Value, boolean] {
218
223
  const selectCase = selectCases[i]
219
224
  if (selectCase.Dir.valueOf() === SelectRecv.valueOf() && selectCase.Chan) {
220
225
  const channelValue = selectCase.Chan
221
- const channelObj = (channelValue as unknown as { value: any }).value
226
+ const channelObj = (channelValue as unknown as { value: unknown })
227
+ .value as ChannelObject
222
228
 
223
229
  // Check if there are queued values to receive
224
230
  if (
@@ -226,7 +232,7 @@ export function Select(cases: $.Slice<SelectCase>): [number, Value, boolean] {
226
232
  channelObj._sendQueue &&
227
233
  channelObj._sendQueue.length > 0
228
234
  ) {
229
- const receivedValue = channelObj._sendQueue.shift() // Remove from queue
235
+ const receivedValue = channelObj._sendQueue.shift() as ReflectValue // Remove from queue
230
236
  const elemType = channelValue.Type().Elem()
231
237
  if (elemType) {
232
238
  const recvVal = new Value(receivedValue, elemType)
@@ -1,5 +1,5 @@
1
1
  import * as $ from '@goscript/builtin/builtin.js'
2
- import { Type } from './type.js'
2
+ import { Type, Ptr, Struct } from './type.js'
3
3
  import { StructField } from './types.js'
4
4
 
5
5
  // VisibleFields returns all the visible fields in t, which must be a
@@ -127,20 +127,24 @@ class visibleFieldsWalker {
127
127
  }
128
128
  $.mapSet(w.visiting, t, true)
129
129
  for (let i = 0; i < t!.NumField!(); i++) {
130
- let f = t!.Field!(i).clone()
131
- f.Index = $.append(null, w.index) as number[]
132
- if (f.Anonymous) {
133
- if (f.Type!.Kind().valueOf() == 22) {
134
- const elemType = f.Type!.Elem!()
135
- if (elemType) {
136
- f.Type = elemType
130
+ if (!t!.Field) continue
131
+ const field = t!.Field(i)
132
+ if (field) {
133
+ const f = field.clone()
134
+ f.Index = $.append(null, w.index) as number[]
135
+ if (f.Anonymous) {
136
+ if (f.Type && f.Type.Kind().valueOf() === Ptr.valueOf()) {
137
+ const elemType = f.Type.Elem!()
138
+ if (elemType) {
139
+ f.Type = elemType
140
+ }
137
141
  }
142
+ if (f.Type && f.Type.Kind().valueOf() === Struct.valueOf()) {
143
+ w.walk(f.Type)
144
+ }
145
+ } else {
146
+ w.fields = $.append(w.fields, f)
138
147
  }
139
- if (f.Type!.Kind().valueOf() == 25) {
140
- w.walk(f.Type)
141
- }
142
- } else {
143
- w.fields = $.append(w.fields, f)
144
148
  }
145
149
  }
146
150
  $.deleteMapEntry(w.visiting, t)
@@ -63,18 +63,21 @@ export function DecodeLastRuneInString(s: string): [number, number] {
63
63
  }
64
64
 
65
65
  // DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and its width in bytes.
66
- export function DecodeRune(p: Uint8Array): [number, number] {
67
- if (p.length === 0) {
66
+ export function DecodeRune(p: $.Bytes): [number, number] {
67
+ if (!p?.length) {
68
68
  return [RuneError, 0]
69
69
  }
70
70
 
71
- if (p[0] < RuneSelf) {
72
- return [p[0], 1]
71
+ if (p![0] < RuneSelf) {
72
+ return [p![0], 1]
73
73
  }
74
74
 
75
+ // Convert p to Uint8Array to satisfy AllowsSharedBufferSource requirement
76
+ const bytes = $.normalizeBytes(p)
77
+
75
78
  // Convert bytes to string and decode
76
79
  const decoder = new TextDecoder('utf-8', { fatal: false })
77
- const str = decoder.decode(p.slice(0, Math.min(4, p.length)))
80
+ const str = decoder.decode(bytes.slice(0, Math.min(4, bytes.length)))
78
81
  if (str.length === 0 || str === '\uFFFD') {
79
82
  return [RuneError, 1]
80
83
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "goscript",
3
3
  "description": "Go to TypeScript transpiler",
4
- "version": "0.0.38",
4
+ "version": "0.0.39",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",
@@ -1 +0,0 @@
1
- export declare function Getenv(key: string): void;
@@ -1,5 +0,0 @@
1
- // Stub implementations for internal/testlog package
2
- export function Getenv(key) {
3
- // Stub for test logging - no-op in runtime
4
- }
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/internal/testlog/index.ts"],"names":[],"mappings":"AAEA,oDAAoD;AAEpD,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,2CAA2C;AAC7C,CAAC"}
@@ -1,7 +0,0 @@
1
- import * as $ from "@goscript/builtin/builtin.js";
2
- import * as iter from "@goscript/iter/index.js";
3
- export declare function All<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq2<K, V>;
4
- export declare function Keys<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq<K>;
5
- export declare function Values<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq<V>;
6
- export declare function Insert<K extends $.Comparable, V>(m: Map<K, V>, seq: iter.Seq2<K, V>): void;
7
- export declare function Collect<K extends $.Comparable, V extends any>(seq: iter.Seq2<K, V>): Map<K, V>;
@@ -1,65 +0,0 @@
1
- import * as $ from "@goscript/builtin/builtin.js";
2
- // All returns an iterator over key-value pairs from m.
3
- // The iteration order is not specified and is not guaranteed
4
- // to be the same from one call to the next.
5
- export function All(m) {
6
- return (_yield) => {
7
- for (const [k, v] of m.entries()) {
8
- {
9
- if (!_yield(k, v)) {
10
- return;
11
- }
12
- }
13
- }
14
- };
15
- }
16
- // Keys returns an iterator over keys in m.
17
- // The iteration order is not specified and is not guaranteed
18
- // to be the same from one call to the next.
19
- export function Keys(m) {
20
- return (_yield) => {
21
- for (const [k, _v] of m.entries()) {
22
- {
23
- if (!_yield(k)) {
24
- return;
25
- }
26
- }
27
- }
28
- };
29
- }
30
- // Values returns an iterator over values in m.
31
- // The iteration order is not specified and is not guaranteed
32
- // to be the same from one call to the next.
33
- export function Values(m) {
34
- return (_yield) => {
35
- for (const [_k, v] of m.entries()) {
36
- {
37
- if (!_yield(v)) {
38
- return;
39
- }
40
- }
41
- }
42
- };
43
- }
44
- // Insert adds the key-value pairs from seq to m.
45
- // If a key in seq already exists in m, its value will be overwritten.
46
- export function Insert(m, seq) {
47
- ;
48
- (() => {
49
- let shouldContinue = true;
50
- seq((k, v) => {
51
- {
52
- $.mapSet(m, k, v);
53
- }
54
- return shouldContinue;
55
- });
56
- })();
57
- }
58
- // Collect collects key-value pairs from seq into a new map
59
- // and returns it.
60
- export function Collect(seq) {
61
- let m = $.makeMap();
62
- Insert(m, seq);
63
- return m;
64
- }
65
- //# sourceMappingURL=iter.gs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iter.gs.js","sourceRoot":"","sources":["../../../gs/maps/iter.gs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAIlD,uDAAuD;AACvD,6DAA6D;AAC7D,4CAA4C;AAC5C,MAAM,UAAU,GAAG,CAA4B,CAAY;IAC1D,OAAO,CAAC,MAA0C,EAAQ,EAAE;QAC3D,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YAClC,CAAC;gBACA,IAAI,CAAC,MAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;oBACpB,OAAM;gBACP,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC,CAAA;AACF,CAAC;AAED,2CAA2C;AAC3C,6DAA6D;AAC7D,4CAA4C;AAC5C,MAAM,UAAU,IAAI,CAA4B,CAAY;IAC3D,OAAO,CAAC,MAAmC,EAAQ,EAAE;QACpD,KAAK,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACnC,CAAC;gBACA,IAAI,CAAC,MAAO,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjB,OAAM;gBACP,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC,CAAA;AACF,CAAC;AAED,+CAA+C;AAC/C,6DAA6D;AAC7D,4CAA4C;AAC5C,MAAM,UAAU,MAAM,CAA4B,CAAY;IAC7D,OAAO,CAAC,MAAmC,EAAQ,EAAE;QACpD,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACnC,CAAC;gBACA,IAAI,CAAC,MAAO,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjB,OAAM;gBACP,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC,CAAA;AACF,CAAC;AAED,iDAAiD;AACjD,sEAAsE;AACtE,MAAM,UAAU,MAAM,CAA4B,CAAY,EAAE,GAAoB;IACnF,CAAC;IAAA,CAAC,GAAG,EAAE;QACN,IAAI,cAAc,GAAG,IAAI,CAAA;QACzB,GAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACb,CAAC;gBACA,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YAClB,CAAC;YACD,OAAO,cAAc,CAAA;QACtB,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,EAAE,CAAA;AACL,CAAC;AAED,2DAA2D;AAC3D,kBAAkB;AAClB,MAAM,UAAU,OAAO,CAAwC,GAAoB;IAClF,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAQ,CAAA;IACzB,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACd,OAAO,CAAC,CAAA;AACT,CAAC"}
@@ -1,7 +0,0 @@
1
- import * as $ from "@goscript/builtin/builtin.js";
2
- export declare function Equal<K extends $.Comparable, V extends $.Comparable>(m1: Map<K, V>, m2: Map<K, V>): boolean;
3
- export declare function EqualFunc<K extends $.Comparable, V1, V2>(m1: Map<K, V1>, m2: Map<K, V2>, eq: ((p0: V1, p1: V2) => boolean) | null): boolean;
4
- export declare function clone<K extends $.Comparable, V>(m: Map<K, V> | null): Map<K, V> | null;
5
- export declare function Clone<K extends $.Comparable, V>(m: Map<K, V>): Map<K, V>;
6
- export declare function Copy<K extends $.Comparable, V>(dst: Map<K, V>, src: Map<K, V>): void;
7
- export declare function DeleteFunc<K extends $.Comparable, V>(m: Map<K, V>, del: ((p0: K, p1: V) => boolean) | null): void;
@@ -1,79 +0,0 @@
1
- import * as $ from "@goscript/builtin/builtin.js";
2
- // Equal reports whether two maps contain the same key/value pairs.
3
- // Values are compared using ==.
4
- export function Equal(m1, m2) {
5
- if ($.len(m1) != $.len(m2)) {
6
- return false;
7
- }
8
- for (const [k, v1] of m1.entries()) {
9
- {
10
- {
11
- let [v2, ok] = $.mapGet(m2, k, null);
12
- if (!ok || v1 != v2) {
13
- return false;
14
- }
15
- }
16
- }
17
- }
18
- return true;
19
- }
20
- // EqualFunc is like Equal, but compares values using eq.
21
- // Keys are still compared with ==.
22
- export function EqualFunc(m1, m2, eq) {
23
- if ($.len(m1) != $.len(m2)) {
24
- return false;
25
- }
26
- for (const [k, v1] of m1.entries()) {
27
- {
28
- {
29
- let [v2, ok] = $.mapGet(m2, k, null);
30
- if (!ok || !eq(v1, v2)) {
31
- return false;
32
- }
33
- }
34
- }
35
- }
36
- return true;
37
- }
38
- // clone returns a shallow copy of the map.
39
- export function clone(m) {
40
- if (m == null) {
41
- return null;
42
- }
43
- const result = $.makeMap();
44
- for (const [k, v] of m.entries()) {
45
- $.mapSet(result, k, v);
46
- }
47
- return result;
48
- }
49
- // Clone returns a copy of m. This is a shallow clone:
50
- // the new keys and values are set using ordinary assignment.
51
- export function Clone(m) {
52
- // Preserve nil in case it matters.
53
- if (m == null) {
54
- return null;
55
- }
56
- return clone(m);
57
- }
58
- // Copy copies all key/value pairs in src adding them to dst.
59
- // When a key in src is already present in dst,
60
- // the value in dst will be overwritten by the value associated
61
- // with the key in src.
62
- export function Copy(dst, src) {
63
- for (const [k, v] of src.entries()) {
64
- {
65
- $.mapSet(dst, k, v);
66
- }
67
- }
68
- }
69
- // DeleteFunc deletes any key/value pairs from m for which del returns true.
70
- export function DeleteFunc(m, del) {
71
- for (const [k, v] of m.entries()) {
72
- {
73
- if (del(k, v)) {
74
- $.deleteMapEntry(m, k);
75
- }
76
- }
77
- }
78
- }
79
- //# sourceMappingURL=maps.gs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"maps.gs.js","sourceRoot":"","sources":["../../../gs/maps/maps.gs.ts"],"names":[],"mappings":"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"}
@@ -1,59 +0,0 @@
1
- import * as $ from "@goscript/builtin/builtin.js";
2
- import { uintptr, Pointer } from "./types.js";
3
- export interface Type {
4
- Kind(): number;
5
- Align(): number;
6
- Size(): number;
7
- }
8
- export declare class abiStep {
9
- freg: number;
10
- ireg: number;
11
- kind: number;
12
- offset: uintptr;
13
- size: uintptr;
14
- stkOff: uintptr;
15
- constructor(init?: Partial<{
16
- freg?: number;
17
- ireg?: number;
18
- kind?: number;
19
- offset?: uintptr;
20
- size?: uintptr;
21
- stkOff?: uintptr;
22
- }>);
23
- }
24
- export declare class abiSeq {
25
- iregs: number;
26
- fregs: number;
27
- stackBytes: uintptr;
28
- steps: $.Slice<abiStep>;
29
- valueStart: $.Slice<number>;
30
- constructor(init?: Partial<{
31
- fregs?: number;
32
- iregs?: number;
33
- stackBytes?: uintptr;
34
- steps?: $.Slice<abiStep>;
35
- valueStart?: $.Slice<number>;
36
- }>);
37
- print(): void;
38
- assignIntN(offset: uintptr, size: uintptr, n: number, ptrMap: number): boolean;
39
- assignFloatN(offset: uintptr, size: uintptr, n: number): boolean;
40
- stackAssign(size: uintptr, alignment: uintptr): void;
41
- regAssign(t: Type | null, offset: uintptr): boolean;
42
- }
43
- export declare class abiDesc {
44
- call: abiSeq;
45
- ret: abiSeq;
46
- stackCallArgsSize: uintptr;
47
- retOffset: uintptr;
48
- spill: uintptr;
49
- inRegPtrs: any;
50
- outRegPtrs: any;
51
- stackPtrs: any;
52
- constructor(init?: any);
53
- dump(): void;
54
- }
55
- export declare function newAbiDesc(t: any, rcvr: any): abiDesc;
56
- export declare function intFromReg(r: any, reg: number, argSize: uintptr, to: Pointer): void;
57
- export declare function intToReg(r: any, reg: number, argSize: uintptr, from: Pointer): void;
58
- export declare function floatFromReg(r: any, reg: number, argSize: uintptr, to: Pointer): void;
59
- export declare function floatToReg(r: any, reg: number, argSize: uintptr, from: Pointer): void;