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.
Files changed (228) hide show
  1. package/compiler/expr-call.go +26 -0
  2. package/compiler/spec-struct.go +41 -8
  3. package/compiler/spec-value.go +4 -0
  4. package/compiler/spec.go +1 -1
  5. package/compiler/stmt.go +26 -8
  6. package/dist/gs/internal/byteorder/index.d.ts +8 -0
  7. package/dist/gs/internal/byteorder/index.js +34 -0
  8. package/dist/gs/internal/byteorder/index.js.map +1 -0
  9. package/dist/gs/internal/testlog/index.d.ts +1 -0
  10. package/dist/gs/internal/testlog/index.js +5 -0
  11. package/dist/gs/internal/testlog/index.js.map +1 -0
  12. package/dist/gs/maps/iter.d.ts +1 -1
  13. package/dist/gs/os/dir.gs.d.ts +6 -0
  14. package/dist/gs/os/dir.gs.js +35 -0
  15. package/dist/gs/os/dir.gs.js.map +1 -0
  16. package/dist/gs/os/dir_unix.gs.d.ts +7 -0
  17. package/dist/gs/os/dir_unix.gs.js +113 -0
  18. package/dist/gs/os/dir_unix.gs.js.map +1 -0
  19. package/dist/gs/os/dirent_js.gs.d.ts +5 -0
  20. package/dist/gs/os/dirent_js.gs.js +20 -0
  21. package/dist/gs/os/dirent_js.gs.js.map +1 -0
  22. package/dist/gs/os/env.gs.d.ts +12 -0
  23. package/dist/gs/os/env.gs.js +157 -0
  24. package/dist/gs/os/env.gs.js.map +1 -0
  25. package/dist/gs/os/error.gs.d.ts +40 -0
  26. package/dist/gs/os/error.gs.js +158 -0
  27. package/dist/gs/os/error.gs.js.map +1 -0
  28. package/dist/gs/os/error_errno.gs.d.ts +1 -0
  29. package/dist/gs/os/error_errno.gs.js +5 -0
  30. package/dist/gs/os/error_errno.gs.js.map +1 -0
  31. package/dist/gs/os/exec.gs.d.ts +60 -0
  32. package/dist/gs/os/exec.gs.js +136 -0
  33. package/dist/gs/os/exec.gs.js.map +1 -0
  34. package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
  35. package/dist/gs/os/exec_nohandle.gs.js +2 -0
  36. package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
  37. package/dist/gs/os/exec_posix.gs.d.ts +25 -0
  38. package/dist/gs/os/exec_posix.gs.js +67 -0
  39. package/dist/gs/os/exec_posix.gs.js.map +1 -0
  40. package/dist/gs/os/exec_unix.gs.d.ts +4 -0
  41. package/dist/gs/os/exec_unix.gs.js +46 -0
  42. package/dist/gs/os/exec_unix.gs.js.map +1 -0
  43. package/dist/gs/os/executable.gs.d.ts +2 -0
  44. package/dist/gs/os/executable.gs.js +16 -0
  45. package/dist/gs/os/executable.gs.js.map +1 -0
  46. package/dist/gs/os/executable_js.gs.d.ts +2 -0
  47. package/dist/gs/os/executable_js.gs.js +5 -0
  48. package/dist/gs/os/executable_js.gs.js.map +1 -0
  49. package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
  50. package/dist/gs/os/executable_wasm.gs.js +6 -0
  51. package/dist/gs/os/executable_wasm.gs.js.map +1 -0
  52. package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
  53. package/dist/gs/os/file_constants_js.gs.js +78 -0
  54. package/dist/gs/os/file_constants_js.gs.js.map +1 -0
  55. package/dist/gs/os/file_js.gs.d.ts +22 -0
  56. package/dist/gs/os/file_js.gs.js +73 -0
  57. package/dist/gs/os/file_js.gs.js.map +1 -0
  58. package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
  59. package/dist/gs/os/file_open_unix.gs.js +10 -0
  60. package/dist/gs/os/file_open_unix.gs.js.map +1 -0
  61. package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
  62. package/dist/gs/os/file_posix_js.gs.js +32 -0
  63. package/dist/gs/os/file_posix_js.gs.js.map +1 -0
  64. package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
  65. package/dist/gs/os/file_unix_js.gs.js +64 -0
  66. package/dist/gs/os/file_unix_js.gs.js.map +1 -0
  67. package/dist/gs/os/getwd_js.gs.d.ts +6 -0
  68. package/dist/gs/os/getwd_js.gs.js +21 -0
  69. package/dist/gs/os/getwd_js.gs.js.map +1 -0
  70. package/dist/gs/os/index.d.ts +19 -0
  71. package/dist/gs/os/index.js +20 -0
  72. package/dist/gs/os/index.js.map +1 -0
  73. package/dist/gs/os/path.gs.d.ts +4 -0
  74. package/dist/gs/os/path.gs.js +32 -0
  75. package/dist/gs/os/path.gs.js.map +1 -0
  76. package/dist/gs/os/path_unix.gs.d.ts +4 -0
  77. package/dist/gs/os/path_unix.gs.js +40 -0
  78. package/dist/gs/os/path_unix.gs.js.map +1 -0
  79. package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
  80. package/dist/gs/os/pidfd_js.gs.js +14 -0
  81. package/dist/gs/os/pidfd_js.gs.js.map +1 -0
  82. package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
  83. package/dist/gs/os/pipe_wasm.gs.js +14 -0
  84. package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
  85. package/dist/gs/os/proc.gs.d.ts +11 -0
  86. package/dist/gs/os/proc.gs.js +68 -0
  87. package/dist/gs/os/proc.gs.js.map +1 -0
  88. package/dist/gs/os/proc_js.gs.d.ts +3 -0
  89. package/dist/gs/os/proc_js.gs.js +12 -0
  90. package/dist/gs/os/proc_js.gs.js.map +1 -0
  91. package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
  92. package/dist/gs/os/rawconn_js.gs.js +26 -0
  93. package/dist/gs/os/rawconn_js.gs.js.map +1 -0
  94. package/dist/gs/os/removeall_js.gs.d.ts +2 -0
  95. package/dist/gs/os/removeall_js.gs.js +7 -0
  96. package/dist/gs/os/removeall_js.gs.js.map +1 -0
  97. package/dist/gs/os/root_js.gs.d.ts +23 -0
  98. package/dist/gs/os/root_js.gs.js +80 -0
  99. package/dist/gs/os/root_js.gs.js.map +1 -0
  100. package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
  101. package/dist/gs/os/root_nonwindows.gs.js +4 -0
  102. package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
  103. package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
  104. package/dist/gs/os/root_noopenat.gs.js +31 -0
  105. package/dist/gs/os/root_noopenat.gs.js.map +1 -0
  106. package/dist/gs/os/stat.gs.d.ts +24 -0
  107. package/dist/gs/os/stat.gs.js +20 -0
  108. package/dist/gs/os/stat.gs.js.map +1 -0
  109. package/dist/gs/os/stat_js.gs.d.ts +6 -0
  110. package/dist/gs/os/stat_js.gs.js +23 -0
  111. package/dist/gs/os/stat_js.gs.js.map +1 -0
  112. package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
  113. package/dist/gs/os/stat_unix_js.gs.js +16 -0
  114. package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
  115. package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
  116. package/dist/gs/os/sticky_bsd.gs.js +3 -0
  117. package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
  118. package/dist/gs/os/sys.gs.d.ts +2 -0
  119. package/dist/gs/os/sys.gs.js +10 -0
  120. package/dist/gs/os/sys.gs.js.map +1 -0
  121. package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
  122. package/dist/gs/os/sys_bsd.gs.js +15 -0
  123. package/dist/gs/os/sys_bsd.gs.js.map +1 -0
  124. package/dist/gs/os/sys_js.gs.d.ts +2 -0
  125. package/dist/gs/os/sys_js.gs.js +6 -0
  126. package/dist/gs/os/sys_js.gs.js.map +1 -0
  127. package/dist/gs/os/tempfile.gs.d.ts +5 -0
  128. package/dist/gs/os/tempfile.gs.js +30 -0
  129. package/dist/gs/os/tempfile.gs.js.map +1 -0
  130. package/dist/gs/os/types.gs.d.ts +59 -0
  131. package/dist/gs/os/types.gs.js +123 -0
  132. package/dist/gs/os/types.gs.js.map +1 -0
  133. package/dist/gs/os/types_js.gs.d.ts +74 -0
  134. package/dist/gs/os/types_js.gs.js +147 -0
  135. package/dist/gs/os/types_js.gs.js.map +1 -0
  136. package/dist/gs/os/types_unix.gs.d.ts +40 -0
  137. package/dist/gs/os/types_unix.gs.js +87 -0
  138. package/dist/gs/os/types_unix.gs.js.map +1 -0
  139. package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
  140. package/dist/gs/os/wait_unimp.gs.js +2 -0
  141. package/dist/gs/os/wait_unimp.gs.js.map +1 -0
  142. package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
  143. package/dist/gs/os/zero_copy_posix.gs.js +27 -0
  144. package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
  145. package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
  146. package/dist/gs/os/zero_copy_stub.gs.js +2 -0
  147. package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
  148. package/dist/gs/sync/atomic/doc.gs.d.ts +28 -0
  149. package/dist/gs/sync/atomic/doc.gs.js +265 -0
  150. package/dist/gs/sync/atomic/doc.gs.js.map +1 -0
  151. package/dist/gs/sync/atomic/doc_64.gs.d.ts +15 -0
  152. package/dist/gs/sync/atomic/doc_64.gs.js +165 -0
  153. package/dist/gs/sync/atomic/doc_64.gs.js.map +1 -0
  154. package/dist/gs/sync/atomic/index.d.ts +4 -0
  155. package/dist/gs/sync/atomic/index.js +5 -0
  156. package/dist/gs/sync/atomic/index.js.map +1 -0
  157. package/dist/gs/sync/atomic/type.gs.d.ts +130 -0
  158. package/dist/gs/sync/atomic/type.gs.js +433 -0
  159. package/dist/gs/sync/atomic/type.gs.js.map +1 -0
  160. package/dist/gs/sync/atomic/value.gs.d.ts +19 -0
  161. package/dist/gs/sync/atomic/value.gs.js +116 -0
  162. package/dist/gs/sync/atomic/value.gs.js.map +1 -0
  163. package/dist/gs/syscall/index.d.ts +80 -0
  164. package/dist/gs/syscall/index.js +163 -0
  165. package/dist/gs/syscall/index.js.map +1 -0
  166. package/dist/gs/unsafe/unsafe.d.ts +1 -0
  167. package/dist/gs/unsafe/unsafe.js +5 -0
  168. package/dist/gs/unsafe/unsafe.js.map +1 -1
  169. package/gs/internal/byteorder/index.ts +40 -0
  170. package/gs/internal/testlog/index.ts +7 -0
  171. package/gs/maps/iter.ts +1 -1
  172. package/gs/math/erfinv.gs.test.ts +2 -2
  173. package/gs/math/fma.gs.test.ts +5 -5
  174. package/gs/math/ldexp.gs.test.ts +5 -5
  175. package/gs/math/lgamma.gs.test.ts +2 -2
  176. package/gs/os/dir.gs.ts +42 -0
  177. package/gs/os/dir_unix.gs.ts +155 -0
  178. package/gs/os/dirent_js.gs.ts +27 -0
  179. package/gs/os/env.gs.ts +179 -0
  180. package/gs/os/error.gs.ts +205 -0
  181. package/gs/os/error_errno.gs.ts +12 -0
  182. package/gs/os/exec.gs.ts +198 -0
  183. package/gs/os/exec_nohandle.gs.ts +2 -0
  184. package/gs/os/exec_posix.gs.ts +95 -0
  185. package/gs/os/exec_unix.gs.ts +64 -0
  186. package/gs/os/executable.gs.ts +18 -0
  187. package/gs/os/executable_js.gs.ts +6 -0
  188. package/gs/os/executable_wasm.gs.ts +10 -0
  189. package/gs/os/file_constants_js.gs.ts +98 -0
  190. package/gs/os/file_js.gs.ts +99 -0
  191. package/gs/os/file_open_unix.gs.ts +15 -0
  192. package/gs/os/file_posix_js.gs.ts +40 -0
  193. package/gs/os/file_unix_js.gs.ts +94 -0
  194. package/gs/os/getwd_js.gs.ts +28 -0
  195. package/gs/os/index.ts +19 -0
  196. package/gs/os/path.gs.ts +35 -0
  197. package/gs/os/path_unix.gs.ts +49 -0
  198. package/gs/os/pidfd_js.gs.ts +25 -0
  199. package/gs/os/pipe_wasm.gs.ts +17 -0
  200. package/gs/os/proc.gs.ts +84 -0
  201. package/gs/os/proc_js.gs.ts +15 -0
  202. package/gs/os/rawconn_js.gs.ts +30 -0
  203. package/gs/os/removeall_js.gs.ts +9 -0
  204. package/gs/os/root_js.gs.ts +111 -0
  205. package/gs/os/root_nonwindows.gs.ts +6 -0
  206. package/gs/os/root_noopenat.gs.ts +45 -0
  207. package/gs/os/stat.gs.ts +38 -0
  208. package/gs/os/stat_js.gs.ts +30 -0
  209. package/gs/os/stat_unix_js.gs.ts +27 -0
  210. package/gs/os/sticky_bsd.gs.ts +4 -0
  211. package/gs/os/sys.gs.ts +12 -0
  212. package/gs/os/sys_bsd.gs.ts +17 -0
  213. package/gs/os/sys_js.gs.ts +9 -0
  214. package/gs/os/tempfile.gs.ts +34 -0
  215. package/gs/os/types.gs.ts +170 -0
  216. package/gs/os/types_js.gs.ts +205 -0
  217. package/gs/os/types_unix.gs.ts +118 -0
  218. package/gs/os/wait_unimp.gs.ts +2 -0
  219. package/gs/os/zero_copy_posix.gs.ts +35 -0
  220. package/gs/os/zero_copy_stub.gs.ts +4 -0
  221. package/gs/sync/atomic/doc.gs.ts +276 -0
  222. package/gs/sync/atomic/doc_64.gs.ts +168 -0
  223. package/gs/sync/atomic/index.ts +4 -0
  224. package/gs/sync/atomic/type.gs.ts +596 -0
  225. package/gs/sync/atomic/value.gs.ts +158 -0
  226. package/gs/syscall/index.ts +204 -0
  227. package/gs/unsafe/unsafe.ts +6 -0
  228. package/package.json +1 -1
