goscript 0.0.36 → 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.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/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/syscall/index.d.ts +80 -0
- package/dist/gs/syscall/index.js +163 -0
- package/dist/gs/syscall/index.js.map +1 -0
- package/gs/internal/byteorder/index.ts +40 -0
- package/gs/internal/testlog/index.ts +7 -0
- 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/syscall/index.ts +204 -0
- package/package.json +1 -1
package/gs/os/proc.gs.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { NewSyscallError, ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as runtime from "@goscript/runtime/index.js"
|
|
5
|
+
|
|
6
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
7
|
+
|
|
8
|
+
export let Args: $.Slice<string> = null
|
|
9
|
+
|
|
10
|
+
export function init(): void {
|
|
11
|
+
// In JavaScript environment, just initialize with empty args
|
|
12
|
+
Args = runtime_args()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function runtime_args(): $.Slice<string> {
|
|
16
|
+
return $.arrayToSlice<string>([])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Getuid returns the numeric user id of the caller.
|
|
20
|
+
//
|
|
21
|
+
// On Windows, it returns -1.
|
|
22
|
+
export function Getuid(): number {
|
|
23
|
+
return -1 // Not available in JavaScript
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Geteuid returns the numeric effective user id of the caller.
|
|
27
|
+
//
|
|
28
|
+
// On Windows, it returns -1.
|
|
29
|
+
export function Geteuid(): number {
|
|
30
|
+
return -1 // Not available in JavaScript
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Getgid returns the numeric group id of the caller.
|
|
34
|
+
//
|
|
35
|
+
// On Windows, it returns -1.
|
|
36
|
+
export function Getgid(): number {
|
|
37
|
+
return -1 // Not available in JavaScript
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Getegid returns the numeric effective group id of the caller.
|
|
41
|
+
//
|
|
42
|
+
// On Windows, it returns -1.
|
|
43
|
+
export function Getegid(): number {
|
|
44
|
+
return -1 // Not available in JavaScript
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
|
|
48
|
+
//
|
|
49
|
+
// On Windows, it returns [syscall.EWINDOWS]. See the [os/user] package
|
|
50
|
+
// for a possible alternative.
|
|
51
|
+
export function Getgroups(): [$.Slice<number>, $.GoError] {
|
|
52
|
+
return [$.arrayToSlice<number>([]), ErrUnimplemented]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Exit causes the current program to exit with the given status code.
|
|
56
|
+
// Conventionally, code zero indicates success, non-zero an error.
|
|
57
|
+
// The program terminates immediately; deferred functions are not run.
|
|
58
|
+
//
|
|
59
|
+
// For portability, the status code should be in the range [0, 125].
|
|
60
|
+
export function Exit(code: number): void {
|
|
61
|
+
|
|
62
|
+
// Testlog functionality not available in JavaScript - stub
|
|
63
|
+
// if (code == 0 && testlog.PanicOnExit0()) {
|
|
64
|
+
// $.panic("unexpected call to os.Exit(0) during test")
|
|
65
|
+
// }
|
|
66
|
+
|
|
67
|
+
// Inform the runtime that os.Exit is being called. If -race is
|
|
68
|
+
// enabled, this will give race detector a chance to fail the
|
|
69
|
+
// program (racy programs do not have the right to finish
|
|
70
|
+
// successfully). If coverage is enabled, then this call will
|
|
71
|
+
// enable us to write out a coverage data file.
|
|
72
|
+
runtime_beforeExit(code)
|
|
73
|
+
|
|
74
|
+
// In JavaScript environment, use process.exit if available
|
|
75
|
+
if (typeof process !== 'undefined' && process.exit) {
|
|
76
|
+
process.exit(code)
|
|
77
|
+
} else {
|
|
78
|
+
// Fallback: just return (can't really exit in browser)
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function runtime_beforeExit(exitCode: number): void {}
|
|
84
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific process functions
|
|
5
|
+
|
|
6
|
+
// runtime_args returns command line arguments (stub for JS)
|
|
7
|
+
export function runtime_args(): $.Slice<string> {
|
|
8
|
+
// In JavaScript environment, return empty args or process.argv equivalent
|
|
9
|
+
return $.arrayToSlice<string>([])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// runtime_beforeExit is called before exit (stub for JS)
|
|
13
|
+
export function runtime_beforeExit(exitCode: number): void {
|
|
14
|
+
// No-op in JavaScript
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
// JavaScript-specific stub for raw connection operations
|
|
6
|
+
// These operations are not available in JavaScript environments
|
|
7
|
+
|
|
8
|
+
export class rawConn {
|
|
9
|
+
constructor(private file: File | null) {}
|
|
10
|
+
|
|
11
|
+
// Control calls fn with the file descriptor - stub implementation
|
|
12
|
+
public Control(f: ((fd: number) => void) | null): $.GoError {
|
|
13
|
+
return ErrUnimplemented
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Read calls fn when the file descriptor is ready for reading - stub implementation
|
|
17
|
+
public Read(f: ((fd: number) => boolean) | null): $.GoError {
|
|
18
|
+
return ErrUnimplemented
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Write calls fn when the file descriptor is ready for writing - stub implementation
|
|
22
|
+
public Write(f: ((fd: number) => boolean) | null): $.GoError {
|
|
23
|
+
return ErrUnimplemented
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// newRawConn creates a new raw connection - stub implementation
|
|
28
|
+
export function newRawConn(file: File | null): rawConn {
|
|
29
|
+
return new rawConn(file)
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific stub for removeall operations
|
|
5
|
+
// These operations cannot be implemented in JavaScript environments
|
|
6
|
+
|
|
7
|
+
export function RemoveAll(path: string): $.GoError {
|
|
8
|
+
return ErrUnimplemented
|
|
9
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 root filesystem operations
|
|
8
|
+
// These functions stub operations that cannot be implemented in JavaScript
|
|
9
|
+
|
|
10
|
+
// OpenInRoot opens the file name in the directory dir - stub implementation
|
|
11
|
+
export function OpenInRoot(dir: string, name: string): [File | null, $.GoError] {
|
|
12
|
+
return [null, ErrUnimplemented]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Root represents a root filesystem - stub implementation
|
|
16
|
+
export class Root {
|
|
17
|
+
constructor() {}
|
|
18
|
+
|
|
19
|
+
// Name returns the name of the directory presented to OpenRoot
|
|
20
|
+
public Name(): string {
|
|
21
|
+
return ""
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Close closes the Root
|
|
25
|
+
public Close(): $.GoError {
|
|
26
|
+
return ErrUnimplemented
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Open opens the named file in the root for reading
|
|
30
|
+
public Open(name: string): [File | null, $.GoError] {
|
|
31
|
+
return [null, ErrUnimplemented]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Create creates or truncates the named file in the root
|
|
35
|
+
public Create(name: string): [File | null, $.GoError] {
|
|
36
|
+
return [null, ErrUnimplemented]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// OpenFile opens the named file in the root
|
|
40
|
+
public OpenFile(name: string, flag: number, perm: number): [File | null, $.GoError] {
|
|
41
|
+
return [null, ErrUnimplemented]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// OpenRoot opens the named directory in the root
|
|
45
|
+
public OpenRoot(name: string): [RootType | null, $.GoError] {
|
|
46
|
+
return [null, ErrUnimplemented]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Mkdir creates a new directory in the root
|
|
50
|
+
public Mkdir(name: string, perm: number): $.GoError {
|
|
51
|
+
return ErrUnimplemented
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Remove removes the named file or directory in the root
|
|
55
|
+
public Remove(name: string): $.GoError {
|
|
56
|
+
return ErrUnimplemented
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Stat returns a FileInfo describing the named file in the root
|
|
60
|
+
public Stat(name: string): [fs.FileInfo | null, $.GoError] {
|
|
61
|
+
return [null, ErrUnimplemented]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Lstat returns a FileInfo describing the named file in the root
|
|
65
|
+
public Lstat(name: string): [fs.FileInfo | null, $.GoError] {
|
|
66
|
+
return [null, ErrUnimplemented]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// FS returns a file system for the tree of files in the root
|
|
70
|
+
public FS(): fs.FS {
|
|
71
|
+
return new stubFS()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Register this type with the runtime type system
|
|
75
|
+
static __typeInfo = $.registerStructType(
|
|
76
|
+
'Root',
|
|
77
|
+
new Root(),
|
|
78
|
+
[
|
|
79
|
+
{ name: "Name", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] },
|
|
80
|
+
{ name: "Close", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] }
|
|
81
|
+
],
|
|
82
|
+
Root,
|
|
83
|
+
{}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Type alias to avoid conflicts
|
|
88
|
+
export type RootType = Root
|
|
89
|
+
|
|
90
|
+
// OpenRoot opens a root filesystem - stub implementation
|
|
91
|
+
export function OpenRoot(name: string): [Root | null, $.GoError] {
|
|
92
|
+
return [null, ErrUnimplemented]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// splitPathInRoot splits a path in root - stub implementation
|
|
96
|
+
export function splitPathInRoot(s: string, prefix: $.Slice<string> | null, suffix: $.Slice<string> | null): [$.Slice<string>, string, $.GoError] {
|
|
97
|
+
return [null, "", ErrUnimplemented]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// isValidRootFSPath checks if a path is valid for root filesystem - stub implementation
|
|
101
|
+
export function isValidRootFSPath(name: string): boolean {
|
|
102
|
+
return false
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Internal stub filesystem
|
|
106
|
+
class stubFS {
|
|
107
|
+
public Open(name: string): [fs.File, $.GoError] {
|
|
108
|
+
return [null, ErrUnimplemented]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { underlyingError, ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { Root } from "./root_js.gs.js";
|
|
4
|
+
import { File } from "./types_js.gs.js";
|
|
5
|
+
|
|
6
|
+
import * as errors from "@goscript/errors/index.js"
|
|
7
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
8
|
+
|
|
9
|
+
// Stub functions for JavaScript environment - these operations cannot be implemented properly
|
|
10
|
+
|
|
11
|
+
// openRootNolog is OpenRoot - stub implementation
|
|
12
|
+
export function openRootNolog(name: string): [Root | null, $.GoError] {
|
|
13
|
+
return [null, ErrUnimplemented]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// openRootInRoot is Root.OpenRoot - stub implementation
|
|
17
|
+
export function openRootInRoot(r: Root | null, name: string): [Root | null, $.GoError] {
|
|
18
|
+
return [null, ErrUnimplemented]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// newRoot returns a new Root - stub implementation
|
|
22
|
+
export function newRoot(name: string): [Root | null, $.GoError] {
|
|
23
|
+
return [null, ErrUnimplemented]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// rootOpenFileNolog is Root.OpenFile - stub implementation
|
|
27
|
+
export function rootOpenFileNolog(r: Root | null, name: string, flag: number, perm: number): [File | null, $.GoError] {
|
|
28
|
+
return [null, ErrUnimplemented]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// rootStat - stub implementation
|
|
32
|
+
export function rootStat(r: Root | null, name: string, lstat: boolean): [fs.FileInfo | null, $.GoError] {
|
|
33
|
+
return [null, ErrUnimplemented]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// rootMkdir - stub implementation
|
|
37
|
+
export function rootMkdir(r: Root | null, name: string, perm: number): $.GoError {
|
|
38
|
+
return ErrUnimplemented
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// rootRemove - stub implementation
|
|
42
|
+
export function rootRemove(r: Root | null, name: string): $.GoError {
|
|
43
|
+
return ErrUnimplemented
|
|
44
|
+
}
|
|
45
|
+
|
package/gs/os/stat.gs.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { lstatNolog, statNolog } from "./stat_js.gs.js";
|
|
3
|
+
import { Time, FileMode } from "./types_js.gs.js";
|
|
4
|
+
|
|
5
|
+
// Stat returns a [FileInfo] describing the named file.
|
|
6
|
+
// If there is an error, it will be of type [*PathError].
|
|
7
|
+
export function Stat(name: string): [null | {
|
|
8
|
+
IsDir(): boolean
|
|
9
|
+
ModTime(): any
|
|
10
|
+
Mode(): any
|
|
11
|
+
Name(): string
|
|
12
|
+
Size(): number
|
|
13
|
+
Sys(): null | any
|
|
14
|
+
}, $.GoError] {
|
|
15
|
+
// testlog.Stat(name) // Testlog not available in JavaScript
|
|
16
|
+
return statNolog(name)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Lstat returns a [FileInfo] describing the named file.
|
|
20
|
+
// If the file is a symbolic link, the returned FileInfo
|
|
21
|
+
// describes the symbolic link. Lstat makes no attempt to follow the link.
|
|
22
|
+
// If there is an error, it will be of type [*PathError].
|
|
23
|
+
//
|
|
24
|
+
// On Windows, if the file is a reparse point that is a surrogate for another
|
|
25
|
+
// named entity (such as a symbolic link or mounted folder), the returned
|
|
26
|
+
// FileInfo describes the reparse point, and makes no attempt to resolve it.
|
|
27
|
+
export function Lstat(name: string): [null | {
|
|
28
|
+
IsDir(): boolean
|
|
29
|
+
ModTime(): Time
|
|
30
|
+
Mode(): FileMode
|
|
31
|
+
Name(): string
|
|
32
|
+
Size(): number
|
|
33
|
+
Sys(): null | any
|
|
34
|
+
}, $.GoError] {
|
|
35
|
+
// testlog.Stat(name) // Testlog not available in JavaScript
|
|
36
|
+
return lstatNolog(name)
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
5
|
+
|
|
6
|
+
// JavaScript-specific stubs for stat operations
|
|
7
|
+
|
|
8
|
+
// Stat returns a [FileInfo] describing the named file.
|
|
9
|
+
// If there is an error, it will be of type [*PathError].
|
|
10
|
+
export function Stat(name: string): [fs.FileInfo, $.GoError] {
|
|
11
|
+
return [null, ErrUnimplemented]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Lstat returns a [FileInfo] describing the named file.
|
|
15
|
+
// If the file is a symbolic link, the returned FileInfo
|
|
16
|
+
// describes the symbolic link. Lstat makes no attempt to follow the link.
|
|
17
|
+
// If there is an error, it will be of type [*PathError].
|
|
18
|
+
export function Lstat(name: string): [fs.FileInfo, $.GoError] {
|
|
19
|
+
return [null, ErrUnimplemented]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// statNolog is the same as Stat, for use in DirFS.
|
|
23
|
+
export function statNolog(name: string): [fs.FileInfo, $.GoError] {
|
|
24
|
+
return [null, ErrUnimplemented]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// lstatNolog is the same as Lstat, for use in DirFS.
|
|
28
|
+
export function lstatNolog(name: string): [fs.FileInfo, $.GoError] {
|
|
29
|
+
return [null, ErrUnimplemented]
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
5
|
+
|
|
6
|
+
// JavaScript-specific stub implementations for Unix stat operations
|
|
7
|
+
// These operations cannot be implemented in JavaScript environments
|
|
8
|
+
|
|
9
|
+
// statNolog stats a file with no test logging - stub implementation
|
|
10
|
+
export function statNolog(name: string): [fs.FileInfo | null, $.GoError] {
|
|
11
|
+
return [null, ErrUnimplemented]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// lstatNolog lstats a file with no test logging - stub implementation
|
|
15
|
+
export function lstatNolog(name: string): [fs.FileInfo | null, $.GoError] {
|
|
16
|
+
return [null, ErrUnimplemented]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Additional compatibility exports
|
|
20
|
+
export function fillFileStatFromSys(fs: any, name: string): void {
|
|
21
|
+
// No-op in JavaScript
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// fileStat stub for compatibility
|
|
25
|
+
export interface fileStat {
|
|
26
|
+
sys: any
|
|
27
|
+
}
|
package/gs/os/sys.gs.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { hostname } from "./sys_js.gs.js";
|
|
3
|
+
|
|
4
|
+
// Hostname returns the host name reported by the kernel.
|
|
5
|
+
export function Hostname(): [string, $.GoError] {
|
|
6
|
+
let name: string = ""
|
|
7
|
+
let err: $.GoError = null
|
|
8
|
+
{
|
|
9
|
+
return hostname()
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { NewSyscallError } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
5
|
+
|
|
6
|
+
export function hostname(): [string, $.GoError] {
|
|
7
|
+
let name: string = ""
|
|
8
|
+
let err: $.GoError = null
|
|
9
|
+
{
|
|
10
|
+
;[name, err] = syscall.Sysctl("kern.hostname")
|
|
11
|
+
if (err != null) {
|
|
12
|
+
return ["", NewSyscallError("sysctl kern.hostname", err)]
|
|
13
|
+
}
|
|
14
|
+
return [name, null]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { File } from "./types.gs.js";
|
|
4
|
+
|
|
5
|
+
// joinPath joins directory and file paths - simplified implementation for JavaScript
|
|
6
|
+
export function joinPath(dir: string, file: string): string {
|
|
7
|
+
if (dir === "" || dir === ".") {
|
|
8
|
+
return file
|
|
9
|
+
}
|
|
10
|
+
if (file === "") {
|
|
11
|
+
return dir
|
|
12
|
+
}
|
|
13
|
+
// Remove trailing slash from dir if present
|
|
14
|
+
if (dir.endsWith("/")) {
|
|
15
|
+
dir = dir.slice(0, -1)
|
|
16
|
+
}
|
|
17
|
+
// Remove leading slash from file if present
|
|
18
|
+
if (file.startsWith("/")) {
|
|
19
|
+
file = file.slice(1)
|
|
20
|
+
}
|
|
21
|
+
return dir + "/" + file
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// CreateTemp creates a new temporary file in the directory dir.
|
|
25
|
+
// Stubbed implementation for JavaScript environment.
|
|
26
|
+
export function CreateTemp(dir: string, pattern: string): [File | null, $.GoError] {
|
|
27
|
+
return [null, ErrUnimplemented]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// MkdirTemp creates a new temporary directory.
|
|
31
|
+
// Stubbed implementation for JavaScript environment.
|
|
32
|
+
export function MkdirTemp(dir: string, pattern: string): [string, $.GoError] {
|
|
33
|
+
return ["", ErrUnimplemented]
|
|
34
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented, ErrInvalid } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
5
|
+
import * as io from "@goscript/io/index.js"
|
|
6
|
+
import * as time from "@goscript/time/index.js"
|
|
7
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
8
|
+
|
|
9
|
+
// Re-export essential types
|
|
10
|
+
export type Time = time.Time;
|
|
11
|
+
export type FileInfo = fs.FileInfo;
|
|
12
|
+
export type FileMode = fs.FileMode;
|
|
13
|
+
export type DirEntry = fs.DirEntry;
|
|
14
|
+
|
|
15
|
+
// Getpagesize returns the underlying system's memory page size.
|
|
16
|
+
export function Getpagesize(): number {
|
|
17
|
+
// Return a standard page size for JavaScript environment
|
|
18
|
+
// Most systems use 4096 bytes as the default page size
|
|
19
|
+
return 4096
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Simplified File implementation for JavaScript environment
|
|
23
|
+
export class File {
|
|
24
|
+
public name: string = ""
|
|
25
|
+
public closed: boolean = false
|
|
26
|
+
|
|
27
|
+
constructor(init?: Partial<{name?: string}>) {
|
|
28
|
+
this.name = init?.name ?? ""
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public clone(): File {
|
|
32
|
+
return new File({name: this.name})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// All File methods return ErrUnimplemented in JavaScript environment
|
|
36
|
+
public Readdir(n: number): [$.Slice<FileInfo>, $.GoError] {
|
|
37
|
+
return [null, ErrUnimplemented]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public Readdirnames(n: number): [$.Slice<string>, $.GoError] {
|
|
41
|
+
return [null, ErrUnimplemented]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public ReadDir(n: number): [$.Slice<DirEntry>, $.GoError] {
|
|
45
|
+
return [null, ErrUnimplemented]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public Name(): string {
|
|
49
|
+
return this.name
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public Read(b: $.Bytes): [number, $.GoError] {
|
|
53
|
+
return [0, ErrUnimplemented]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public ReadAt(b: $.Bytes, off: number): [number, $.GoError] {
|
|
57
|
+
return [0, ErrUnimplemented]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public ReadFrom(r: io.Reader): [number, $.GoError] {
|
|
61
|
+
return [0, ErrUnimplemented]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public Write(b: $.Bytes): [number, $.GoError] {
|
|
65
|
+
return [0, ErrUnimplemented]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public WriteAt(b: $.Bytes, off: number): [number, $.GoError] {
|
|
69
|
+
return [0, ErrUnimplemented]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public WriteTo(w: io.Writer): [number, $.GoError] {
|
|
73
|
+
return [0, ErrUnimplemented]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public Seek(offset: number, whence: number): [number, $.GoError] {
|
|
77
|
+
return [0, ErrUnimplemented]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public WriteString(s: string): [number, $.GoError] {
|
|
81
|
+
return [0, ErrUnimplemented]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public Chmod(mode: number): $.GoError {
|
|
85
|
+
return ErrUnimplemented
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public SetDeadline(t: Time): $.GoError {
|
|
89
|
+
return ErrUnimplemented
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public SetReadDeadline(t: Time): $.GoError {
|
|
93
|
+
return ErrUnimplemented
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public SetWriteDeadline(t: Time): $.GoError {
|
|
97
|
+
return ErrUnimplemented
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public SyscallConn(): [syscall.RawConn, $.GoError] {
|
|
101
|
+
return [new syscall.StubRawConn(), ErrUnimplemented]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public Close(): $.GoError {
|
|
105
|
+
this.closed = true
|
|
106
|
+
return null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public Chown(uid: number, gid: number): $.GoError {
|
|
110
|
+
return ErrUnimplemented
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public Truncate(size: number): $.GoError {
|
|
114
|
+
return ErrUnimplemented
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public Sync(): $.GoError {
|
|
118
|
+
return ErrUnimplemented
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public Chdir(): $.GoError {
|
|
122
|
+
return ErrUnimplemented
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public Fd(): syscall.uintptr {
|
|
126
|
+
return 0
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public Stat(): [FileInfo, $.GoError] {
|
|
130
|
+
return [null, ErrUnimplemented]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Register this type with the runtime type system
|
|
134
|
+
static __typeInfo = $.registerStructType(
|
|
135
|
+
'File',
|
|
136
|
+
new File(),
|
|
137
|
+
[
|
|
138
|
+
{ name: "Readdir", args: [{ name: "n", type: { kind: $.TypeKind.Basic, name: "number" } }], returns: [{ type: { kind: $.TypeKind.Slice, elemType: "FileInfo" } }, { type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
139
|
+
{ name: "Read", args: [{ name: "b", type: { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "number" } } }], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }, { type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
|
|
140
|
+
{ name: "Close", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] }
|
|
141
|
+
],
|
|
142
|
+
File,
|
|
143
|
+
{ "name": { kind: $.TypeKind.Basic, name: "string" }, "closed": { kind: $.TypeKind.Basic, name: "boolean" } }
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// File mode constants
|
|
148
|
+
export let ModeDir: FileMode = fs.ModeDir
|
|
149
|
+
export let ModeAppend: FileMode = fs.ModeAppend
|
|
150
|
+
export let ModeExclusive: FileMode = fs.ModeExclusive
|
|
151
|
+
export let ModeTemporary: FileMode = fs.ModeTemporary
|
|
152
|
+
export let ModeSymlink: FileMode = fs.ModeSymlink
|
|
153
|
+
export let ModeDevice: FileMode = fs.ModeDevice
|
|
154
|
+
export let ModeNamedPipe: FileMode = fs.ModeNamedPipe
|
|
155
|
+
export let ModeSocket: FileMode = fs.ModeSocket
|
|
156
|
+
export let ModeSetuid: FileMode = fs.ModeSetuid
|
|
157
|
+
export let ModeSetgid: FileMode = fs.ModeSetgid
|
|
158
|
+
export let ModeCharDevice: FileMode = fs.ModeCharDevice
|
|
159
|
+
export let ModeSticky: FileMode = fs.ModeSticky
|
|
160
|
+
export let ModeIrregular: FileMode = fs.ModeIrregular
|
|
161
|
+
|
|
162
|
+
export let ModeType: FileMode = fs.ModeType
|
|
163
|
+
export let ModePerm: FileMode = fs.ModePerm
|
|
164
|
+
|
|
165
|
+
// SameFile reports whether fi1 and fi2 describe the same file.
|
|
166
|
+
export function SameFile(fi1: FileInfo, fi2: FileInfo): boolean {
|
|
167
|
+
// In JavaScript environment, always return false as we can't compare files
|
|
168
|
+
return false
|
|
169
|
+
}
|
|
170
|
+
|