goscript 0.0.50 → 0.0.51
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 +18 -4
- package/compiler/compiler.go +8 -4
- package/compiler/expr-call-async.go +218 -13
- package/compiler/sanitize.go +1 -2
- package/compiler/spec-struct.go +3 -3
- package/compiler/spec.go +0 -21
- package/compiler/stmt-select.go +52 -1
- package/compiler/type.go +3 -3
- package/dist/gs/builtin/channel.d.ts +2 -2
- package/dist/gs/builtin/channel.js +12 -7
- package/dist/gs/builtin/channel.js.map +1 -1
- package/dist/gs/syscall/constants.d.ts +24 -0
- package/dist/gs/syscall/constants.js +27 -0
- package/dist/gs/syscall/constants.js.map +1 -0
- package/dist/gs/syscall/env.d.ts +6 -0
- package/dist/gs/syscall/env.js +43 -0
- package/dist/gs/syscall/env.js.map +1 -0
- package/dist/gs/syscall/errors.d.ts +111 -0
- package/dist/gs/syscall/errors.js +547 -0
- package/dist/gs/syscall/errors.js.map +1 -0
- package/dist/gs/syscall/fs.d.ts +29 -0
- package/dist/gs/syscall/fs.js +53 -0
- package/dist/gs/syscall/fs.js.map +1 -0
- package/dist/gs/syscall/index.d.ts +6 -80
- package/dist/gs/syscall/index.js +12 -168
- package/dist/gs/syscall/index.js.map +1 -1
- package/dist/gs/syscall/rawconn.d.ts +7 -0
- package/dist/gs/syscall/rawconn.js +19 -0
- package/dist/gs/syscall/rawconn.js.map +1 -0
- package/dist/gs/syscall/types.d.ts +12 -0
- package/dist/gs/syscall/types.js +2 -0
- package/dist/gs/syscall/types.js.map +1 -0
- package/gs/builtin/channel.ts +18 -12
- package/gs/syscall/constants.ts +29 -0
- package/gs/syscall/env.ts +47 -0
- package/gs/syscall/errors.ts +658 -0
- package/gs/syscall/fs.ts +62 -0
- package/gs/syscall/index.ts +12 -207
- package/gs/syscall/rawconn.ts +23 -0
- package/gs/syscall/types.ts +18 -0
- package/package.json +1 -1
package/gs/syscall/index.ts
CHANGED
|
@@ -1,212 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// Re-export all types
|
|
2
|
+
export * from './types.js'
|
|
2
3
|
|
|
3
|
-
//
|
|
4
|
-
export
|
|
4
|
+
// Re-export all constants
|
|
5
|
+
export * from './constants.js'
|
|
5
6
|
|
|
6
|
-
//
|
|
7
|
-
export
|
|
8
|
-
Error(): string
|
|
9
|
-
Is(target: $.GoError): boolean
|
|
10
|
-
Errno(): number
|
|
11
|
-
}
|
|
7
|
+
// Re-export environment functions
|
|
8
|
+
export * from './env.js'
|
|
12
9
|
|
|
13
|
-
//
|
|
14
|
-
export
|
|
15
|
-
export const O_WRONLY = 1
|
|
16
|
-
export const O_RDWR = 2
|
|
17
|
-
export const O_APPEND = 8
|
|
18
|
-
export const O_CREATE = 64
|
|
19
|
-
export const O_EXCL = 128
|
|
20
|
-
export const O_SYNC = 256
|
|
21
|
-
export const O_TRUNC = 512
|
|
10
|
+
// Re-export file system structures and functions
|
|
11
|
+
export * from './fs.js'
|
|
22
12
|
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export const Stderr = 2
|
|
13
|
+
// Re-export error constants
|
|
14
|
+
export * from './errors.js'
|
|
26
15
|
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
// File mode constants
|
|
31
|
-
export const S_IFMT = 0o170000
|
|
32
|
-
export const S_IFREG = 0o100000
|
|
33
|
-
export const S_IFDIR = 0o040000
|
|
34
|
-
export const S_IFLNK = 0o120000
|
|
35
|
-
export const S_IFBLK = 0o060000
|
|
36
|
-
export const S_IFCHR = 0o020000
|
|
37
|
-
export const S_IFIFO = 0o010000
|
|
38
|
-
export const S_IFSOCK = 0o140000
|
|
39
|
-
export const S_ISUID = 0o004000
|
|
40
|
-
export const S_ISGID = 0o002000
|
|
41
|
-
export const S_ISVTX = 0o001000
|
|
42
|
-
|
|
43
|
-
// Environment variable functions using Node.js/browser APIs
|
|
44
|
-
export function Getenv(key: string): [string, boolean] {
|
|
45
|
-
if (typeof process !== 'undefined' && process.env) {
|
|
46
|
-
const value = process.env[key]
|
|
47
|
-
return value !== undefined ? [value, true] : ['', false]
|
|
48
|
-
}
|
|
49
|
-
return ['', false]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function Setenv(key: string, value: string): $.GoError {
|
|
53
|
-
if (typeof process !== 'undefined' && process.env) {
|
|
54
|
-
process.env[key] = value
|
|
55
|
-
return null
|
|
56
|
-
}
|
|
57
|
-
return { Error: () => 'setenv not supported' }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function Unsetenv(key: string): $.GoError {
|
|
61
|
-
if (typeof process !== 'undefined' && process.env) {
|
|
62
|
-
delete process.env[key]
|
|
63
|
-
return null
|
|
64
|
-
}
|
|
65
|
-
return { Error: () => 'unsetenv not supported' }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function Clearenv(): void {
|
|
69
|
-
if (typeof process !== 'undefined' && process.env) {
|
|
70
|
-
for (const key in process.env) {
|
|
71
|
-
delete process.env[key]
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function Environ(): $.Slice<string> {
|
|
77
|
-
if (typeof process !== 'undefined' && process.env) {
|
|
78
|
-
const env: string[] = []
|
|
79
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
80
|
-
if (value !== undefined) {
|
|
81
|
-
env.push(`${key}=${value}`)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return $.arrayToSlice(env)
|
|
85
|
-
}
|
|
86
|
-
return $.arrayToSlice([])
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Dirent structure with Reclen field
|
|
90
|
-
export class Dirent {
|
|
91
|
-
public Name: $.Bytes = new Uint8Array(0)
|
|
92
|
-
public Reclen: number = 0
|
|
93
|
-
constructor(init?: any) {
|
|
94
|
-
if (init?.Name) this.Name = init.Name
|
|
95
|
-
if (init?.Reclen) this.Reclen = init.Reclen
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Stat_t structure stub
|
|
100
|
-
export class Stat_t {
|
|
101
|
-
public Dev: number = 0
|
|
102
|
-
public Ino: number = 0
|
|
103
|
-
public Mode: number = 0
|
|
104
|
-
public Nlink: number = 0
|
|
105
|
-
public Uid: number = 0
|
|
106
|
-
public Gid: number = 0
|
|
107
|
-
public Rdev: number = 0
|
|
108
|
-
public Size: number = 0
|
|
109
|
-
public Blksize: number = 0
|
|
110
|
-
public Blocks: number = 0
|
|
111
|
-
public Atime: number = 0
|
|
112
|
-
public Mtime: number = 0
|
|
113
|
-
public Ctime: number = 0
|
|
114
|
-
public AtimeNsec: number = 0
|
|
115
|
-
public MtimeNsec: number = 0
|
|
116
|
-
public CtimeNsec: number = 0
|
|
117
|
-
|
|
118
|
-
constructor(init?: any) {
|
|
119
|
-
if (init) {
|
|
120
|
-
Object.assign(this, init)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public clone(): Stat_t {
|
|
125
|
-
return new Stat_t(this)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// RawConn interface - stub implementation for JavaScript environment
|
|
130
|
-
export interface RawConn {
|
|
131
|
-
Control(f: (fd: uintptr) => void): $.GoError
|
|
132
|
-
Read(f: (fd: uintptr) => boolean): $.GoError
|
|
133
|
-
Write(f: (fd: uintptr) => boolean): $.GoError
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Stub implementation of RawConn that always returns ErrUnimplemented
|
|
137
|
-
export class StubRawConn implements RawConn {
|
|
138
|
-
Control(_f: (fd: uintptr) => void): $.GoError {
|
|
139
|
-
return {
|
|
140
|
-
Error: () => 'operation not implemented in JavaScript environment',
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
Read(_f: (fd: uintptr) => boolean): $.GoError {
|
|
145
|
-
return {
|
|
146
|
-
Error: () => 'operation not implemented in JavaScript environment',
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
Write(_f: (fd: uintptr) => boolean): $.GoError {
|
|
151
|
-
return {
|
|
152
|
-
Error: () => 'operation not implemented in JavaScript environment',
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Additional error constants - implement as Errno type
|
|
158
|
-
export const ENOSYS: Errno = {
|
|
159
|
-
Error: () => 'function not implemented',
|
|
160
|
-
Is: (target: $.GoError) => target === ENOSYS,
|
|
161
|
-
Errno: () => 38,
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export const EISDIR: Errno = {
|
|
165
|
-
Error: () => 'is a directory',
|
|
166
|
-
Is: (target: $.GoError) => target === EISDIR,
|
|
167
|
-
Errno: () => 21,
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export const ENOTDIR: Errno = {
|
|
171
|
-
Error: () => 'not a directory',
|
|
172
|
-
Is: (target: $.GoError) => target === ENOTDIR,
|
|
173
|
-
Errno: () => 20,
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export const ERANGE: Errno = {
|
|
177
|
-
Error: () => 'result too large',
|
|
178
|
-
Is: (target: $.GoError) => target === ERANGE,
|
|
179
|
-
Errno: () => 34,
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export const ENOMEM: Errno = {
|
|
183
|
-
Error: () => 'out of memory',
|
|
184
|
-
Is: (target: $.GoError) => target === ENOMEM,
|
|
185
|
-
Errno: () => 12,
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export const ESRCH: Errno = {
|
|
189
|
-
Error: () => 'no such process',
|
|
190
|
-
Is: (target: $.GoError) => target === ESRCH,
|
|
191
|
-
Errno: () => 3,
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Additional missing syscall functions
|
|
195
|
-
export function Open(
|
|
196
|
-
_path: string,
|
|
197
|
-
_flag: number,
|
|
198
|
-
_perm: number,
|
|
199
|
-
): [number, $.GoError] {
|
|
200
|
-
return [-1, ENOSYS]
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function Sysctl(_name: string): [string, $.GoError] {
|
|
204
|
-
return ['', ENOSYS]
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Getpagesize returns the underlying system's memory page size.
|
|
208
|
-
export function Getpagesize(): number {
|
|
209
|
-
// Return a standard page size for JavaScript environment
|
|
210
|
-
// Most systems use 4096 bytes as the default page size
|
|
211
|
-
return 4096
|
|
212
|
-
}
|
|
16
|
+
// Re-export RawConn implementation
|
|
17
|
+
export * from './rawconn.js'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as $ from '@goscript/builtin/index.js'
|
|
2
|
+
import { RawConn, uintptr } from './types.js'
|
|
3
|
+
|
|
4
|
+
// Stub implementation of RawConn that always returns ErrUnimplemented
|
|
5
|
+
export class StubRawConn implements RawConn {
|
|
6
|
+
Control(_f: (fd: uintptr) => void): $.GoError {
|
|
7
|
+
return {
|
|
8
|
+
Error: () => 'operation not implemented in JavaScript environment',
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Read(_f: (fd: uintptr) => boolean): $.GoError {
|
|
13
|
+
return {
|
|
14
|
+
Error: () => 'operation not implemented in JavaScript environment',
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Write(_f: (fd: uintptr) => boolean): $.GoError {
|
|
19
|
+
return {
|
|
20
|
+
Error: () => 'operation not implemented in JavaScript environment',
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as $ from '@goscript/builtin/index.js'
|
|
2
|
+
|
|
3
|
+
// Essential type aliases
|
|
4
|
+
export type uintptr = number
|
|
5
|
+
|
|
6
|
+
// Errno type for syscall errors
|
|
7
|
+
export interface Errno {
|
|
8
|
+
Error(): string
|
|
9
|
+
Is(target: $.GoError): boolean
|
|
10
|
+
Errno(): number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// RawConn interface - stub implementation for JavaScript environment
|
|
14
|
+
export interface RawConn {
|
|
15
|
+
Control(f: (fd: uintptr) => void): $.GoError
|
|
16
|
+
Read(f: (fd: uintptr) => boolean): $.GoError
|
|
17
|
+
Write(f: (fd: uintptr) => boolean): $.GoError
|
|
18
|
+
}
|