goscript 0.0.37 → 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.
- package/compiler/analysis.go +129 -8
- package/compiler/compiler.go +4 -1
- package/compiler/composite-lit.go +2 -4
- package/compiler/expr-call.go +12 -0
- package/compiler/lit.go +100 -6
- package/compiler/protobuf.go +2 -2
- package/compiler/spec-value.go +3 -3
- package/compiler/spec.go +6 -3
- package/compiler/stmt-assign.go +1 -1
- package/dist/gs/builtin/builtin.d.ts +45 -0
- package/dist/gs/builtin/builtin.js +197 -0
- package/dist/gs/builtin/builtin.js.map +1 -1
- package/dist/gs/builtin/slice.js +2 -1
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/bytes/buffer.gs.d.ts +56 -0
- package/dist/gs/bytes/buffer.gs.js +611 -0
- package/dist/gs/bytes/buffer.gs.js.map +1 -0
- package/dist/gs/bytes/bytes.gs.d.ts +78 -0
- package/dist/gs/bytes/bytes.gs.js +1011 -0
- package/dist/gs/bytes/bytes.gs.js.map +1 -0
- package/dist/gs/bytes/index.d.ts +4 -0
- package/dist/gs/bytes/index.js +5 -0
- package/dist/gs/bytes/index.js.map +1 -0
- package/dist/gs/bytes/iter.gs.d.ts +9 -0
- package/dist/gs/bytes/iter.gs.js +143 -0
- package/dist/gs/bytes/iter.gs.js.map +1 -0
- package/dist/gs/bytes/reader.gs.d.ts +34 -0
- package/dist/gs/bytes/reader.gs.js +198 -0
- package/dist/gs/bytes/reader.gs.js.map +1 -0
- package/dist/gs/github.com/pkg/errors/errors.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js +182 -23
- package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/go113.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/index.d.ts +3 -3
- package/dist/gs/github.com/pkg/errors/index.js +3 -3
- package/dist/gs/github.com/pkg/errors/index.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/stack.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/stack.js +8 -5
- package/dist/gs/github.com/pkg/errors/stack.js.map +1 -1
- package/dist/gs/internal/abi/index.d.ts +20 -0
- package/dist/gs/internal/abi/index.js +20 -0
- package/dist/gs/internal/abi/index.js.map +1 -0
- package/dist/gs/internal/bytealg/index.d.ts +14 -0
- package/dist/gs/internal/bytealg/index.js +139 -0
- package/dist/gs/internal/bytealg/index.js.map +1 -0
- package/dist/gs/internal/byteorder/index.d.ts +1 -1
- package/dist/gs/internal/byteorder/index.js +4 -4
- package/dist/gs/internal/byteorder/index.js.map +1 -1
- package/dist/gs/math/index.d.ts +44 -44
- package/dist/gs/math/index.js +44 -44
- package/dist/gs/math/index.js.map +1 -1
- package/dist/gs/os/index.d.ts +19 -19
- package/dist/gs/os/index.js +19 -19
- package/dist/gs/os/index.js.map +1 -1
- package/dist/gs/reflect/deepequal.d.ts +2 -0
- package/dist/gs/reflect/deepequal.js +91 -0
- package/dist/gs/reflect/deepequal.js.map +1 -0
- package/dist/gs/reflect/index.d.ts +8 -0
- package/dist/gs/reflect/index.js +10 -0
- package/dist/gs/reflect/index.js.map +1 -0
- package/dist/gs/reflect/iter.d.ts +4 -0
- package/dist/gs/reflect/iter.js +24 -0
- package/dist/gs/reflect/iter.js.map +1 -0
- package/dist/gs/reflect/map.d.ts +20 -0
- package/dist/gs/reflect/map.js +74 -0
- package/dist/gs/reflect/map.js.map +1 -0
- package/dist/gs/reflect/swapper.d.ts +2 -0
- package/dist/gs/reflect/swapper.js +46 -0
- package/dist/gs/reflect/swapper.js.map +1 -0
- package/dist/gs/reflect/type.d.ts +134 -0
- package/dist/gs/reflect/type.js +825 -0
- package/dist/gs/reflect/type.js.map +1 -0
- package/dist/gs/reflect/types.d.ts +90 -0
- package/dist/gs/reflect/types.js +119 -0
- package/dist/gs/reflect/types.js.map +1 -0
- package/dist/gs/reflect/value.d.ts +13 -0
- package/dist/gs/reflect/value.js +202 -0
- package/dist/gs/reflect/value.js.map +1 -0
- package/dist/gs/reflect/visiblefields.d.ts +4 -0
- package/dist/gs/reflect/visiblefields.js +149 -0
- package/dist/gs/reflect/visiblefields.js.map +1 -0
- package/dist/gs/strconv/index.d.ts +6 -6
- package/dist/gs/strconv/index.js +6 -6
- package/dist/gs/strconv/index.js.map +1 -1
- package/dist/gs/strings/index.d.ts +1 -1
- package/dist/gs/strings/index.js +1 -1
- package/dist/gs/strings/index.js.map +1 -1
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/sync/atomic/index.d.ts +4 -4
- package/dist/gs/sync/atomic/index.js +4 -4
- package/dist/gs/sync/atomic/index.js.map +1 -1
- package/dist/gs/syscall/index.d.ts +6 -6
- package/dist/gs/syscall/index.js +34 -28
- package/dist/gs/syscall/index.js.map +1 -1
- package/dist/gs/unicode/utf8/utf8.d.ts +1 -1
- package/dist/gs/unicode/utf8/utf8.js +4 -2
- package/dist/gs/unicode/utf8/utf8.js.map +1 -1
- package/dist/gs/unsafe/unsafe.js.map +1 -1
- package/gs/builtin/builtin.ts +219 -0
- package/gs/builtin/slice.ts +2 -1
- package/gs/bytes/buffer.gs.ts +614 -0
- package/gs/bytes/bytes.gs.ts +1180 -0
- package/gs/bytes/godoc.txt +69 -0
- package/gs/bytes/index.ts +69 -0
- package/gs/bytes/iter.gs.ts +149 -0
- package/gs/bytes/reader.gs.ts +230 -0
- package/gs/github.com/pkg/errors/errors.ts +408 -238
- package/gs/github.com/pkg/errors/go113.ts +5 -6
- package/gs/github.com/pkg/errors/index.ts +12 -3
- package/gs/github.com/pkg/errors/stack.ts +107 -105
- package/gs/internal/abi/index.ts +37 -0
- package/gs/internal/bytealg/index.ts +149 -0
- package/gs/internal/byteorder/index.ts +5 -5
- package/gs/math/abs.gs.test.ts +1 -1
- package/gs/math/acosh.gs.test.ts +4 -2
- package/gs/math/asin.gs.test.ts +1 -1
- package/gs/math/asinh.gs.test.ts +7 -3
- package/gs/math/atan.gs.test.ts +1 -1
- package/gs/math/atan2.gs.test.ts +17 -9
- package/gs/math/atanh.gs.test.ts +1 -1
- package/gs/math/bits.gs.test.ts +1 -1
- package/gs/math/cbrt.gs.test.ts +1 -1
- package/gs/math/const.gs.test.ts +34 -8
- package/gs/math/copysign.gs.test.ts +7 -3
- package/gs/math/dim.gs.test.ts +19 -7
- package/gs/math/erf.gs.test.ts +1 -1
- package/gs/math/erfinv.gs.test.ts +4 -2
- package/gs/math/exp.gs.test.ts +1 -1
- package/gs/math/expm1.gs.test.ts +6 -4
- package/gs/math/floor.gs.test.ts +17 -4
- package/gs/math/fma.gs.test.ts +53 -53
- package/gs/math/frexp.gs.test.ts +112 -117
- package/gs/math/gamma.gs.test.ts +1 -1
- package/gs/math/hypot.gs.test.ts +53 -53
- package/gs/math/index.ts +80 -44
- package/gs/math/j0.gs.test.ts +6 -2
- package/gs/math/j1.gs.test.ts +6 -2
- package/gs/math/jn.gs.test.ts +9 -5
- package/gs/math/ldexp.gs.test.ts +103 -86
- package/gs/math/lgamma.gs.test.ts +10 -10
- package/gs/math/log.gs.test.ts +1 -1
- package/gs/math/log10.gs.test.ts +1 -1
- package/gs/math/log1p.gs.test.ts +2 -2
- package/gs/math/logb.gs.test.ts +1 -1
- package/gs/math/mod.gs.test.ts +2 -2
- package/gs/math/modf.gs.test.ts +7 -7
- package/gs/math/nextafter.gs.test.ts +9 -7
- package/gs/math/pow.gs.test.ts +6 -4
- package/gs/math/pow10.gs.test.ts +1 -1
- package/gs/math/remainder.gs.test.ts +1 -1
- package/gs/math/signbit.gs.test.ts +1 -1
- package/gs/math/sin.gs.test.ts +1 -1
- package/gs/math/sincos.gs.test.ts +33 -14
- package/gs/math/sinh.gs.test.ts +1 -1
- package/gs/math/sqrt.gs.test.ts +1 -1
- package/gs/math/tan.gs.test.ts +3 -3
- package/gs/math/tanh.gs.test.ts +1 -1
- package/gs/os/index.ts +128 -19
- package/gs/reflect/ANALYSIS.md +278 -0
- package/gs/reflect/deepequal.test.ts +41 -0
- package/gs/reflect/deepequal.ts +169 -0
- package/gs/reflect/function-types.test.ts +146 -0
- package/gs/reflect/godoc.txt +67 -0
- package/gs/reflect/index.ts +83 -0
- package/gs/reflect/iter.ts +44 -0
- package/gs/reflect/map.test.ts +30 -0
- package/gs/reflect/map.ts +85 -0
- package/gs/reflect/swapper.ts +52 -0
- package/gs/reflect/type.ts +1016 -0
- package/gs/reflect/types.ts +214 -0
- package/gs/reflect/value.ts +270 -0
- package/gs/reflect/visiblefields.ts +177 -0
- package/gs/strconv/index.ts +39 -6
- package/gs/strings/index.ts +7 -1
- package/gs/strings/replace.ts +1 -9
- package/gs/sync/atomic/index.ts +53 -4
- package/gs/syscall/index.ts +45 -37
- package/gs/unicode/utf8/utf8.ts +8 -5
- package/gs/unsafe/unsafe.ts +1 -1
- package/package.json +2 -1
- package/dist/gs/internal/testlog/index.d.ts +0 -1
- package/dist/gs/internal/testlog/index.js +0 -5
- package/dist/gs/internal/testlog/index.js.map +0 -1
- package/dist/gs/maps/iter.gs.d.ts +0 -7
- package/dist/gs/maps/iter.gs.js +0 -65
- package/dist/gs/maps/iter.gs.js.map +0 -1
- package/dist/gs/maps/maps.gs.d.ts +0 -7
- package/dist/gs/maps/maps.gs.js +0 -79
- package/dist/gs/maps/maps.gs.js.map +0 -1
- package/dist/gs/stringslite/index.d.ts +0 -1
- package/dist/gs/stringslite/index.js +0 -2
- package/dist/gs/stringslite/index.js.map +0 -1
- package/dist/gs/stringslite/strings.d.ts +0 -11
- package/dist/gs/stringslite/strings.js +0 -67
- package/dist/gs/stringslite/strings.js.map +0 -1
- package/gs/internal/testlog/index.ts +0 -7
package/gs/strings/index.ts
CHANGED
|
@@ -2,5 +2,11 @@ export * from './builder.js'
|
|
|
2
2
|
export * from './strings.js'
|
|
3
3
|
export * from './reader.js'
|
|
4
4
|
export { Replacer, NewReplacer } from './replace.js'
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
Lines,
|
|
7
|
+
FieldsSeq,
|
|
8
|
+
FieldsFuncSeq,
|
|
9
|
+
SplitSeq,
|
|
10
|
+
SplitAfterSeq,
|
|
11
|
+
} from './iter.js'
|
|
6
12
|
// Clone and Compare are already exported from strings.js, so we don't re-export them
|
package/gs/strings/replace.ts
CHANGED
|
@@ -434,8 +434,6 @@ class trieNode {
|
|
|
434
434
|
t!.next!.add('', val, priority, r)
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
437
|
}
|
|
440
438
|
|
|
441
439
|
class genericReplacer {
|
|
@@ -625,9 +623,7 @@ class genericReplacer {
|
|
|
625
623
|
}
|
|
626
624
|
}
|
|
627
625
|
|
|
628
|
-
function makeGenericReplacer(
|
|
629
|
-
oldnew: $.Slice<string>,
|
|
630
|
-
): genericReplacer | null {
|
|
626
|
+
function makeGenericReplacer(oldnew: $.Slice<string>): genericReplacer | null {
|
|
631
627
|
let r = new genericReplacer()
|
|
632
628
|
// Find each byte used, then assign them each an index.
|
|
633
629
|
for (let i = 0; i < $.len(oldnew); i += 2) {
|
|
@@ -789,8 +785,6 @@ class singleStringReplacer {
|
|
|
789
785
|
n += wn
|
|
790
786
|
return [n, err]
|
|
791
787
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
788
|
}
|
|
795
789
|
|
|
796
790
|
function makeSingleStringReplacer(
|
|
@@ -1065,8 +1059,6 @@ class byteStringReplacer {
|
|
|
1065
1059
|
}
|
|
1066
1060
|
return [n, err]
|
|
1067
1061
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
1062
|
}
|
|
1071
1063
|
|
|
1072
1064
|
// Helper function to copy bytes
|
package/gs/sync/atomic/index.ts
CHANGED
|
@@ -1,4 +1,53 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export {
|
|
2
|
+
AddInt32,
|
|
3
|
+
AddUint32,
|
|
4
|
+
AddUintptr,
|
|
5
|
+
AndInt32,
|
|
6
|
+
AndUint32,
|
|
7
|
+
AndUintptr,
|
|
8
|
+
CompareAndSwapInt32,
|
|
9
|
+
CompareAndSwapPointer,
|
|
10
|
+
CompareAndSwapUint32,
|
|
11
|
+
CompareAndSwapUintptr,
|
|
12
|
+
LoadInt32,
|
|
13
|
+
LoadPointer,
|
|
14
|
+
LoadUint32,
|
|
15
|
+
LoadUintptr,
|
|
16
|
+
OrInt32,
|
|
17
|
+
OrUint32,
|
|
18
|
+
OrUintptr,
|
|
19
|
+
StoreInt32,
|
|
20
|
+
StorePointer,
|
|
21
|
+
StoreUint32,
|
|
22
|
+
StoreUintptr,
|
|
23
|
+
SwapInt32,
|
|
24
|
+
SwapPointer,
|
|
25
|
+
SwapUint32,
|
|
26
|
+
SwapUintptr,
|
|
27
|
+
} from './doc.gs.js'
|
|
28
|
+
export {
|
|
29
|
+
AddInt64,
|
|
30
|
+
AddUint64,
|
|
31
|
+
AndInt64,
|
|
32
|
+
AndUint64,
|
|
33
|
+
CompareAndSwapInt64,
|
|
34
|
+
CompareAndSwapUint64,
|
|
35
|
+
LoadInt64,
|
|
36
|
+
LoadUint64,
|
|
37
|
+
OrInt64,
|
|
38
|
+
OrUint64,
|
|
39
|
+
StoreInt64,
|
|
40
|
+
StoreUint64,
|
|
41
|
+
SwapInt64,
|
|
42
|
+
SwapUint64,
|
|
43
|
+
} from './doc_64.gs.js'
|
|
44
|
+
export {
|
|
45
|
+
Bool,
|
|
46
|
+
Int32,
|
|
47
|
+
Int64,
|
|
48
|
+
Pointer,
|
|
49
|
+
Uint32,
|
|
50
|
+
Uint64,
|
|
51
|
+
Uintptr,
|
|
52
|
+
} from './type.gs.js'
|
|
53
|
+
export { Value } from './value.gs.js'
|
package/gs/syscall/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as $ from
|
|
1
|
+
import * as $ from '@goscript/builtin/builtin.js'
|
|
2
2
|
|
|
3
3
|
// Essential type aliases
|
|
4
4
|
export type uintptr = number
|
|
@@ -27,7 +27,7 @@ export const Stderr = 2
|
|
|
27
27
|
export const SIGINT = 2
|
|
28
28
|
export const SIGTERM = 15
|
|
29
29
|
|
|
30
|
-
// File mode constants
|
|
30
|
+
// File mode constants
|
|
31
31
|
export const S_IFMT = 0o170000
|
|
32
32
|
export const S_IFREG = 0o100000
|
|
33
33
|
export const S_IFDIR = 0o040000
|
|
@@ -44,9 +44,9 @@ export const S_ISVTX = 0o001000
|
|
|
44
44
|
export function Getenv(key: string): [string, boolean] {
|
|
45
45
|
if (typeof process !== 'undefined' && process.env) {
|
|
46
46
|
const value = process.env[key]
|
|
47
|
-
return value !== undefined ? [value, true] : [
|
|
47
|
+
return value !== undefined ? [value, true] : ['', false]
|
|
48
48
|
}
|
|
49
|
-
return [
|
|
49
|
+
return ['', false]
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function Setenv(key: string, value: string): $.GoError {
|
|
@@ -54,7 +54,7 @@ export function Setenv(key: string, value: string): $.GoError {
|
|
|
54
54
|
process.env[key] = value
|
|
55
55
|
return null
|
|
56
56
|
}
|
|
57
|
-
return { Error: () =>
|
|
57
|
+
return { Error: () => 'setenv not supported' }
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function Unsetenv(key: string): $.GoError {
|
|
@@ -62,7 +62,7 @@ export function Unsetenv(key: string): $.GoError {
|
|
|
62
62
|
delete process.env[key]
|
|
63
63
|
return null
|
|
64
64
|
}
|
|
65
|
-
return { Error: () =>
|
|
65
|
+
return { Error: () => 'unsetenv not supported' }
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export function Clearenv(): void {
|
|
@@ -96,10 +96,10 @@ export class Dirent {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// Stat_t structure stub
|
|
99
|
+
// Stat_t structure stub
|
|
100
100
|
export class Stat_t {
|
|
101
101
|
public Dev: number = 0
|
|
102
|
-
public Ino: number = 0
|
|
102
|
+
public Ino: number = 0
|
|
103
103
|
public Mode: number = 0
|
|
104
104
|
public Nlink: number = 0
|
|
105
105
|
public Uid: number = 0
|
|
@@ -114,13 +114,13 @@ export class Stat_t {
|
|
|
114
114
|
public AtimeNsec: number = 0
|
|
115
115
|
public MtimeNsec: number = 0
|
|
116
116
|
public CtimeNsec: number = 0
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
constructor(init?: any) {
|
|
119
119
|
if (init) {
|
|
120
120
|
Object.assign(this, init)
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
public clone(): Stat_t {
|
|
125
125
|
return new Stat_t(this)
|
|
126
126
|
}
|
|
@@ -129,76 +129,84 @@ export class Stat_t {
|
|
|
129
129
|
// RawConn interface - stub implementation for JavaScript environment
|
|
130
130
|
export interface RawConn {
|
|
131
131
|
Control(f: (fd: uintptr) => void): $.GoError
|
|
132
|
-
Read(f: (fd: uintptr) => boolean): $.GoError
|
|
132
|
+
Read(f: (fd: uintptr) => boolean): $.GoError
|
|
133
133
|
Write(f: (fd: uintptr) => boolean): $.GoError
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// Stub implementation of RawConn that always returns ErrUnimplemented
|
|
137
137
|
export class StubRawConn implements RawConn {
|
|
138
|
-
Control(
|
|
139
|
-
return {
|
|
138
|
+
Control(_f: (fd: uintptr) => void): $.GoError {
|
|
139
|
+
return {
|
|
140
|
+
Error: () => 'operation not implemented in JavaScript environment',
|
|
141
|
+
}
|
|
140
142
|
}
|
|
141
|
-
|
|
142
|
-
Read(
|
|
143
|
-
return {
|
|
143
|
+
|
|
144
|
+
Read(_f: (fd: uintptr) => boolean): $.GoError {
|
|
145
|
+
return {
|
|
146
|
+
Error: () => 'operation not implemented in JavaScript environment',
|
|
147
|
+
}
|
|
144
148
|
}
|
|
145
|
-
|
|
146
|
-
Write(
|
|
147
|
-
return {
|
|
149
|
+
|
|
150
|
+
Write(_f: (fd: uintptr) => boolean): $.GoError {
|
|
151
|
+
return {
|
|
152
|
+
Error: () => 'operation not implemented in JavaScript environment',
|
|
153
|
+
}
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
// Additional error constants - implement as Errno type
|
|
152
158
|
export const ENOSYS: Errno = {
|
|
153
|
-
Error: () =>
|
|
159
|
+
Error: () => 'function not implemented',
|
|
154
160
|
Is: (target: $.GoError) => target === ENOSYS,
|
|
155
|
-
Errno: () => 38
|
|
161
|
+
Errno: () => 38,
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
export const EISDIR: Errno = {
|
|
159
|
-
Error: () =>
|
|
165
|
+
Error: () => 'is a directory',
|
|
160
166
|
Is: (target: $.GoError) => target === EISDIR,
|
|
161
|
-
Errno: () => 21
|
|
167
|
+
Errno: () => 21,
|
|
162
168
|
}
|
|
163
169
|
|
|
164
170
|
export const ENOTDIR: Errno = {
|
|
165
|
-
Error: () =>
|
|
171
|
+
Error: () => 'not a directory',
|
|
166
172
|
Is: (target: $.GoError) => target === ENOTDIR,
|
|
167
|
-
Errno: () => 20
|
|
173
|
+
Errno: () => 20,
|
|
168
174
|
}
|
|
169
175
|
|
|
170
176
|
export const ERANGE: Errno = {
|
|
171
|
-
Error: () =>
|
|
177
|
+
Error: () => 'result too large',
|
|
172
178
|
Is: (target: $.GoError) => target === ERANGE,
|
|
173
|
-
Errno: () => 34
|
|
179
|
+
Errno: () => 34,
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
export const ENOMEM: Errno = {
|
|
177
|
-
Error: () =>
|
|
183
|
+
Error: () => 'out of memory',
|
|
178
184
|
Is: (target: $.GoError) => target === ENOMEM,
|
|
179
|
-
Errno: () => 12
|
|
185
|
+
Errno: () => 12,
|
|
180
186
|
}
|
|
181
187
|
|
|
182
188
|
export const ESRCH: Errno = {
|
|
183
|
-
Error: () =>
|
|
189
|
+
Error: () => 'no such process',
|
|
184
190
|
Is: (target: $.GoError) => target === ESRCH,
|
|
185
|
-
Errno: () => 3
|
|
191
|
+
Errno: () => 3,
|
|
186
192
|
}
|
|
187
193
|
|
|
188
194
|
// Additional missing syscall functions
|
|
189
|
-
export function Open(
|
|
195
|
+
export function Open(
|
|
196
|
+
_path: string,
|
|
197
|
+
_flag: number,
|
|
198
|
+
_perm: number,
|
|
199
|
+
): [number, $.GoError] {
|
|
190
200
|
return [-1, ENOSYS]
|
|
191
201
|
}
|
|
192
202
|
|
|
193
|
-
export function Sysctl(
|
|
194
|
-
return [
|
|
203
|
+
export function Sysctl(_name: string): [string, $.GoError] {
|
|
204
|
+
return ['', ENOSYS]
|
|
195
205
|
}
|
|
196
206
|
|
|
197
|
-
|
|
198
|
-
|
|
199
207
|
// Getpagesize returns the underlying system's memory page size.
|
|
200
208
|
export function Getpagesize(): number {
|
|
201
209
|
// Return a standard page size for JavaScript environment
|
|
202
210
|
// Most systems use 4096 bytes as the default page size
|
|
203
211
|
return 4096
|
|
204
|
-
}
|
|
212
|
+
}
|
package/gs/unicode/utf8/utf8.ts
CHANGED
|
@@ -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:
|
|
67
|
-
if (p
|
|
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(
|
|
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/gs/unsafe/unsafe.ts
CHANGED
|
@@ -79,5 +79,5 @@ export function StringData(_str: string): Pointer {
|
|
|
79
79
|
// Pointer converts a value to an unsafe.Pointer for atomic operations
|
|
80
80
|
// In JavaScript/TypeScript, this is just a pass-through function
|
|
81
81
|
export function Pointer(value: any): Pointer {
|
|
82
|
-
return value
|
|
82
|
+
return value
|
|
83
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.
|
|
4
|
+
"version": "0.0.39",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aperture Robotics LLC.",
|
|
7
7
|
"email": "support@aperture.us",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"lint": "npm run lint:go && npm run lint:js",
|
|
64
64
|
"lint:go": "make lint",
|
|
65
65
|
"lint:js": "eslint -c eslint.config.mjs ./",
|
|
66
|
+
"lint:js:fix": "eslint -c eslint.config.mjs ./ --fix",
|
|
66
67
|
"prepare": "husky",
|
|
67
68
|
"precommit": "lint-staged"
|
|
68
69
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function Getenv(key: string): void;
|
|
@@ -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>;
|
package/dist/gs/maps/iter.gs.js
DELETED
|
@@ -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,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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;
|
package/dist/gs/maps/maps.gs.js
DELETED
|
@@ -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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C,CAAC;YACA,IAAI,GAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBAChB,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACvB,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './strings';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/stringslite/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare function HasPrefix(s: string, prefix: string): boolean;
|
|
2
|
-
export declare function HasSuffix(s: string, suffix: string): boolean;
|
|
3
|
-
export declare function IndexByte(s: string, c: number): number;
|
|
4
|
-
export declare function Index(s: string, substr: string): number;
|
|
5
|
-
export declare function Cut(s: string, sep: string): [string, string, boolean];
|
|
6
|
-
export declare function CutPrefix(s: string, prefix: string): [string, boolean];
|
|
7
|
-
export declare function CutSuffix(s: string, suffix: string): [string, boolean];
|
|
8
|
-
export declare function TrimPrefix(s: string, prefix: string): string;
|
|
9
|
-
export declare function TrimSuffix(s: string, suffix: string): string;
|
|
10
|
-
export declare function Clone(s: string): string;
|
|
11
|
-
export declare function CopyBytes(b: Uint8Array, s: string): number;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as $ from '@goscript/builtin/builtin.js';
|
|
2
|
-
import * as unsafe from '@goscript/unsafe/index.js';
|
|
3
|
-
export function HasPrefix(s, prefix) {
|
|
4
|
-
return ($.len(s) >= $.len(prefix) &&
|
|
5
|
-
$.sliceString(s, undefined, $.len(prefix)) == prefix);
|
|
6
|
-
}
|
|
7
|
-
export function HasSuffix(s, suffix) {
|
|
8
|
-
return ($.len(s) >= $.len(suffix) &&
|
|
9
|
-
$.sliceString(s, $.len(s) - $.len(suffix), undefined) == suffix);
|
|
10
|
-
}
|
|
11
|
-
export function IndexByte(s, c) {
|
|
12
|
-
const char = String.fromCharCode(c);
|
|
13
|
-
return s.indexOf(char);
|
|
14
|
-
}
|
|
15
|
-
export function Index(s, substr) {
|
|
16
|
-
if (substr === '') {
|
|
17
|
-
return 0;
|
|
18
|
-
}
|
|
19
|
-
return s.indexOf(substr);
|
|
20
|
-
}
|
|
21
|
-
export function Cut(s, sep) {
|
|
22
|
-
let i = Index(s, sep);
|
|
23
|
-
if (i >= 0) {
|
|
24
|
-
return [
|
|
25
|
-
$.sliceString(s, undefined, i),
|
|
26
|
-
$.sliceString(s, i + $.len(sep), undefined),
|
|
27
|
-
true,
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
return [s, '', false];
|
|
31
|
-
}
|
|
32
|
-
export function CutPrefix(s, prefix) {
|
|
33
|
-
if (!HasPrefix(s, prefix)) {
|
|
34
|
-
return [s, false];
|
|
35
|
-
}
|
|
36
|
-
return [$.sliceString(s, $.len(prefix), undefined), true];
|
|
37
|
-
}
|
|
38
|
-
export function CutSuffix(s, suffix) {
|
|
39
|
-
if (!HasSuffix(s, suffix)) {
|
|
40
|
-
return [s, false];
|
|
41
|
-
}
|
|
42
|
-
return [$.sliceString(s, undefined, $.len(s) - $.len(suffix)), true];
|
|
43
|
-
}
|
|
44
|
-
export function TrimPrefix(s, prefix) {
|
|
45
|
-
if (HasPrefix(s, prefix)) {
|
|
46
|
-
return $.sliceString(s, $.len(prefix), undefined);
|
|
47
|
-
}
|
|
48
|
-
return s;
|
|
49
|
-
}
|
|
50
|
-
export function TrimSuffix(s, suffix) {
|
|
51
|
-
if (HasSuffix(s, suffix)) {
|
|
52
|
-
return $.sliceString(s, undefined, $.len(s) - $.len(suffix));
|
|
53
|
-
}
|
|
54
|
-
return s;
|
|
55
|
-
}
|
|
56
|
-
export function Clone(s) {
|
|
57
|
-
if ($.len(s) == 0) {
|
|
58
|
-
return '';
|
|
59
|
-
}
|
|
60
|
-
let b = new Uint8Array($.len(s));
|
|
61
|
-
$.copy(b, s);
|
|
62
|
-
return unsafe.String(b[0], $.len(b));
|
|
63
|
-
}
|
|
64
|
-
export function CopyBytes(b, s) {
|
|
65
|
-
return $.copy(b, s);
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=strings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../gs/stringslite/strings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAA;AAEjD,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAA;AAEnD,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,MAAc;IACjD,OAAO,CACL,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QACzB,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CACrD,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,MAAc;IACjD,OAAO,CACL,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QACzB,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,IAAI,MAAM,CAChE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,CAAS;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IACnC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,CAAS,EAAE,MAAc;IAC7C,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QAClB,OAAO,CAAC,CAAA;IACV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