goscript 0.0.35 → 0.0.37
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/expr-call.go +26 -0
- package/compiler/spec-struct.go +41 -8
- package/compiler/spec-value.go +4 -0
- package/compiler/spec.go +1 -1
- package/compiler/stmt.go +26 -8
- package/dist/gs/internal/byteorder/index.d.ts +8 -0
- package/dist/gs/internal/byteorder/index.js +34 -0
- package/dist/gs/internal/byteorder/index.js.map +1 -0
- package/dist/gs/internal/testlog/index.d.ts +1 -0
- package/dist/gs/internal/testlog/index.js +5 -0
- package/dist/gs/internal/testlog/index.js.map +1 -0
- package/dist/gs/maps/iter.d.ts +1 -1
- package/dist/gs/os/dir.gs.d.ts +6 -0
- package/dist/gs/os/dir.gs.js +35 -0
- package/dist/gs/os/dir.gs.js.map +1 -0
- package/dist/gs/os/dir_unix.gs.d.ts +7 -0
- package/dist/gs/os/dir_unix.gs.js +113 -0
- package/dist/gs/os/dir_unix.gs.js.map +1 -0
- package/dist/gs/os/dirent_js.gs.d.ts +5 -0
- package/dist/gs/os/dirent_js.gs.js +20 -0
- package/dist/gs/os/dirent_js.gs.js.map +1 -0
- package/dist/gs/os/env.gs.d.ts +12 -0
- package/dist/gs/os/env.gs.js +157 -0
- package/dist/gs/os/env.gs.js.map +1 -0
- package/dist/gs/os/error.gs.d.ts +40 -0
- package/dist/gs/os/error.gs.js +158 -0
- package/dist/gs/os/error.gs.js.map +1 -0
- package/dist/gs/os/error_errno.gs.d.ts +1 -0
- package/dist/gs/os/error_errno.gs.js +5 -0
- package/dist/gs/os/error_errno.gs.js.map +1 -0
- package/dist/gs/os/exec.gs.d.ts +60 -0
- package/dist/gs/os/exec.gs.js +136 -0
- package/dist/gs/os/exec.gs.js.map +1 -0
- package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
- package/dist/gs/os/exec_nohandle.gs.js +2 -0
- package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
- package/dist/gs/os/exec_posix.gs.d.ts +25 -0
- package/dist/gs/os/exec_posix.gs.js +67 -0
- package/dist/gs/os/exec_posix.gs.js.map +1 -0
- package/dist/gs/os/exec_unix.gs.d.ts +4 -0
- package/dist/gs/os/exec_unix.gs.js +46 -0
- package/dist/gs/os/exec_unix.gs.js.map +1 -0
- package/dist/gs/os/executable.gs.d.ts +2 -0
- package/dist/gs/os/executable.gs.js +16 -0
- package/dist/gs/os/executable.gs.js.map +1 -0
- package/dist/gs/os/executable_js.gs.d.ts +2 -0
- package/dist/gs/os/executable_js.gs.js +5 -0
- package/dist/gs/os/executable_js.gs.js.map +1 -0
- package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
- package/dist/gs/os/executable_wasm.gs.js +6 -0
- package/dist/gs/os/executable_wasm.gs.js.map +1 -0
- package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
- package/dist/gs/os/file_constants_js.gs.js +78 -0
- package/dist/gs/os/file_constants_js.gs.js.map +1 -0
- package/dist/gs/os/file_js.gs.d.ts +22 -0
- package/dist/gs/os/file_js.gs.js +73 -0
- package/dist/gs/os/file_js.gs.js.map +1 -0
- package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
- package/dist/gs/os/file_open_unix.gs.js +10 -0
- package/dist/gs/os/file_open_unix.gs.js.map +1 -0
- package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
- package/dist/gs/os/file_posix_js.gs.js +32 -0
- package/dist/gs/os/file_posix_js.gs.js.map +1 -0
- package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
- package/dist/gs/os/file_unix_js.gs.js +64 -0
- package/dist/gs/os/file_unix_js.gs.js.map +1 -0
- package/dist/gs/os/getwd_js.gs.d.ts +6 -0
- package/dist/gs/os/getwd_js.gs.js +21 -0
- package/dist/gs/os/getwd_js.gs.js.map +1 -0
- package/dist/gs/os/index.d.ts +19 -0
- package/dist/gs/os/index.js +20 -0
- package/dist/gs/os/index.js.map +1 -0
- package/dist/gs/os/path.gs.d.ts +4 -0
- package/dist/gs/os/path.gs.js +32 -0
- package/dist/gs/os/path.gs.js.map +1 -0
- package/dist/gs/os/path_unix.gs.d.ts +4 -0
- package/dist/gs/os/path_unix.gs.js +40 -0
- package/dist/gs/os/path_unix.gs.js.map +1 -0
- package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
- package/dist/gs/os/pidfd_js.gs.js +14 -0
- package/dist/gs/os/pidfd_js.gs.js.map +1 -0
- package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
- package/dist/gs/os/pipe_wasm.gs.js +14 -0
- package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
- package/dist/gs/os/proc.gs.d.ts +11 -0
- package/dist/gs/os/proc.gs.js +68 -0
- package/dist/gs/os/proc.gs.js.map +1 -0
- package/dist/gs/os/proc_js.gs.d.ts +3 -0
- package/dist/gs/os/proc_js.gs.js +12 -0
- package/dist/gs/os/proc_js.gs.js.map +1 -0
- package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
- package/dist/gs/os/rawconn_js.gs.js +26 -0
- package/dist/gs/os/rawconn_js.gs.js.map +1 -0
- package/dist/gs/os/removeall_js.gs.d.ts +2 -0
- package/dist/gs/os/removeall_js.gs.js +7 -0
- package/dist/gs/os/removeall_js.gs.js.map +1 -0
- package/dist/gs/os/root_js.gs.d.ts +23 -0
- package/dist/gs/os/root_js.gs.js +80 -0
- package/dist/gs/os/root_js.gs.js.map +1 -0
- package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
- package/dist/gs/os/root_nonwindows.gs.js +4 -0
- package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
- package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
- package/dist/gs/os/root_noopenat.gs.js +31 -0
- package/dist/gs/os/root_noopenat.gs.js.map +1 -0
- package/dist/gs/os/stat.gs.d.ts +24 -0
- package/dist/gs/os/stat.gs.js +20 -0
- package/dist/gs/os/stat.gs.js.map +1 -0
- package/dist/gs/os/stat_js.gs.d.ts +6 -0
- package/dist/gs/os/stat_js.gs.js +23 -0
- package/dist/gs/os/stat_js.gs.js.map +1 -0
- package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
- package/dist/gs/os/stat_unix_js.gs.js +16 -0
- package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
- package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
- package/dist/gs/os/sticky_bsd.gs.js +3 -0
- package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys.gs.d.ts +2 -0
- package/dist/gs/os/sys.gs.js +10 -0
- package/dist/gs/os/sys.gs.js.map +1 -0
- package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
- package/dist/gs/os/sys_bsd.gs.js +15 -0
- package/dist/gs/os/sys_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys_js.gs.d.ts +2 -0
- package/dist/gs/os/sys_js.gs.js +6 -0
- package/dist/gs/os/sys_js.gs.js.map +1 -0
- package/dist/gs/os/tempfile.gs.d.ts +5 -0
- package/dist/gs/os/tempfile.gs.js +30 -0
- package/dist/gs/os/tempfile.gs.js.map +1 -0
- package/dist/gs/os/types.gs.d.ts +59 -0
- package/dist/gs/os/types.gs.js +123 -0
- package/dist/gs/os/types.gs.js.map +1 -0
- package/dist/gs/os/types_js.gs.d.ts +74 -0
- package/dist/gs/os/types_js.gs.js +147 -0
- package/dist/gs/os/types_js.gs.js.map +1 -0
- package/dist/gs/os/types_unix.gs.d.ts +40 -0
- package/dist/gs/os/types_unix.gs.js +87 -0
- package/dist/gs/os/types_unix.gs.js.map +1 -0
- package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
- package/dist/gs/os/wait_unimp.gs.js +2 -0
- package/dist/gs/os/wait_unimp.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
- package/dist/gs/os/zero_copy_posix.gs.js +27 -0
- package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
- package/dist/gs/os/zero_copy_stub.gs.js +2 -0
- package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
- package/dist/gs/sync/atomic/doc.gs.d.ts +28 -0
- package/dist/gs/sync/atomic/doc.gs.js +265 -0
- package/dist/gs/sync/atomic/doc.gs.js.map +1 -0
- package/dist/gs/sync/atomic/doc_64.gs.d.ts +15 -0
- package/dist/gs/sync/atomic/doc_64.gs.js +165 -0
- package/dist/gs/sync/atomic/doc_64.gs.js.map +1 -0
- package/dist/gs/sync/atomic/index.d.ts +4 -0
- package/dist/gs/sync/atomic/index.js +5 -0
- package/dist/gs/sync/atomic/index.js.map +1 -0
- package/dist/gs/sync/atomic/type.gs.d.ts +130 -0
- package/dist/gs/sync/atomic/type.gs.js +433 -0
- package/dist/gs/sync/atomic/type.gs.js.map +1 -0
- package/dist/gs/sync/atomic/value.gs.d.ts +19 -0
- package/dist/gs/sync/atomic/value.gs.js +116 -0
- package/dist/gs/sync/atomic/value.gs.js.map +1 -0
- package/dist/gs/syscall/index.d.ts +80 -0
- package/dist/gs/syscall/index.js +163 -0
- package/dist/gs/syscall/index.js.map +1 -0
- package/dist/gs/unsafe/unsafe.d.ts +1 -0
- package/dist/gs/unsafe/unsafe.js +5 -0
- package/dist/gs/unsafe/unsafe.js.map +1 -1
- package/gs/internal/byteorder/index.ts +40 -0
- package/gs/internal/testlog/index.ts +7 -0
- package/gs/maps/iter.ts +1 -1
- package/gs/math/erfinv.gs.test.ts +2 -2
- package/gs/math/fma.gs.test.ts +5 -5
- package/gs/math/ldexp.gs.test.ts +5 -5
- package/gs/math/lgamma.gs.test.ts +2 -2
- package/gs/os/dir.gs.ts +42 -0
- package/gs/os/dir_unix.gs.ts +155 -0
- package/gs/os/dirent_js.gs.ts +27 -0
- package/gs/os/env.gs.ts +179 -0
- package/gs/os/error.gs.ts +205 -0
- package/gs/os/error_errno.gs.ts +12 -0
- package/gs/os/exec.gs.ts +198 -0
- package/gs/os/exec_nohandle.gs.ts +2 -0
- package/gs/os/exec_posix.gs.ts +95 -0
- package/gs/os/exec_unix.gs.ts +64 -0
- package/gs/os/executable.gs.ts +18 -0
- package/gs/os/executable_js.gs.ts +6 -0
- package/gs/os/executable_wasm.gs.ts +10 -0
- package/gs/os/file_constants_js.gs.ts +98 -0
- package/gs/os/file_js.gs.ts +99 -0
- package/gs/os/file_open_unix.gs.ts +15 -0
- package/gs/os/file_posix_js.gs.ts +40 -0
- package/gs/os/file_unix_js.gs.ts +94 -0
- package/gs/os/getwd_js.gs.ts +28 -0
- package/gs/os/index.ts +19 -0
- package/gs/os/path.gs.ts +35 -0
- package/gs/os/path_unix.gs.ts +49 -0
- package/gs/os/pidfd_js.gs.ts +25 -0
- package/gs/os/pipe_wasm.gs.ts +17 -0
- package/gs/os/proc.gs.ts +84 -0
- package/gs/os/proc_js.gs.ts +15 -0
- package/gs/os/rawconn_js.gs.ts +30 -0
- package/gs/os/removeall_js.gs.ts +9 -0
- package/gs/os/root_js.gs.ts +111 -0
- package/gs/os/root_nonwindows.gs.ts +6 -0
- package/gs/os/root_noopenat.gs.ts +45 -0
- package/gs/os/stat.gs.ts +38 -0
- package/gs/os/stat_js.gs.ts +30 -0
- package/gs/os/stat_unix_js.gs.ts +27 -0
- package/gs/os/sticky_bsd.gs.ts +4 -0
- package/gs/os/sys.gs.ts +12 -0
- package/gs/os/sys_bsd.gs.ts +17 -0
- package/gs/os/sys_js.gs.ts +9 -0
- package/gs/os/tempfile.gs.ts +34 -0
- package/gs/os/types.gs.ts +170 -0
- package/gs/os/types_js.gs.ts +205 -0
- package/gs/os/types_unix.gs.ts +118 -0
- package/gs/os/wait_unimp.gs.ts +2 -0
- package/gs/os/zero_copy_posix.gs.ts +35 -0
- package/gs/os/zero_copy_stub.gs.ts +4 -0
- package/gs/sync/atomic/doc.gs.ts +276 -0
- package/gs/sync/atomic/doc_64.gs.ts +168 -0
- package/gs/sync/atomic/index.ts +4 -0
- package/gs/sync/atomic/type.gs.ts +596 -0
- package/gs/sync/atomic/value.gs.ts +158 -0
- package/gs/syscall/index.ts +204 -0
- package/gs/unsafe/unsafe.ts +6 -0
- package/package.json +1 -1
package/gs/os/exec.gs.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as errors from "@goscript/errors/index.js"
|
|
5
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
6
|
+
|
|
7
|
+
export let ErrProcessDone: $.GoError = errors.New("os: process already finished")
|
|
8
|
+
|
|
9
|
+
// Simplified Process class for JavaScript environment
|
|
10
|
+
export class Process {
|
|
11
|
+
public get Pid(): number {
|
|
12
|
+
return this._fields.Pid.value
|
|
13
|
+
}
|
|
14
|
+
public set Pid(value: number) {
|
|
15
|
+
this._fields.Pid.value = value
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public _fields: {
|
|
19
|
+
Pid: $.VarRef<number>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor(init?: Partial<{Pid?: number}>) {
|
|
23
|
+
this._fields = {
|
|
24
|
+
Pid: $.varRef(init?.Pid ?? -1)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public clone(): Process {
|
|
29
|
+
const cloned = new Process()
|
|
30
|
+
cloned._fields = {
|
|
31
|
+
Pid: $.varRef(this._fields.Pid.value)
|
|
32
|
+
}
|
|
33
|
+
return cloned
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// All process operations return ErrUnimplemented in JavaScript
|
|
37
|
+
public Release(): $.GoError {
|
|
38
|
+
return ErrUnimplemented
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public Kill(): $.GoError {
|
|
42
|
+
return ErrUnimplemented
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public Wait(): [ProcessState | null, $.GoError] {
|
|
46
|
+
return [null, ErrUnimplemented]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public Signal(sig: Signal): $.GoError {
|
|
50
|
+
return ErrUnimplemented
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Register this type with the runtime type system
|
|
54
|
+
static __typeInfo = $.registerStructType(
|
|
55
|
+
'Process',
|
|
56
|
+
new Process(),
|
|
57
|
+
[
|
|
58
|
+
{ name: "Release", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
59
|
+
{ name: "Kill", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
60
|
+
{ name: "Wait", args: [], returns: [{ type: { kind: $.TypeKind.Pointer, elemType: "ProcessState" } }, { type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
61
|
+
{ name: "Signal", args: [{ name: "sig", type: "Signal" }], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] }
|
|
62
|
+
],
|
|
63
|
+
Process,
|
|
64
|
+
{ "Pid": { kind: $.TypeKind.Basic, name: "number" } }
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Simplified ProcAttr class for JavaScript environment
|
|
69
|
+
export class ProcAttr {
|
|
70
|
+
public get Dir(): string {
|
|
71
|
+
return this._fields.Dir.value
|
|
72
|
+
}
|
|
73
|
+
public set Dir(value: string) {
|
|
74
|
+
this._fields.Dir.value = value
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public get Env(): $.Slice<string> {
|
|
78
|
+
return this._fields.Env.value
|
|
79
|
+
}
|
|
80
|
+
public set Env(value: $.Slice<string>) {
|
|
81
|
+
this._fields.Env.value = value
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public get Files(): $.Slice<any> {
|
|
85
|
+
return this._fields.Files.value
|
|
86
|
+
}
|
|
87
|
+
public set Files(value: $.Slice<any>) {
|
|
88
|
+
this._fields.Files.value = value
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public get Sys(): any {
|
|
92
|
+
return this._fields.Sys.value
|
|
93
|
+
}
|
|
94
|
+
public set Sys(value: any) {
|
|
95
|
+
this._fields.Sys.value = value
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public _fields: {
|
|
99
|
+
Dir: $.VarRef<string>;
|
|
100
|
+
Env: $.VarRef<$.Slice<string>>;
|
|
101
|
+
Files: $.VarRef<$.Slice<any>>;
|
|
102
|
+
Sys: $.VarRef<any>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
constructor(init?: Partial<{Dir?: string, Env?: $.Slice<string>, Files?: $.Slice<any>, Sys?: any}>) {
|
|
106
|
+
this._fields = {
|
|
107
|
+
Dir: $.varRef(init?.Dir ?? ""),
|
|
108
|
+
Env: $.varRef(init?.Env ?? null),
|
|
109
|
+
Files: $.varRef(init?.Files ?? null),
|
|
110
|
+
Sys: $.varRef(init?.Sys ?? null)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public clone(): ProcAttr {
|
|
115
|
+
const cloned = new ProcAttr()
|
|
116
|
+
cloned._fields = {
|
|
117
|
+
Dir: $.varRef(this._fields.Dir.value),
|
|
118
|
+
Env: $.varRef(this._fields.Env.value),
|
|
119
|
+
Files: $.varRef(this._fields.Files.value),
|
|
120
|
+
Sys: $.varRef(this._fields.Sys.value)
|
|
121
|
+
}
|
|
122
|
+
return cloned
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Register this type with the runtime type system
|
|
126
|
+
static __typeInfo = $.registerStructType(
|
|
127
|
+
'ProcAttr',
|
|
128
|
+
new ProcAttr(),
|
|
129
|
+
[],
|
|
130
|
+
ProcAttr,
|
|
131
|
+
{
|
|
132
|
+
"Dir": { kind: $.TypeKind.Basic, name: "string" },
|
|
133
|
+
"Env": { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "string" } },
|
|
134
|
+
"Files": { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "any" } },
|
|
135
|
+
"Sys": { kind: $.TypeKind.Basic, name: "any" }
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Stub ProcessState for JavaScript environment
|
|
141
|
+
export class ProcessState {
|
|
142
|
+
public _fields: {}
|
|
143
|
+
|
|
144
|
+
constructor() {
|
|
145
|
+
this._fields = {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public clone(): ProcessState {
|
|
149
|
+
return new ProcessState()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Register this type with the runtime type system
|
|
153
|
+
static __typeInfo = $.registerStructType(
|
|
154
|
+
'ProcessState',
|
|
155
|
+
new ProcessState(),
|
|
156
|
+
[],
|
|
157
|
+
ProcessState,
|
|
158
|
+
{}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Signal interface stub
|
|
163
|
+
export type Signal = null | {
|
|
164
|
+
Signal(): void
|
|
165
|
+
String(): string
|
|
166
|
+
}
|
|
167
|
+
export const Signal = null as any;
|
|
168
|
+
|
|
169
|
+
// Stub functions that return ErrUnimplemented
|
|
170
|
+
export function Getpid(): number {
|
|
171
|
+
return -1 // Not available in JavaScript
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function Getppid(): number {
|
|
175
|
+
return -1 // Not available in JavaScript
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function FindProcess(pid: number): [Process | null, $.GoError] {
|
|
179
|
+
return [null, ErrUnimplemented]
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function StartProcess(name: string, argv: $.Slice<string>, attr: ProcAttr | null): [Process | null, $.GoError] {
|
|
183
|
+
return [null, ErrUnimplemented]
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Internal functions used by exec_unix.gs.ts
|
|
187
|
+
export function newDoneProcess(pid: number): Process {
|
|
188
|
+
return new Process({Pid: pid})
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function newHandleProcess(pid: number, handle: number): Process {
|
|
192
|
+
return new Process({Pid: pid})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function newPIDProcess(pid: number): Process {
|
|
196
|
+
return new Process({Pid: pid})
|
|
197
|
+
}
|
|
198
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { Signal } from "./exec.gs.js";
|
|
3
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
4
|
+
|
|
5
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
6
|
+
|
|
7
|
+
// Signal constants for JavaScript environment
|
|
8
|
+
export let Interrupt: Signal = null // syscall.SIGINT not available in JavaScript
|
|
9
|
+
|
|
10
|
+
export let Kill: Signal = null // syscall.SIGKILL not available in JavaScript
|
|
11
|
+
|
|
12
|
+
// Simplified ProcessState for JavaScript environment
|
|
13
|
+
export class ProcessState {
|
|
14
|
+
public get pid(): number {
|
|
15
|
+
return this._fields.pid.value
|
|
16
|
+
}
|
|
17
|
+
public set pid(value: number) {
|
|
18
|
+
this._fields.pid.value = value
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public _fields: {
|
|
22
|
+
pid: $.VarRef<number>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
constructor(init?: Partial<{pid?: number}>) {
|
|
26
|
+
this._fields = {
|
|
27
|
+
pid: $.varRef(init?.pid ?? -1)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public clone(): ProcessState {
|
|
32
|
+
const cloned = new ProcessState()
|
|
33
|
+
cloned._fields = {
|
|
34
|
+
pid: $.varRef(this._fields.pid.value)
|
|
35
|
+
}
|
|
36
|
+
return cloned
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// All methods return stub values for JavaScript environment
|
|
40
|
+
public UserTime(): any {
|
|
41
|
+
return 0 // Duration not available
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public SystemTime(): any {
|
|
45
|
+
return 0 // Duration not available
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public Exited(): boolean {
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public Success(): boolean {
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public Sys(): null | any {
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public SysUsage(): null | any {
|
|
61
|
+
return null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public Pid(): number {
|
|
65
|
+
return this.pid
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public String(): string {
|
|
69
|
+
return `exit status ${this.pid}`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public ExitCode(): number {
|
|
73
|
+
return -1
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Register this type with the runtime type system
|
|
77
|
+
static __typeInfo = $.registerStructType(
|
|
78
|
+
'ProcessState',
|
|
79
|
+
new ProcessState(),
|
|
80
|
+
[
|
|
81
|
+
{ name: "UserTime", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
|
|
82
|
+
{ name: "SystemTime", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
|
|
83
|
+
{ name: "Exited", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] },
|
|
84
|
+
{ name: "Success", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] },
|
|
85
|
+
{ name: "Sys", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
|
|
86
|
+
{ name: "SysUsage", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
|
|
87
|
+
{ name: "Pid", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] },
|
|
88
|
+
{ name: "String", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "string" } }] },
|
|
89
|
+
{ name: "ExitCode", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] }
|
|
90
|
+
],
|
|
91
|
+
ProcessState,
|
|
92
|
+
{ "pid": { kind: $.TypeKind.Basic, name: "number" } }
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { NewSyscallError, ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { newDoneProcess, newHandleProcess, newPIDProcess, Process, ErrProcessDone } from "./exec.gs.js";
|
|
4
|
+
|
|
5
|
+
import * as errors from "@goscript/errors/index.js"
|
|
6
|
+
|
|
7
|
+
import * as runtime from "@goscript/runtime/index.js"
|
|
8
|
+
|
|
9
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
10
|
+
|
|
11
|
+
import * as time from "@goscript/time/index.js"
|
|
12
|
+
|
|
13
|
+
// Import uintptr type
|
|
14
|
+
type uintptr = syscall.uintptr
|
|
15
|
+
|
|
16
|
+
// Stub functions for JavaScript environment
|
|
17
|
+
function ignoringEINTR2(fn: any, arg1: any, arg2: any): [any, $.GoError] {
|
|
18
|
+
return [null, ErrUnimplemented]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function pidfdFind(pid: number): [uintptr, $.GoError] {
|
|
22
|
+
return [0, ErrUnimplemented]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Special values for Process.Pid.
|
|
26
|
+
let pidUnset: number = 0
|
|
27
|
+
|
|
28
|
+
let pidReleased: number = -1
|
|
29
|
+
|
|
30
|
+
export function convertESRCH(err: $.GoError): $.GoError {
|
|
31
|
+
if (err == syscall.ESRCH) {
|
|
32
|
+
return ErrProcessDone
|
|
33
|
+
}
|
|
34
|
+
return err
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function findProcess(pid: number): [Process | null, $.GoError] {
|
|
38
|
+
let p: Process | null = null
|
|
39
|
+
let err: $.GoError = null
|
|
40
|
+
{
|
|
41
|
+
let h: uintptr
|
|
42
|
+
[h, err] = pidfdFind(pid)
|
|
43
|
+
|
|
44
|
+
// We can't return an error here since users are not expecting
|
|
45
|
+
// it. Instead, return a process with a "done" state already
|
|
46
|
+
// and let a subsequent Signal or Wait call catch that.
|
|
47
|
+
|
|
48
|
+
// Ignore other errors from pidfdFind, as the callers
|
|
49
|
+
// do not expect them. Fall back to using the PID.
|
|
50
|
+
if (err == ErrProcessDone) {
|
|
51
|
+
// We can't return an error here since users are not expecting
|
|
52
|
+
// it. Instead, return a process with a "done" state already
|
|
53
|
+
// and let a subsequent Signal or Wait call catch that.
|
|
54
|
+
return [newDoneProcess(pid), null]
|
|
55
|
+
} else if (err != null) {
|
|
56
|
+
// Ignore other errors from pidfdFind, as the callers
|
|
57
|
+
// do not expect them. Fall back to using the PID.
|
|
58
|
+
return [newPIDProcess(pid), null]
|
|
59
|
+
}
|
|
60
|
+
// Use the handle.
|
|
61
|
+
return [newHandleProcess(pid, h), null]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { executable } from "./executable_js.gs.js";
|
|
3
|
+
|
|
4
|
+
// Executable returns the path name for the executable that started
|
|
5
|
+
// the current process. There is no guarantee that the path is still
|
|
6
|
+
// pointing to the correct executable. If a symlink was used to start
|
|
7
|
+
// the process, depending on the operating system, the result might
|
|
8
|
+
// be the symlink or the path it pointed to. If a stable result is
|
|
9
|
+
// needed, [path/filepath.EvalSymlinks] might help.
|
|
10
|
+
//
|
|
11
|
+
// Executable returns an absolute path unless an error occurred.
|
|
12
|
+
//
|
|
13
|
+
// The main use case is finding resources located relative to an
|
|
14
|
+
// executable.
|
|
15
|
+
export function Executable(): [string, $.GoError] {
|
|
16
|
+
return executable()
|
|
17
|
+
}
|
|
18
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
|
|
3
|
+
import * as errors from "@goscript/errors/index.js"
|
|
4
|
+
|
|
5
|
+
import * as runtime from "@goscript/runtime/index.js"
|
|
6
|
+
|
|
7
|
+
export function executable(): [string, $.GoError] {
|
|
8
|
+
return ["", errors.New("Executable not implemented for " + runtime.GOOS)]
|
|
9
|
+
}
|
|
10
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific stubs for file constants and operations
|
|
5
|
+
// These provide the required constants and stub implementations
|
|
6
|
+
|
|
7
|
+
// File open flags - using values compatible with typical Unix systems
|
|
8
|
+
export const O_RDONLY = 0
|
|
9
|
+
export const O_WRONLY = 1
|
|
10
|
+
export const O_RDWR = 2
|
|
11
|
+
export const O_APPEND = 1024
|
|
12
|
+
export const O_CREATE = 64
|
|
13
|
+
export const O_EXCL = 128
|
|
14
|
+
export const O_SYNC = 1052672
|
|
15
|
+
export const O_TRUNC = 512
|
|
16
|
+
|
|
17
|
+
// Seek constants
|
|
18
|
+
export const SEEK_SET = 0
|
|
19
|
+
export const SEEK_CUR = 1
|
|
20
|
+
export const SEEK_END = 2
|
|
21
|
+
|
|
22
|
+
// LinkError stub for compatibility
|
|
23
|
+
export class LinkError {
|
|
24
|
+
public get Op(): string {
|
|
25
|
+
return this._fields.Op.value
|
|
26
|
+
}
|
|
27
|
+
public set Op(value: string) {
|
|
28
|
+
this._fields.Op.value = value
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public get Old(): string {
|
|
32
|
+
return this._fields.Old.value
|
|
33
|
+
}
|
|
34
|
+
public set Old(value: string) {
|
|
35
|
+
this._fields.Old.value = value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public get New(): string {
|
|
39
|
+
return this._fields.New.value
|
|
40
|
+
}
|
|
41
|
+
public set New(value: string) {
|
|
42
|
+
this._fields.New.value = value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public get Err(): $.GoError {
|
|
46
|
+
return this._fields.Err.value
|
|
47
|
+
}
|
|
48
|
+
public set Err(value: $.GoError) {
|
|
49
|
+
this._fields.Err.value = value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public _fields: {
|
|
53
|
+
Op: $.VarRef<string>;
|
|
54
|
+
Old: $.VarRef<string>;
|
|
55
|
+
New: $.VarRef<string>;
|
|
56
|
+
Err: $.VarRef<$.GoError>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
constructor(init?: Partial<{Op?: string, Old?: string, New?: string, Err?: $.GoError}>) {
|
|
60
|
+
this._fields = {
|
|
61
|
+
Op: $.varRef(init?.Op ?? ""),
|
|
62
|
+
Old: $.varRef(init?.Old ?? ""),
|
|
63
|
+
New: $.varRef(init?.New ?? ""),
|
|
64
|
+
Err: $.varRef(init?.Err ?? null)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public Error(): string {
|
|
69
|
+
const e = this
|
|
70
|
+
return e.Op + " " + e.Old + " " + e.New + ": " + (e.Err?.Error() ?? "")
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public Unwrap(): $.GoError {
|
|
74
|
+
const e = this
|
|
75
|
+
return e.Err
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Directory and file operation stubs
|
|
80
|
+
export function Readlink(name: string): [string, $.GoError] {
|
|
81
|
+
return ["", ErrUnimplemented]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function TempDir(): string {
|
|
85
|
+
return "/tmp"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function UserCacheDir(): [string, $.GoError] {
|
|
89
|
+
return ["", ErrUnimplemented]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function UserConfigDir(): [string, $.GoError] {
|
|
93
|
+
return ["", ErrUnimplemented]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function UserHomeDir(): [string, $.GoError] {
|
|
97
|
+
return ["", ErrUnimplemented]
|
|
98
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { File } from "./types_js.gs.js";
|
|
4
|
+
|
|
5
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
6
|
+
|
|
7
|
+
// JavaScript-specific implementations for filesystem operations
|
|
8
|
+
// These functions stub filesystem operations that cannot be implemented
|
|
9
|
+
// in a JavaScript environment
|
|
10
|
+
|
|
11
|
+
// File operations - stub implementations
|
|
12
|
+
export function Open(name: string): [File | null, $.GoError] {
|
|
13
|
+
return [null, ErrUnimplemented]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Create(name: string): [File | null, $.GoError] {
|
|
17
|
+
return [null, ErrUnimplemented]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function OpenFile(name: string, flag: number, perm: number): [File | null, $.GoError] {
|
|
21
|
+
return [null, ErrUnimplemented]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function ReadFile(name: string): [$.Bytes, $.GoError] {
|
|
25
|
+
return [null, ErrUnimplemented]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function WriteFile(name: string, data: $.Bytes, perm: number): $.GoError {
|
|
29
|
+
return ErrUnimplemented
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Directory operations - stub implementations
|
|
33
|
+
export function Mkdir(name: string, perm: number): $.GoError {
|
|
34
|
+
return ErrUnimplemented
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function MkdirAll(path: string, perm: number): $.GoError {
|
|
38
|
+
return ErrUnimplemented
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function Remove(name: string): $.GoError {
|
|
42
|
+
return ErrUnimplemented
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function RemoveAll(path: string): $.GoError {
|
|
46
|
+
return ErrUnimplemented
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function Chdir(dir: string): $.GoError {
|
|
50
|
+
return ErrUnimplemented
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function Chmod(name: string, mode: number): $.GoError {
|
|
54
|
+
return ErrUnimplemented
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function Rename(oldpath: string, newpath: string): $.GoError {
|
|
58
|
+
return ErrUnimplemented
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// File information operations - stub implementations
|
|
62
|
+
export function Stat(name: string): [fs.FileInfo, $.GoError] {
|
|
63
|
+
return [null, ErrUnimplemented]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function Lstat(name: string): [fs.FileInfo, $.GoError] {
|
|
67
|
+
return [null, ErrUnimplemented]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Link operations - stub implementations
|
|
71
|
+
export function Link(oldname: string, newname: string): $.GoError {
|
|
72
|
+
return ErrUnimplemented
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function Symlink(oldname: string, newname: string): $.GoError {
|
|
76
|
+
return ErrUnimplemented
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function Readlink(name: string): [string, $.GoError] {
|
|
80
|
+
return ["", ErrUnimplemented]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function Truncate(name: string, size: number): $.GoError {
|
|
84
|
+
return ErrUnimplemented
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// File system information - stub implementations
|
|
88
|
+
export function DirFS(dir: string): fs.FS {
|
|
89
|
+
// Return a stub filesystem that always returns ErrUnimplemented
|
|
90
|
+
return new stubFS()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class stubFS {
|
|
94
|
+
public Open(name: string): [fs.File, $.GoError] {
|
|
95
|
+
return [null, ErrUnimplemented]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
5
|
+
|
|
6
|
+
// Stub SysFile for JavaScript environment
|
|
7
|
+
class SysFile {
|
|
8
|
+
constructor(init?: any) {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function open(path: string, flag: number, perm: number): [number, SysFile, $.GoError] {
|
|
12
|
+
let [fd, err] = syscall.Open(path, flag, perm)
|
|
13
|
+
return [fd, new SysFile({}), err]
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific stubs for POSIX file operations
|
|
5
|
+
// These operations are not available in JavaScript environments
|
|
6
|
+
|
|
7
|
+
// syscallMode stub
|
|
8
|
+
export function syscallMode(i: number): number {
|
|
9
|
+
return 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// ignoringEINTR stub
|
|
13
|
+
export function ignoringEINTR(fn: () => $.GoError): $.GoError {
|
|
14
|
+
return ErrUnimplemented
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ignoringEINTR2 stub
|
|
18
|
+
export function ignoringEINTR2(fn: () => [string, $.GoError]): [string, $.GoError] {
|
|
19
|
+
return ["", ErrUnimplemented]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Chmod operation stub
|
|
23
|
+
export function Chmod(name: string, mode: number): $.GoError {
|
|
24
|
+
return ErrUnimplemented
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Chown operation stub
|
|
28
|
+
export function Chown(name: string, uid: number, gid: number): $.GoError {
|
|
29
|
+
return ErrUnimplemented
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Lchown operation stub
|
|
33
|
+
export function Lchown(name: string, uid: number, gid: number): $.GoError {
|
|
34
|
+
return ErrUnimplemented
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Chtimes operation stub
|
|
38
|
+
export function Chtimes(name: string, atime: any, mtime: any): $.GoError {
|
|
39
|
+
return ErrUnimplemented
|
|
40
|
+
}
|