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.
Files changed (196) hide show
  1. package/compiler/expr-call.go +26 -0
  2. package/compiler/spec.go +1 -1
  3. package/compiler/stmt.go +26 -8
  4. package/dist/gs/internal/byteorder/index.d.ts +8 -0
  5. package/dist/gs/internal/byteorder/index.js +34 -0
  6. package/dist/gs/internal/byteorder/index.js.map +1 -0
  7. package/dist/gs/internal/testlog/index.d.ts +1 -0
  8. package/dist/gs/internal/testlog/index.js +5 -0
  9. package/dist/gs/internal/testlog/index.js.map +1 -0
  10. package/dist/gs/os/dir.gs.d.ts +6 -0
  11. package/dist/gs/os/dir.gs.js +35 -0
  12. package/dist/gs/os/dir.gs.js.map +1 -0
  13. package/dist/gs/os/dir_unix.gs.d.ts +7 -0
  14. package/dist/gs/os/dir_unix.gs.js +113 -0
  15. package/dist/gs/os/dir_unix.gs.js.map +1 -0
  16. package/dist/gs/os/dirent_js.gs.d.ts +5 -0
  17. package/dist/gs/os/dirent_js.gs.js +20 -0
  18. package/dist/gs/os/dirent_js.gs.js.map +1 -0
  19. package/dist/gs/os/env.gs.d.ts +12 -0
  20. package/dist/gs/os/env.gs.js +157 -0
  21. package/dist/gs/os/env.gs.js.map +1 -0
  22. package/dist/gs/os/error.gs.d.ts +40 -0
  23. package/dist/gs/os/error.gs.js +158 -0
  24. package/dist/gs/os/error.gs.js.map +1 -0
  25. package/dist/gs/os/error_errno.gs.d.ts +1 -0
  26. package/dist/gs/os/error_errno.gs.js +5 -0
  27. package/dist/gs/os/error_errno.gs.js.map +1 -0
  28. package/dist/gs/os/exec.gs.d.ts +60 -0
  29. package/dist/gs/os/exec.gs.js +136 -0
  30. package/dist/gs/os/exec.gs.js.map +1 -0
  31. package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
  32. package/dist/gs/os/exec_nohandle.gs.js +2 -0
  33. package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
  34. package/dist/gs/os/exec_posix.gs.d.ts +25 -0
  35. package/dist/gs/os/exec_posix.gs.js +67 -0
  36. package/dist/gs/os/exec_posix.gs.js.map +1 -0
  37. package/dist/gs/os/exec_unix.gs.d.ts +4 -0
  38. package/dist/gs/os/exec_unix.gs.js +46 -0
  39. package/dist/gs/os/exec_unix.gs.js.map +1 -0
  40. package/dist/gs/os/executable.gs.d.ts +2 -0
  41. package/dist/gs/os/executable.gs.js +16 -0
  42. package/dist/gs/os/executable.gs.js.map +1 -0
  43. package/dist/gs/os/executable_js.gs.d.ts +2 -0
  44. package/dist/gs/os/executable_js.gs.js +5 -0
  45. package/dist/gs/os/executable_js.gs.js.map +1 -0
  46. package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
  47. package/dist/gs/os/executable_wasm.gs.js +6 -0
  48. package/dist/gs/os/executable_wasm.gs.js.map +1 -0
  49. package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
  50. package/dist/gs/os/file_constants_js.gs.js +78 -0
  51. package/dist/gs/os/file_constants_js.gs.js.map +1 -0
  52. package/dist/gs/os/file_js.gs.d.ts +22 -0
  53. package/dist/gs/os/file_js.gs.js +73 -0
  54. package/dist/gs/os/file_js.gs.js.map +1 -0
  55. package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
  56. package/dist/gs/os/file_open_unix.gs.js +10 -0
  57. package/dist/gs/os/file_open_unix.gs.js.map +1 -0
  58. package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
  59. package/dist/gs/os/file_posix_js.gs.js +32 -0
  60. package/dist/gs/os/file_posix_js.gs.js.map +1 -0
  61. package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
  62. package/dist/gs/os/file_unix_js.gs.js +64 -0
  63. package/dist/gs/os/file_unix_js.gs.js.map +1 -0
  64. package/dist/gs/os/getwd_js.gs.d.ts +6 -0
  65. package/dist/gs/os/getwd_js.gs.js +21 -0
  66. package/dist/gs/os/getwd_js.gs.js.map +1 -0
  67. package/dist/gs/os/index.d.ts +19 -0
  68. package/dist/gs/os/index.js +20 -0
  69. package/dist/gs/os/index.js.map +1 -0
  70. package/dist/gs/os/path.gs.d.ts +4 -0
  71. package/dist/gs/os/path.gs.js +32 -0
  72. package/dist/gs/os/path.gs.js.map +1 -0
  73. package/dist/gs/os/path_unix.gs.d.ts +4 -0
  74. package/dist/gs/os/path_unix.gs.js +40 -0
  75. package/dist/gs/os/path_unix.gs.js.map +1 -0
  76. package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
  77. package/dist/gs/os/pidfd_js.gs.js +14 -0
  78. package/dist/gs/os/pidfd_js.gs.js.map +1 -0
  79. package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
  80. package/dist/gs/os/pipe_wasm.gs.js +14 -0
  81. package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
  82. package/dist/gs/os/proc.gs.d.ts +11 -0
  83. package/dist/gs/os/proc.gs.js +68 -0
  84. package/dist/gs/os/proc.gs.js.map +1 -0
  85. package/dist/gs/os/proc_js.gs.d.ts +3 -0
  86. package/dist/gs/os/proc_js.gs.js +12 -0
  87. package/dist/gs/os/proc_js.gs.js.map +1 -0
  88. package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
  89. package/dist/gs/os/rawconn_js.gs.js +26 -0
  90. package/dist/gs/os/rawconn_js.gs.js.map +1 -0
  91. package/dist/gs/os/removeall_js.gs.d.ts +2 -0
  92. package/dist/gs/os/removeall_js.gs.js +7 -0
  93. package/dist/gs/os/removeall_js.gs.js.map +1 -0
  94. package/dist/gs/os/root_js.gs.d.ts +23 -0
  95. package/dist/gs/os/root_js.gs.js +80 -0
  96. package/dist/gs/os/root_js.gs.js.map +1 -0
  97. package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
  98. package/dist/gs/os/root_nonwindows.gs.js +4 -0
  99. package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
  100. package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
  101. package/dist/gs/os/root_noopenat.gs.js +31 -0
  102. package/dist/gs/os/root_noopenat.gs.js.map +1 -0
  103. package/dist/gs/os/stat.gs.d.ts +24 -0
  104. package/dist/gs/os/stat.gs.js +20 -0
  105. package/dist/gs/os/stat.gs.js.map +1 -0
  106. package/dist/gs/os/stat_js.gs.d.ts +6 -0
  107. package/dist/gs/os/stat_js.gs.js +23 -0
  108. package/dist/gs/os/stat_js.gs.js.map +1 -0
  109. package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
  110. package/dist/gs/os/stat_unix_js.gs.js +16 -0
  111. package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
  112. package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
  113. package/dist/gs/os/sticky_bsd.gs.js +3 -0
  114. package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
  115. package/dist/gs/os/sys.gs.d.ts +2 -0
  116. package/dist/gs/os/sys.gs.js +10 -0
  117. package/dist/gs/os/sys.gs.js.map +1 -0
  118. package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
  119. package/dist/gs/os/sys_bsd.gs.js +15 -0
  120. package/dist/gs/os/sys_bsd.gs.js.map +1 -0
  121. package/dist/gs/os/sys_js.gs.d.ts +2 -0
  122. package/dist/gs/os/sys_js.gs.js +6 -0
  123. package/dist/gs/os/sys_js.gs.js.map +1 -0
  124. package/dist/gs/os/tempfile.gs.d.ts +5 -0
  125. package/dist/gs/os/tempfile.gs.js +30 -0
  126. package/dist/gs/os/tempfile.gs.js.map +1 -0
  127. package/dist/gs/os/types.gs.d.ts +59 -0
  128. package/dist/gs/os/types.gs.js +123 -0
  129. package/dist/gs/os/types.gs.js.map +1 -0
  130. package/dist/gs/os/types_js.gs.d.ts +74 -0
  131. package/dist/gs/os/types_js.gs.js +147 -0
  132. package/dist/gs/os/types_js.gs.js.map +1 -0
  133. package/dist/gs/os/types_unix.gs.d.ts +40 -0
  134. package/dist/gs/os/types_unix.gs.js +87 -0
  135. package/dist/gs/os/types_unix.gs.js.map +1 -0
  136. package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
  137. package/dist/gs/os/wait_unimp.gs.js +2 -0
  138. package/dist/gs/os/wait_unimp.gs.js.map +1 -0
  139. package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
  140. package/dist/gs/os/zero_copy_posix.gs.js +27 -0
  141. package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
  142. package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
  143. package/dist/gs/os/zero_copy_stub.gs.js +2 -0
  144. package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
  145. package/dist/gs/syscall/index.d.ts +80 -0
  146. package/dist/gs/syscall/index.js +163 -0
  147. package/dist/gs/syscall/index.js.map +1 -0
  148. package/gs/internal/byteorder/index.ts +40 -0
  149. package/gs/internal/testlog/index.ts +7 -0
  150. package/gs/os/dir.gs.ts +42 -0
  151. package/gs/os/dir_unix.gs.ts +155 -0
  152. package/gs/os/dirent_js.gs.ts +27 -0
  153. package/gs/os/env.gs.ts +179 -0
  154. package/gs/os/error.gs.ts +205 -0
  155. package/gs/os/error_errno.gs.ts +12 -0
  156. package/gs/os/exec.gs.ts +198 -0
  157. package/gs/os/exec_nohandle.gs.ts +2 -0
  158. package/gs/os/exec_posix.gs.ts +95 -0
  159. package/gs/os/exec_unix.gs.ts +64 -0
  160. package/gs/os/executable.gs.ts +18 -0
  161. package/gs/os/executable_js.gs.ts +6 -0
  162. package/gs/os/executable_wasm.gs.ts +10 -0
  163. package/gs/os/file_constants_js.gs.ts +98 -0
  164. package/gs/os/file_js.gs.ts +99 -0
  165. package/gs/os/file_open_unix.gs.ts +15 -0
  166. package/gs/os/file_posix_js.gs.ts +40 -0
  167. package/gs/os/file_unix_js.gs.ts +94 -0
  168. package/gs/os/getwd_js.gs.ts +28 -0
  169. package/gs/os/index.ts +19 -0
  170. package/gs/os/path.gs.ts +35 -0
  171. package/gs/os/path_unix.gs.ts +49 -0
  172. package/gs/os/pidfd_js.gs.ts +25 -0
  173. package/gs/os/pipe_wasm.gs.ts +17 -0
  174. package/gs/os/proc.gs.ts +84 -0
  175. package/gs/os/proc_js.gs.ts +15 -0
  176. package/gs/os/rawconn_js.gs.ts +30 -0
  177. package/gs/os/removeall_js.gs.ts +9 -0
  178. package/gs/os/root_js.gs.ts +111 -0
  179. package/gs/os/root_nonwindows.gs.ts +6 -0
  180. package/gs/os/root_noopenat.gs.ts +45 -0
  181. package/gs/os/stat.gs.ts +38 -0
  182. package/gs/os/stat_js.gs.ts +30 -0
  183. package/gs/os/stat_unix_js.gs.ts +27 -0
  184. package/gs/os/sticky_bsd.gs.ts +4 -0
  185. package/gs/os/sys.gs.ts +12 -0
  186. package/gs/os/sys_bsd.gs.ts +17 -0
  187. package/gs/os/sys_js.gs.ts +9 -0
  188. package/gs/os/tempfile.gs.ts +34 -0
  189. package/gs/os/types.gs.ts +170 -0
  190. package/gs/os/types_js.gs.ts +205 -0
  191. package/gs/os/types_unix.gs.ts +118 -0
  192. package/gs/os/wait_unimp.gs.ts +2 -0
  193. package/gs/os/zero_copy_posix.gs.ts +35 -0
  194. package/gs/os/zero_copy_stub.gs.ts +4 -0
  195. package/gs/syscall/index.ts +204 -0
  196. package/package.json +1 -1