@@ -0,0 +1,158 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { CompareAndSwapPointer, LoadPointer, StorePointer, SwapPointer } from "./doc.gs.js";
3
+
4
+ import * as unsafe from "@goscript/unsafe/index.js"
5
+
6
+ // Pointer type for use in efaceWords
7
+ type Pointer = any;
8
+
9
+ // firstStoreInProgress is a placeholder value used during the first store operation
10
+ const firstStoreInProgress = Symbol('firstStoreInProgress');
11
+
12
+ export class Value {
13
+ public get v(): null | any {
14
+ return this._fields.v.value
15
+ }
16
+ public set v(value: null | any) {
17
+ this._fields.v.value = value
18
+ }
19
+
20
+ public _fields: {
21
+ v: $.VarRef<null | any>;
22
+ }
23
+
24
+ constructor(init?: Partial<{v?: null | any}>) {
25
+ this._fields = {
26
+ v: $.varRef(init?.v ?? null)
27
+ }
28
+ }
29
+
30
+ public clone(): Value {
31
+ const cloned = new Value()
32
+ cloned._fields = {
33
+ v: $.varRef(this._fields.v.value)
34
+ }
35
+ return cloned
36
+ }
37
+
38
+ // Load returns the value set by the most recent Store.
39
+ // It returns nil if there has been no call to Store for this Value.
40
+ public Load(): null | any {
41
+ const v = this
42
+ // For JavaScript, we can simplify this since we're single-threaded
43
+ // Just return the stored value directly
44
+ return v._fields.v.value
45
+ }
46
+
47
+ // Store sets the value of the [Value] v to val.
48
+ // All calls to Store for a given Value must use values of the same concrete type.
49
+ // Store of an inconsistent type panics, as does Store(nil).
50
+ public Store(val: null | any): void {
51
+ const v = this
52
+ if (val == null) {
53
+ $.panic("sync/atomic: store of nil value into Value")
54
+ }
55
+ // For JavaScript, store the value directly
56
+ v._fields.v.value = val
57
+ }
58
+
59
+ // Swap stores new into Value and returns the previous value. It returns nil if
60
+ // the Value is empty.
61
+ //
62
+ // All calls to Swap for a given Value must use values of the same concrete
63
+ // type. Swap of an inconsistent type panics, as does Swap(nil).
64
+ public Swap(_new: null | any): null | any {
65
+ const v = this
66
+ if (_new == null) {
67
+ $.panic("sync/atomic: swap of nil value into Value")
68
+ }
69
+ // For JavaScript, swap the values directly
70
+ const old = v._fields.v.value
71
+ v._fields.v.value = _new
72
+ return old
73
+ }
74
+
75
+ // CompareAndSwap executes the compare-and-swap operation for the [Value].
76
+ //
77
+ // All calls to CompareAndSwap for a given Value must use values of the same
78
+ // concrete type. CompareAndSwap of an inconsistent type panics, as does
79
+ // CompareAndSwap(old, nil).
80
+ public CompareAndSwap(old: null | any, _new: null | any): boolean {
81
+ const v = this
82
+ if (_new == null) {
83
+ $.panic("sync/atomic: compare and swap of nil value into Value")
84
+ }
85
+ // For JavaScript, compare and swap directly
86
+ if (v._fields.v.value === old) {
87
+ v._fields.v.value = _new
88
+ return true
89
+ }
90
+ return false
91
+ }
92
+
93
+ // Register this type with the runtime type system
94
+ static __typeInfo = $.registerStructType(
95
+ 'Value',
96
+ new Value(),
97
+ [{ name: "Load", args: [], returns: [{ type: { kind: $.TypeKind.Interface, methods: [] } }] }, { name: "Store", args: [{ name: "val", type: { kind: $.TypeKind.Interface, methods: [] } }], returns: [] }, { name: "Swap", args: [{ name: "new", type: { kind: $.TypeKind.Interface, methods: [] } }], returns: [{ type: { kind: $.TypeKind.Interface, methods: [] } }] }, { name: "CompareAndSwap", args: [{ name: "old", type: { kind: $.TypeKind.Interface, methods: [] } }, { name: "new", type: { kind: $.TypeKind.Interface, methods: [] } }], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] }],
98
+ Value,
99
+ {"v": { kind: $.TypeKind.Interface, methods: [] }}
100
+ );
101
+ }
102
+
103
+
104
+ class efaceWords {
105
+ public get typ(): Pointer {
106
+ return this._fields.typ.value
107
+ }
108
+ public set typ(value: Pointer) {
109
+ this._fields.typ.value = value
110
+ }
111
+
112
+ public get data(): Pointer {
113
+ return this._fields.data.value
114
+ }
115
+ public set data(value: Pointer) {
116
+ this._fields.data.value = value
117
+ }
118
+
119
+ public _fields: {
120
+ typ: $.VarRef<Pointer>;
121
+ data: $.VarRef<Pointer>;
122
+ }
123
+
124
+ constructor(init?: Partial<{data?: Pointer, typ?: Pointer}>) {
125
+ this._fields = {
126
+ typ: $.varRef(init?.typ ?? null),
127
+ data: $.varRef(init?.data ?? null)
128
+ }
129
+ }
130
+
131
+ public clone(): efaceWords {
132
+ const cloned = new efaceWords()
133
+ cloned._fields = {
134
+ typ: $.varRef(this._fields.typ.value),
135
+ data: $.varRef(this._fields.data.value)
136
+ }
137
+ return cloned
138
+ }
139
+
140
+ // Register this type with the runtime type system
141
+ static __typeInfo = $.registerStructType(
142
+ 'efaceWords',
143
+ new efaceWords(),
144
+ [],
145
+ efaceWords,
146
+ {"data": { kind: $.TypeKind.Basic, name: "Pointer" }, "typ": { kind: $.TypeKind.Basic, name: "Pointer" }}
147
+ );
148
+ }
149
+
150
+ // Runtime functions for pinning/unpinning (no-ops in JavaScript)
151
+ export function runtime_procPin(): number {
152
+ return 0; // No-op in JavaScript
153
+ }
154
+
155
+ export function runtime_procUnpin(): void {
156
+ // No-op in JavaScript
157
+ }
158
+
@@ -0,0 +1,204 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ // Essential type aliases
4
+ export type uintptr = number
5
+
6
+ // Errno type for syscall errors
7
+ export interface Errno {
8
+ Error(): string
9
+ Is(target: $.GoError): boolean
10
+ Errno(): number
11
+ }
12
+
13
+ // Essential syscall constants
14
+ export const O_RDONLY = 0
15
+ export const O_WRONLY = 1
16
+ export const O_RDWR = 2
17
+ export const O_APPEND = 8
18
+ export const O_CREATE = 64
19
+ export const O_EXCL = 128
20
+ export const O_SYNC = 256
21
+ export const O_TRUNC = 512
22
+
23
+ export const Stdin = 0
24
+ export const Stdout = 1
25
+ export const Stderr = 2
26
+
27
+ export const SIGINT = 2
28
+ export const SIGTERM = 15
29
+
30
+ // File mode constants
31
+ export const S_IFMT = 0o170000
32
+ export const S_IFREG = 0o100000
33
+ export const S_IFDIR = 0o040000
34
+ export const S_IFLNK = 0o120000
35
+ export const S_IFBLK = 0o060000
36
+ export const S_IFCHR = 0o020000
37
+ export const S_IFIFO = 0o010000
38
+ export const S_IFSOCK = 0o140000
39
+ export const S_ISUID = 0o004000
40
+ export const S_ISGID = 0o002000
41
+ export const S_ISVTX = 0o001000
42
+
43
+ // Environment variable functions using Node.js/browser APIs
44
+ export function Getenv(key: string): [string, boolean] {
45
+ if (typeof process !== 'undefined' && process.env) {
46
+ const value = process.env[key]
47
+ return value !== undefined ? [value, true] : ["", false]
48
+ }
49
+ return ["", false]
50
+ }
51
+
52
+ export function Setenv(key: string, value: string): $.GoError {
53
+ if (typeof process !== 'undefined' && process.env) {
54
+ process.env[key] = value
55
+ return null
56
+ }
57
+ return { Error: () => "setenv not supported" }
58
+ }
59
+
60
+ export function Unsetenv(key: string): $.GoError {
61
+ if (typeof process !== 'undefined' && process.env) {
62
+ delete process.env[key]
63
+ return null
64
+ }
65
+ return { Error: () => "unsetenv not supported" }
66
+ }
67
+
68
+ export function Clearenv(): void {
69
+ if (typeof process !== 'undefined' && process.env) {
70
+ for (const key in process.env) {
71
+ delete process.env[key]
72
+ }
73
+ }
74
+ }
75
+
76
+ export function Environ(): $.Slice<string> {
77
+ if (typeof process !== 'undefined' && process.env) {
78
+ const env: string[] = []
79
+ for (const [key, value] of Object.entries(process.env)) {
80
+ if (value !== undefined) {
81
+ env.push(`${key}=${value}`)
82
+ }
83
+ }
84
+ return $.arrayToSlice(env)
85
+ }
86
+ return $.arrayToSlice([])
87
+ }
88
+
89
+ // Dirent structure with Reclen field
90
+ export class Dirent {
91
+ public Name: $.Bytes = new Uint8Array(0)
92
+ public Reclen: number = 0
93
+ constructor(init?: any) {
94
+ if (init?.Name) this.Name = init.Name
95
+ if (init?.Reclen) this.Reclen = init.Reclen
96
+ }
97
+ }
98
+
99
+ // Stat_t structure stub
100
+ export class Stat_t {
101
+ public Dev: number = 0
102
+ public Ino: number = 0
103
+ public Mode: number = 0
104
+ public Nlink: number = 0
105
+ public Uid: number = 0
106
+ public Gid: number = 0
107
+ public Rdev: number = 0
108
+ public Size: number = 0
109
+ public Blksize: number = 0
110
+ public Blocks: number = 0
111
+ public Atime: number = 0
112
+ public Mtime: number = 0
113
+ public Ctime: number = 0
114
+ public AtimeNsec: number = 0
115
+ public MtimeNsec: number = 0
116
+ public CtimeNsec: number = 0
117
+
118
+ constructor(init?: any) {
119
+ if (init) {
120
+ Object.assign(this, init)
121
+ }
122
+ }
123
+
124
+ public clone(): Stat_t {
125
+ return new Stat_t(this)
126
+ }
127
+ }
128
+
129
+ // RawConn interface - stub implementation for JavaScript environment
130
+ export interface RawConn {
131
+ Control(f: (fd: uintptr) => void): $.GoError
132
+ Read(f: (fd: uintptr) => boolean): $.GoError
133
+ Write(f: (fd: uintptr) => boolean): $.GoError
134
+ }
135
+
136
+ // Stub implementation of RawConn that always returns ErrUnimplemented
137
+ export class StubRawConn implements RawConn {
138
+ Control(f: (fd: uintptr) => void): $.GoError {
139
+ return { Error: () => "operation not implemented in JavaScript environment" }
140
+ }
141
+
142
+ Read(f: (fd: uintptr) => boolean): $.GoError {
143
+ return { Error: () => "operation not implemented in JavaScript environment" }
144
+ }
145
+
146
+ Write(f: (fd: uintptr) => boolean): $.GoError {
147
+ return { Error: () => "operation not implemented in JavaScript environment" }
148
+ }
149
+ }
150
+
151
+ // Additional error constants - implement as Errno type
152
+ export const ENOSYS: Errno = {
153
+ Error: () => "function not implemented",
154
+ Is: (target: $.GoError) => target === ENOSYS,
155
+ Errno: () => 38
156
+ }
157
+
158
+ export const EISDIR: Errno = {
159
+ Error: () => "is a directory",
160
+ Is: (target: $.GoError) => target === EISDIR,
161
+ Errno: () => 21
162
+ }
163
+
164
+ export const ENOTDIR: Errno = {
165
+ Error: () => "not a directory",
166
+ Is: (target: $.GoError) => target === ENOTDIR,
167
+ Errno: () => 20
168
+ }
169
+
170
+ export const ERANGE: Errno = {
171
+ Error: () => "result too large",
172
+ Is: (target: $.GoError) => target === ERANGE,
173
+ Errno: () => 34
174
+ }
175
+
176
+ export const ENOMEM: Errno = {
177
+ Error: () => "out of memory",
178
+ Is: (target: $.GoError) => target === ENOMEM,
179
+ Errno: () => 12
180
+ }
181
+
182
+ export const ESRCH: Errno = {
183
+ Error: () => "no such process",
184
+ Is: (target: $.GoError) => target === ESRCH,
185
+ Errno: () => 3
186
+ }
187
+
188
+ // Additional missing syscall functions
189
+ export function Open(path: string, flag: number, perm: number): [number, $.GoError] {
190
+ return [-1, ENOSYS]
191
+ }
192
+
193
+ export function Sysctl(name: string): [string, $.GoError] {
194
+ return ["", ENOSYS]
195
+ }
196
+
197
+
198
+
199
+ // Getpagesize returns the underlying system's memory page size.
200
+ export function Getpagesize(): number {
201
+ // Return a standard page size for JavaScript environment
202
+ // Most systems use 4096 bytes as the default page size
203
+ return 4096
204
+ }
@@ -75,3 +75,9 @@ export function StringData(_str: string): Pointer {
75
75
  'unsafe.StringData is not supported in JavaScript/TypeScript: direct memory access is not available in JavaScript',
76
76
  )
77
77
  }
78
+
79
+ // Pointer converts a value to an unsafe.Pointer for atomic operations
80
+ // In JavaScript/TypeScript, this is just a pass-through function
81
+ export function Pointer(value: any): Pointer {
82
+ return value;
83
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "goscript",
3
3
  "description": "Go to TypeScript transpiler",
4
- "version": "0.0.35",
4
+ "version": "0.0.37",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",