@@ -0,0 +1,80 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ export type uintptr = number;
3
+ export interface Errno {
4
+ Error(): string;
5
+ Is(target: $.GoError): boolean;
6
+ Errno(): number;
7
+ }
8
+ export declare const O_RDONLY = 0;
9
+ export declare const O_WRONLY = 1;
10
+ export declare const O_RDWR = 2;
11
+ export declare const O_APPEND = 8;
12
+ export declare const O_CREATE = 64;
13
+ export declare const O_EXCL = 128;
14
+ export declare const O_SYNC = 256;
15
+ export declare const O_TRUNC = 512;
16
+ export declare const Stdin = 0;
17
+ export declare const Stdout = 1;
18
+ export declare const Stderr = 2;
19
+ export declare const SIGINT = 2;
20
+ export declare const SIGTERM = 15;
21
+ export declare const S_IFMT = 61440;
22
+ export declare const S_IFREG = 32768;
23
+ export declare const S_IFDIR = 16384;
24
+ export declare const S_IFLNK = 40960;
25
+ export declare const S_IFBLK = 24576;
26
+ export declare const S_IFCHR = 8192;
27
+ export declare const S_IFIFO = 4096;
28
+ export declare const S_IFSOCK = 49152;
29
+ export declare const S_ISUID = 2048;
30
+ export declare const S_ISGID = 1024;
31
+ export declare const S_ISVTX = 512;
32
+ export declare function Getenv(key: string): [string, boolean];
33
+ export declare function Setenv(key: string, value: string): $.GoError;
34
+ export declare function Unsetenv(key: string): $.GoError;
35
+ export declare function Clearenv(): void;
36
+ export declare function Environ(): $.Slice<string>;
37
+ export declare class Dirent {
38
+ Name: $.Bytes;
39
+ Reclen: number;
40
+ constructor(init?: any);
41
+ }
42
+ export declare class Stat_t {
43
+ Dev: number;
44
+ Ino: number;
45
+ Mode: number;
46
+ Nlink: number;
47
+ Uid: number;
48
+ Gid: number;
49
+ Rdev: number;
50
+ Size: number;
51
+ Blksize: number;
52
+ Blocks: number;
53
+ Atime: number;
54
+ Mtime: number;
55
+ Ctime: number;
56
+ AtimeNsec: number;
57
+ MtimeNsec: number;
58
+ CtimeNsec: number;
59
+ constructor(init?: any);
60
+ clone(): Stat_t;
61
+ }
62
+ export interface RawConn {
63
+ Control(f: (fd: uintptr) => void): $.GoError;
64
+ Read(f: (fd: uintptr) => boolean): $.GoError;
65
+ Write(f: (fd: uintptr) => boolean): $.GoError;
66
+ }
67
+ export declare class StubRawConn implements RawConn {
68
+ Control(f: (fd: uintptr) => void): $.GoError;
69
+ Read(f: (fd: uintptr) => boolean): $.GoError;
70
+ Write(f: (fd: uintptr) => boolean): $.GoError;
71
+ }
72
+ export declare const ENOSYS: Errno;
73
+ export declare const EISDIR: Errno;
74
+ export declare const ENOTDIR: Errno;
75
+ export declare const ERANGE: Errno;
76
+ export declare const ENOMEM: Errno;
77
+ export declare const ESRCH: Errno;
78
+ export declare function Open(path: string, flag: number, perm: number): [number, $.GoError];
79
+ export declare function Sysctl(name: string): [string, $.GoError];
80
+ export declare function Getpagesize(): number;
@@ -0,0 +1,163 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ // Essential syscall constants
3
+ export const O_RDONLY = 0;
4
+ export const O_WRONLY = 1;
5
+ export const O_RDWR = 2;
6
+ export const O_APPEND = 8;
7
+ export const O_CREATE = 64;
8
+ export const O_EXCL = 128;
9
+ export const O_SYNC = 256;
10
+ export const O_TRUNC = 512;
11
+ export const Stdin = 0;
12
+ export const Stdout = 1;
13
+ export const Stderr = 2;
14
+ export const SIGINT = 2;
15
+ export const SIGTERM = 15;
16
+ // File mode constants
17
+ export const S_IFMT = 0o170000;
18
+ export const S_IFREG = 0o100000;
19
+ export const S_IFDIR = 0o040000;
20
+ export const S_IFLNK = 0o120000;
21
+ export const S_IFBLK = 0o060000;
22
+ export const S_IFCHR = 0o020000;
23
+ export const S_IFIFO = 0o010000;
24
+ export const S_IFSOCK = 0o140000;
25
+ export const S_ISUID = 0o004000;
26
+ export const S_ISGID = 0o002000;
27
+ export const S_ISVTX = 0o001000;
28
+ // Environment variable functions using Node.js/browser APIs
29
+ export function Getenv(key) {
30
+ if (typeof process !== 'undefined' && process.env) {
31
+ const value = process.env[key];
32
+ return value !== undefined ? [value, true] : ["", false];
33
+ }
34
+ return ["", false];
35
+ }
36
+ export function Setenv(key, value) {
37
+ if (typeof process !== 'undefined' && process.env) {
38
+ process.env[key] = value;
39
+ return null;
40
+ }
41
+ return { Error: () => "setenv not supported" };
42
+ }
43
+ export function Unsetenv(key) {
44
+ if (typeof process !== 'undefined' && process.env) {
45
+ delete process.env[key];
46
+ return null;
47
+ }
48
+ return { Error: () => "unsetenv not supported" };
49
+ }
50
+ export function Clearenv() {
51
+ if (typeof process !== 'undefined' && process.env) {
52
+ for (const key in process.env) {
53
+ delete process.env[key];
54
+ }
55
+ }
56
+ }
57
+ export function Environ() {
58
+ if (typeof process !== 'undefined' && process.env) {
59
+ const env = [];
60
+ for (const [key, value] of Object.entries(process.env)) {
61
+ if (value !== undefined) {
62
+ env.push(`${key}=${value}`);
63
+ }
64
+ }
65
+ return $.arrayToSlice(env);
66
+ }
67
+ return $.arrayToSlice([]);
68
+ }
69
+ // Dirent structure with Reclen field
70
+ export class Dirent {
71
+ Name = new Uint8Array(0);
72
+ Reclen = 0;
73
+ constructor(init) {
74
+ if (init?.Name)
75
+ this.Name = init.Name;
76
+ if (init?.Reclen)
77
+ this.Reclen = init.Reclen;
78
+ }
79
+ }
80
+ // Stat_t structure stub
81
+ export class Stat_t {
82
+ Dev = 0;
83
+ Ino = 0;
84
+ Mode = 0;
85
+ Nlink = 0;
86
+ Uid = 0;
87
+ Gid = 0;
88
+ Rdev = 0;
89
+ Size = 0;
90
+ Blksize = 0;
91
+ Blocks = 0;
92
+ Atime = 0;
93
+ Mtime = 0;
94
+ Ctime = 0;
95
+ AtimeNsec = 0;
96
+ MtimeNsec = 0;
97
+ CtimeNsec = 0;
98
+ constructor(init) {
99
+ if (init) {
100
+ Object.assign(this, init);
101
+ }
102
+ }
103
+ clone() {
104
+ return new Stat_t(this);
105
+ }
106
+ }
107
+ // Stub implementation of RawConn that always returns ErrUnimplemented
108
+ export class StubRawConn {
109
+ Control(f) {
110
+ return { Error: () => "operation not implemented in JavaScript environment" };
111
+ }
112
+ Read(f) {
113
+ return { Error: () => "operation not implemented in JavaScript environment" };
114
+ }
115
+ Write(f) {
116
+ return { Error: () => "operation not implemented in JavaScript environment" };
117
+ }
118
+ }
119
+ // Additional error constants - implement as Errno type
120
+ export const ENOSYS = {
121
+ Error: () => "function not implemented",
122
+ Is: (target) => target === ENOSYS,
123
+ Errno: () => 38
124
+ };
125
+ export const EISDIR = {
126
+ Error: () => "is a directory",
127
+ Is: (target) => target === EISDIR,
128
+ Errno: () => 21
129
+ };
130
+ export const ENOTDIR = {
131
+ Error: () => "not a directory",
132
+ Is: (target) => target === ENOTDIR,
133
+ Errno: () => 20
134
+ };
135
+ export const ERANGE = {
136
+ Error: () => "result too large",
137
+ Is: (target) => target === ERANGE,
138
+ Errno: () => 34
139
+ };
140
+ export const ENOMEM = {
141
+ Error: () => "out of memory",
142
+ Is: (target) => target === ENOMEM,
143
+ Errno: () => 12
144
+ };
145
+ export const ESRCH = {
146
+ Error: () => "no such process",
147
+ Is: (target) => target === ESRCH,
148
+ Errno: () => 3
149
+ };
150
+ // Additional missing syscall functions
151
+ export function Open(path, flag, perm) {
152
+ return [-1, ENOSYS];
153
+ }
154
+ export function Sysctl(name) {
155
+ return ["", ENOSYS];
156
+ }
157
+ // Getpagesize returns the underlying system's memory page size.
158
+ export function Getpagesize() {
159
+ // Return a standard page size for JavaScript environment
160
+ // Most systems use 4096 bytes as the default page size
161
+ return 4096;
162
+ }
163
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/syscall/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAYlD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AACzB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AACzB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AACvB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AACzB,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAA;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;AACzB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAA;AACtB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AAEvB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AACvB,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAA;AAEzB,wBAAwB;AACxB,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AAED,uCAAuC;AACvC,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,IAAY,EAAE,IAAY;IAC3D,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;AACrB,CAAC;AAID,gEAAgE;AAChE,MAAM,UAAU,WAAW;IACzB,yDAAyD;IACzD,uDAAuD;IACvD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,40 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ // Stub implementations for internal/byteorder package
4
+ export function LittleEndian(): boolean {
5
+ return true // Assume little endian for JS
6
+ }
7
+
8
+ // Big Endian byte order functions
9
+ export function BEUint16(b: $.Bytes): number {
10
+ return (b![0] << 8) | b![1]
11
+ }
12
+
13
+ export function BEUint32(b: $.Bytes): number {
14
+ return (b![0] << 24) | (b![1] << 16) | (b![2] << 8) | b![3]
15
+ }
16
+
17
+ export function BEUint64(b: $.Bytes): number {
18
+ // JavaScript numbers are 64-bit floats, so we'll lose precision for very large integers
19
+ // For our stub purposes, this should be sufficient
20
+ let high = BEUint32(b)
21
+ let low = BEUint32($.goSlice(b, 4, undefined))
22
+ return (high * 0x100000000) + low
23
+ }
24
+
25
+ // Little Endian byte order functions
26
+ export function LEUint16(b: $.Bytes): number {
27
+ return b![0] | (b![1] << 8)
28
+ }
29
+
30
+ export function LEUint32(b: $.Bytes): number {
31
+ return b![0] | (b![1] << 8) | (b![2] << 16) | (b![3] << 24)
32
+ }
33
+
34
+ export function LEUint64(b: $.Bytes): number {
35
+ // JavaScript numbers are 64-bit floats, so we'll lose precision for very large integers
36
+ // For our stub purposes, this should be sufficient
37
+ let low = LEUint32(b)
38
+ let high = LEUint32($.goSlice(b, 4, undefined))
39
+ return low + (high * 0x100000000)
40
+ }
@@ -0,0 +1,7 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ // Stub implementations for internal/testlog package
4
+
5
+ export function Getenv(key: string): void {
6
+ // Stub for test logging - no-op in runtime
7
+ }
@@ -0,0 +1,42 @@
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
+ type DirEntry = fs.DirEntry;
7
+
8
+ // ReadDir reads the named directory,
9
+ // returning all its directory entries sorted by filename.
10
+ // If an error occurs reading the directory,
11
+ // ReadDir returns the entries it was able to read before the error,
12
+ // along with the error.
13
+ export function ReadDir(name: string): [$.Slice<DirEntry>, $.GoError] {
14
+ // Directory reading not supported in JavaScript environment
15
+ return [null, ErrUnimplemented]
16
+ }
17
+
18
+ // CopyFS copies the file system fsys into the directory dir,
19
+ // creating dir if necessary.
20
+ //
21
+ // Files are created with mode 0o666 plus any execute permissions
22
+ // from the source, and directories are created with mode 0o777
23
+ // (before umask).
24
+ //
25
+ // CopyFS will not overwrite existing files. If a file name in fsys
26
+ // already exists in the destination, CopyFS will return an error
27
+ // such that errors.Is(err, fs.ErrExist) will be true.
28
+ //
29
+ // Symbolic links in fsys are not supported. A *PathError with Err set
30
+ // to ErrInvalid is returned when copying from a symbolic link.
31
+ //
32
+ // Symbolic links in dir are followed.
33
+ //
34
+ // New files added to fsys (including if dir is a subdirectory of fsys)
35
+ // while CopyFS is running are not guaranteed to be copied.
36
+ //
37
+ // Copying stops at and returns the first error encountered.
38
+ export function CopyFS(dir: string, fsys: fs.FS): $.GoError {
39
+ // File system copying not supported in JavaScript environment
40
+ return ErrUnimplemented
41
+ }
42
+
@@ -0,0 +1,155 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { direntIno, direntNamlen, direntReclen, direntType } from "./dirent_js.gs.js";
3
+ import { IsNotExist } from "./error.gs.js";
4
+ import { newUnixDirent } from "./file_unix_js.gs.js";
5
+
6
+ import * as byteorder from "@goscript/internal/byteorder/index.js"
7
+
8
+ import * as goarch from "@goscript/internal/goarch/index.js"
9
+
10
+ import * as io from "@goscript/io/index.js"
11
+
12
+ import * as runtime from "@goscript/runtime/index.js"
13
+
14
+ import * as sync from "@goscript/sync/index.js"
15
+
16
+ import * as syscall from "@goscript/syscall/index.js"
17
+
18
+ import * as unsafe from "@goscript/unsafe/index.js"
19
+
20
+ // Import uintptr type
21
+ type uintptr = syscall.uintptr
22
+
23
+ class dirInfo {
24
+ public get mu(): sync.Mutex {
25
+ return this._fields.mu.value
26
+ }
27
+ public set mu(value: sync.Mutex) {
28
+ this._fields.mu.value = value
29
+ }
30
+
31
+ // buffer for directory I/O
32
+ public get buf(): $.VarRef<$.Bytes> | null {
33
+ return this._fields.buf.value
34
+ }
35
+ public set buf(value: $.VarRef<$.Bytes> | null) {
36
+ this._fields.buf.value = value
37
+ }
38
+
39
+ // length of buf; return value from Getdirentries
40
+ public get nbuf(): number {
41
+ return this._fields.nbuf.value
42
+ }
43
+ public set nbuf(value: number) {
44
+ this._fields.nbuf.value = value
45
+ }
46
+
47
+ // location of next record in buf.
48
+ public get bufp(): number {
49
+ return this._fields.bufp.value
50
+ }
51
+ public set bufp(value: number) {
52
+ this._fields.bufp.value = value
53
+ }
54
+
55
+ public _fields: {
56
+ mu: $.VarRef<sync.Mutex>;
57
+ buf: $.VarRef<$.VarRef<$.Bytes> | null>;
58
+ nbuf: $.VarRef<number>;
59
+ bufp: $.VarRef<number>;
60
+ }
61
+
62
+ constructor(init?: Partial<{buf?: $.VarRef<$.Bytes> | null, bufp?: number, mu?: sync.Mutex, nbuf?: number}>) {
63
+ this._fields = {
64
+ mu: $.varRef(init?.mu?.clone() ?? new sync.Mutex()),
65
+ buf: $.varRef(init?.buf ?? null),
66
+ nbuf: $.varRef(init?.nbuf ?? 0),
67
+ bufp: $.varRef(init?.bufp ?? 0)
68
+ }
69
+ }
70
+
71
+ public clone(): dirInfo {
72
+ const cloned = new dirInfo()
73
+ cloned._fields = {
74
+ mu: $.varRef(this._fields.mu.value?.clone() ?? null),
75
+ buf: $.varRef(this._fields.buf.value),
76
+ nbuf: $.varRef(this._fields.nbuf.value),
77
+ bufp: $.varRef(this._fields.bufp.value)
78
+ }
79
+ return cloned
80
+ }
81
+
82
+ public close(): void {
83
+ const d = this
84
+ if (d.buf != null) {
85
+ dirBufPool.Put(d.buf)
86
+ d.buf = null
87
+ }
88
+ }
89
+
90
+ // Register this type with the runtime type system
91
+ static __typeInfo = $.registerStructType(
92
+ 'dirInfo',
93
+ new dirInfo(),
94
+ [{ name: "close", args: [], returns: [] }],
95
+ dirInfo,
96
+ {"mu": "Mutex", "buf": { kind: $.TypeKind.Pointer, elemType: { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "number" } } }, "nbuf": { kind: $.TypeKind.Basic, name: "number" }, "bufp": { kind: $.TypeKind.Basic, name: "number" }}
97
+ );
98
+ }
99
+
100
+ // More than 5760 to work around https://golang.org/issue/24015.
101
+ let blockSize: number = 8192
102
+
103
+ let dirBufPool: sync.Pool = new sync.Pool({New: (): null | any => {
104
+ // The buffer must be at least a block long.
105
+ let buf = new Uint8Array(8192)
106
+ return buf
107
+ }})
108
+
109
+ // readInt returns the size-bytes unsigned integer in native byte order at offset off.
110
+ export function readInt(b: $.Bytes, off: uintptr, size: uintptr): [number, boolean] {
111
+ let u: number = 0
112
+ let ok: boolean = false
113
+ {
114
+ if ($.len(b) < $.int(off + size)) {
115
+ return [0, false]
116
+ }
117
+ if (goarch.BigEndian) {
118
+ return [readIntBE($.goSlice(b, off, undefined), size), true]
119
+ }
120
+ return [readIntLE($.goSlice(b, off, undefined), size), true]
121
+ }
122
+ }
123
+
124
+ export function readIntBE(b: $.Bytes, size: uintptr): number {
125
+ switch (size) {
126
+ case 1:
127
+ return (b![0] as number)
128
+ case 2:
129
+ return (byteorder.BEUint16(b) as number)
130
+ case 4:
131
+ return (byteorder.BEUint32(b) as number)
132
+ case 8:
133
+ return (byteorder.BEUint64(b) as number)
134
+ default:
135
+ $.panic("syscall: readInt with unsupported size")
136
+ return 0 // This line will never be reached due to panic, but satisfies TypeScript
137
+ }
138
+ }
139
+
140
+ export function readIntLE(b: $.Bytes, size: uintptr): number {
141
+ switch (size) {
142
+ case 1:
143
+ return (b![0] as number)
144
+ case 2:
145
+ return (byteorder.LEUint16(b) as number)
146
+ case 4:
147
+ return (byteorder.LEUint32(b) as number)
148
+ case 8:
149
+ return (byteorder.LEUint64(b) as number)
150
+ default:
151
+ $.panic("syscall: readInt with unsupported size")
152
+ return 0 // This line will never be reached due to panic, but satisfies TypeScript
153
+ }
154
+ }
155
+
@@ -0,0 +1,27 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { readInt } from "./dir_unix.gs.js";
3
+
4
+ import * as syscall from "@goscript/syscall/index.js"
5
+
6
+ import * as unsafe from "@goscript/unsafe/index.js"
7
+
8
+ export function direntIno(buf: $.Bytes): [number, boolean] {
9
+ return [1, true]
10
+ }
11
+
12
+ export function direntReclen(buf: $.Bytes): [number, boolean] {
13
+ return readInt(buf, unsafe.Offsetof(new syscall.Dirent({}).Reclen), unsafe.Sizeof(new syscall.Dirent({}).Reclen))
14
+ }
15
+
16
+ export function direntNamlen(buf: $.Bytes): [number, boolean] {
17
+ let [reclen, ok] = direntReclen(buf)
18
+ if (!ok) {
19
+ return [0, false]
20
+ }
21
+ return [reclen - (unsafe.Offsetof(new syscall.Dirent({}).Name) as number), true]
22
+ }
23
+
24
+ export function direntType(buf: $.Bytes): number {
25
+ return ~(0 as number)
26
+ }
27
+