warpo 3.2.0 → 3.2.1

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 (93) hide show
  1. package/assemblyscript/std/README.md +5 -0
  2. package/assemblyscript/std/assembly/array.ts +542 -0
  3. package/assemblyscript/std/assembly/arraybuffer.ts +72 -0
  4. package/assemblyscript/std/assembly/builtins.ts +2312 -0
  5. package/assemblyscript/std/assembly/compat.ts +2 -0
  6. package/assemblyscript/std/assembly/dataview.ts +144 -0
  7. package/assemblyscript/std/assembly/date.ts +383 -0
  8. package/assemblyscript/std/assembly/diagnostics.ts +11 -0
  9. package/assemblyscript/std/assembly/error.ts +39 -0
  10. package/assemblyscript/std/assembly/function.ts +44 -0
  11. package/assemblyscript/std/assembly/iterator.ts +24 -0
  12. package/assemblyscript/std/assembly/map.ts +304 -0
  13. package/assemblyscript/std/assembly/math.ts +3401 -0
  14. package/assemblyscript/std/assembly/memory.ts +110 -0
  15. package/assemblyscript/std/assembly/number.ts +388 -0
  16. package/assemblyscript/std/assembly/object.ts +30 -0
  17. package/assemblyscript/std/assembly/polyfills.ts +24 -0
  18. package/assemblyscript/std/assembly/process.ts +7 -0
  19. package/assemblyscript/std/assembly/promise.ts +172 -0
  20. package/assemblyscript/std/assembly/reference.ts +48 -0
  21. package/assemblyscript/std/assembly/regexp.ts +16 -0
  22. package/assemblyscript/std/assembly/rt/common.ts +79 -0
  23. package/assemblyscript/std/assembly/rt/index-incremental.ts +4 -0
  24. package/assemblyscript/std/assembly/rt/index-radical.ts +4 -0
  25. package/assemblyscript/std/assembly/rt/index.d.ts +37 -0
  26. package/assemblyscript/std/assembly/rt/itcms.ts +415 -0
  27. package/assemblyscript/std/assembly/rt/tcms.ts +276 -0
  28. package/assemblyscript/std/assembly/rt/tlsf.ts +564 -0
  29. package/assemblyscript/std/assembly/rt.ts +71 -0
  30. package/assemblyscript/std/assembly/set.ts +261 -0
  31. package/assemblyscript/std/assembly/shared/feature.ts +69 -0
  32. package/assemblyscript/std/assembly/shared/host.ts +12 -0
  33. package/assemblyscript/std/assembly/shared/runtime.ts +9 -0
  34. package/assemblyscript/std/assembly/shared/target.ts +9 -0
  35. package/assemblyscript/std/assembly/shared/tsconfig.json +9 -0
  36. package/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
  37. package/assemblyscript/std/assembly/staticarray.ts +446 -0
  38. package/assemblyscript/std/assembly/string.ts +892 -0
  39. package/assemblyscript/std/assembly/symbol.ts +61 -0
  40. package/assemblyscript/std/assembly/table.ts +15 -0
  41. package/assemblyscript/std/assembly/tsconfig.json +4 -0
  42. package/assemblyscript/std/assembly/tuple.ts +36 -0
  43. package/assemblyscript/std/assembly/typedarray.ts +2000 -0
  44. package/assemblyscript/std/assembly/uri.ts +17 -0
  45. package/assemblyscript/std/assembly/util/bytes.ts +90 -0
  46. package/assemblyscript/std/assembly/util/casemap.ts +264 -0
  47. package/assemblyscript/std/assembly/util/error.ts +54 -0
  48. package/assemblyscript/std/assembly/util/hash.ts +117 -0
  49. package/assemblyscript/std/assembly/util/math.ts +1922 -0
  50. package/assemblyscript/std/assembly/util/memory.ts +309 -0
  51. package/assemblyscript/std/assembly/util/number.ts +884 -0
  52. package/assemblyscript/std/assembly/util/sort.ts +282 -0
  53. package/assemblyscript/std/assembly/util/string.ts +1075 -0
  54. package/assemblyscript/std/assembly/util/uri.ts +251 -0
  55. package/assemblyscript/std/assembly/vector.ts +3 -0
  56. package/dist/debug_server/debugSession.d.ts +1 -0
  57. package/dist/debug_server/debugSession.js +15 -6
  58. package/dist/debug_server/debugSession.js.map +1 -1
  59. package/dist/debug_server/debuggerWasmModule.d.ts +3 -0
  60. package/dist/debug_server/debuggerWasmModule.js +47 -2
  61. package/dist/debug_server/debuggerWasmModule.js.map +1 -1
  62. package/dist/debug_server/tests/debugSession.test.js +96 -0
  63. package/dist/debug_server/tests/debugSession.test.js.map +1 -1
  64. package/dist/debug_server/tests/testModule/debugger_closure_stepping.d.ts +1 -0
  65. package/dist/debug_server/tests/testModule/debugger_closure_stepping.js +12 -0
  66. package/dist/debug_server/tests/testModule/debugger_closure_stepping.js.map +1 -0
  67. package/dist/debug_server/tests/testModule/debugger_std_array.d.ts +1 -0
  68. package/dist/debug_server/tests/testModule/debugger_std_array.js +6 -0
  69. package/dist/debug_server/tests/testModule/debugger_std_array.js.map +1 -0
  70. package/dist/debug_server/tests/testModule/debugger_string_stepping.d.ts +1 -0
  71. package/dist/debug_server/tests/testModule/debugger_string_stepping.js +9 -0
  72. package/dist/debug_server/tests/testModule/debugger_string_stepping.js.map +1 -0
  73. package/package.json +7 -7
  74. package/warpo_extension/std/tsconfig.json +4 -0
  75. package/warpo_extension/std/warpo/ffi.ts +16 -0
  76. package/warpo_extension/std/warpo/test/comparison.ts +122 -0
  77. package/warpo_extension/std/warpo/test/env.ts +33 -0
  78. package/warpo_extension/std/warpo/test/expect.ts +101 -0
  79. package/warpo_extension/std/warpo/test/formatPrint.ts +99 -0
  80. package/warpo_extension/std/warpo/test/implement.ts +41 -0
  81. package/warpo_extension/std/warpo/test/index.d.ts +0 -0
  82. package/warpo_extension/std/warpo/test/index.ts +39 -0
  83. package/warpo_extension/std/warpo/test/mockInstrument.ts +26 -0
  84. package/warpo_extension/std/warpo/utf8/const_str.ts +17 -0
  85. package/warpo_extension/std/wasi_snapshot_preview1/LICENSE +202 -0
  86. package/warpo_extension/std/wasi_snapshot_preview1/README.md +1 -0
  87. package/warpo_extension/std/wasi_snapshot_preview1/bindings/wasi_snapshot_preview1.ts +1731 -0
  88. package/warpo_extension/std/wasi_snapshot_preview1/wasi_console.ts +96 -0
  89. package/warpo_extension/std/wasi_snapshot_preview1/wasi_crypto.ts +8 -0
  90. package/warpo_extension/std/wasi_snapshot_preview1/wasi_date.ts +13 -0
  91. package/warpo_extension/std/wasi_snapshot_preview1/wasi_internal.ts +119 -0
  92. package/warpo_extension/std/wasi_snapshot_preview1/wasi_performance.ts +11 -0
  93. package/warpo_extension/std/wasi_snapshot_preview1/wasi_process.ts +191 -0
@@ -0,0 +1,110 @@
1
+ import { memcmp, memmove, memset } from "./util/memory";
2
+ import { E_NOTIMPLEMENTED } from "./util/error";
3
+
4
+ /** Memory manager interface. */
5
+ export namespace memory {
6
+ /** Gets the size of the memory in pages. */
7
+ // @ts-ignore: decorator
8
+ @builtin
9
+ export declare function size(): i32;
10
+
11
+ /** Grows the memory by the given size in pages and returns the previous size in pages. */
12
+ // @ts-ignore: decorator
13
+ @unsafe @builtin
14
+ export declare function grow(pages: i32): i32;
15
+
16
+ /** Fills a section in memory with the specified byte value. */
17
+ // @ts-ignore: decorator
18
+ @unsafe @builtin
19
+ export function fill(dst: usize, c: u8, n: usize): void {
20
+ memset(dst, c, n); // fallback if "bulk-memory" isn't enabled
21
+ }
22
+
23
+ /** Copies a section of memory to another. Has move semantics. */
24
+ // @ts-ignore: decorator
25
+ @unsafe @builtin
26
+ export function copy(dst: usize, src: usize, n: usize): void {
27
+ memmove(dst, src, n); // fallback if "bulk-memory" isn't enabled
28
+ }
29
+
30
+ /** Initializes a memory segment. */
31
+ // @ts-ignore: decorator
32
+ @unsafe
33
+ export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void {
34
+ throw new Error(E_NOTIMPLEMENTED);
35
+ }
36
+
37
+ /** Drops a memory segment. */
38
+ // @ts-ignore: decorator
39
+ @unsafe
40
+ export function drop(segmentIndex: u32): void {
41
+ throw new Error(E_NOTIMPLEMENTED);
42
+ }
43
+
44
+ /** Repeats a section of memory at a specific address. */
45
+ // @ts-ignore: decorator
46
+ @unsafe
47
+ export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void {
48
+ let index: usize = 0;
49
+ let total = srcLength * count;
50
+ while (index < total) {
51
+ memory.copy(dst + index, src, srcLength);
52
+ index += srcLength;
53
+ }
54
+ }
55
+
56
+ /** Compares a section of memory to another. */
57
+ // @ts-ignore: decorator
58
+ @inline
59
+ export function compare(vl: usize, vr: usize, n: usize): i32 {
60
+ return memcmp(vl, vr, n);
61
+ }
62
+
63
+ /** Gets a pointer to a static chunk of memory of the given size. */
64
+ // @ts-ignore: decorator
65
+ @builtin
66
+ export declare function data<T>(size: T, align?: i32): usize;
67
+ }
68
+
69
+ // @ts-ignore: decorator
70
+ @builtin
71
+ export declare const __data_end: usize;
72
+
73
+ // @ts-ignore: decorator
74
+ @builtin
75
+ export declare let __stack_pointer: usize;
76
+
77
+ // @ts-ignore: decorator
78
+ @builtin
79
+ export declare const __heap_base: usize;
80
+
81
+ /** Heap memory interface. */
82
+ export namespace heap {
83
+ /** Allocates a chunk of memory of at least the specified size. */
84
+ // @ts-ignore: decorator
85
+ @unsafe export function alloc(size: usize): usize {
86
+ return __alloc(size);
87
+ }
88
+
89
+ /** Reallocates a chunk of memory to have at least the specified size. */
90
+ // @ts-ignore: decorator
91
+ @unsafe export function realloc(ptr: usize, size: usize): usize {
92
+ return __realloc(ptr, size);
93
+ }
94
+
95
+ /** Frees a chunk of memory. Does hardly anything (most recent block only) with the stub runtime. */
96
+ // @ts-ignore: decorator
97
+ @unsafe export function free(ptr: usize): void {
98
+ __free(ptr);
99
+ }
100
+
101
+ /** Dangerously resets the entire heap. Specific to the stub runtime. */
102
+ // @ts-ignore: decorator
103
+ @unsafe export function reset(): void {
104
+ if (isDefined(__reset)) {
105
+ __reset();
106
+ } else {
107
+ throw new Error(E_NOTIMPLEMENTED);
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,388 @@
1
+ import { itoa32, utoa32, itoa64, utoa64, dtoa } from "./util/number";
2
+ import { strtol, strtod } from "./util/string";
3
+
4
+ // @ts-ignore: decorator
5
+ @builtin @inline
6
+ export const NaN: f64 = 0 / 0; // context-aware
7
+
8
+ // @ts-ignore: decorator
9
+ @builtin @inline
10
+ export const Infinity: f64 = 1 / 0; // context-aware
11
+
12
+ // @ts-ignore: decorator
13
+ @builtin
14
+ export declare function isNaN<T extends number>(value: T): bool;
15
+
16
+ // @ts-ignore: decorator
17
+ @builtin
18
+ export declare function isFinite<T extends number>(value: T): bool;
19
+
20
+
21
+ @final @unmanaged
22
+ export abstract class I8 {
23
+ // @ts-ignore: decorator
24
+ @lazy
25
+ static readonly MIN_VALUE: i8 = i8.MIN_VALUE;
26
+
27
+ // @ts-ignore: decorator
28
+ @lazy
29
+ static readonly MAX_VALUE: i8 = i8.MAX_VALUE;
30
+
31
+ /** @deprecated */
32
+ static parseInt(value: string, radix: i32 = 0): i8 {
33
+ return <i8>strtol<i32>(value, radix);
34
+ }
35
+
36
+ toString(this: i8, radix: i32 = 10): String {
37
+ return itoa32(this, radix);
38
+ }
39
+ }
40
+
41
+
42
+ @final @unmanaged
43
+ export abstract class I16 {
44
+ // @ts-ignore: decorator
45
+ @lazy
46
+ static readonly MIN_VALUE: i16 = i16.MIN_VALUE;
47
+
48
+ // @ts-ignore: decorator
49
+ @lazy
50
+ static readonly MAX_VALUE: i16 = i16.MAX_VALUE;
51
+
52
+ /** @deprecated */
53
+ static parseInt(value: string, radix: i32 = 0): i16 {
54
+ return <i16>strtol<i32>(value, radix);
55
+ }
56
+
57
+ toString(this: i16, radix: i32 = 10): String {
58
+ return itoa32(this, radix);
59
+ }
60
+ }
61
+
62
+
63
+ @final @unmanaged
64
+ export abstract class I32 {
65
+ // @ts-ignore: decorator
66
+ @lazy
67
+ static readonly MIN_VALUE: i32 = i32.MIN_VALUE;
68
+
69
+ // @ts-ignore: decorator
70
+ @lazy
71
+ static readonly MAX_VALUE: i32 = i32.MAX_VALUE;
72
+
73
+ /** @deprecated */
74
+ static parseInt(value: string, radix: i32 = 0): i32 {
75
+ return <i32>strtol<i32>(value, radix);
76
+ }
77
+
78
+ toString(this: i32, radix: i32 = 10): String {
79
+ return itoa32(this, radix);
80
+ }
81
+ }
82
+
83
+
84
+ @final @unmanaged
85
+ export abstract class I64 {
86
+ // @ts-ignore: decorator
87
+ @lazy
88
+ static readonly MIN_VALUE: i64 = i64.MIN_VALUE;
89
+
90
+ // @ts-ignore: decorator
91
+ @lazy
92
+ static readonly MAX_VALUE: i64 = i64.MAX_VALUE;
93
+
94
+ /** @deprecated */
95
+ static parseInt(value: string, radix: i32 = 0): i64 {
96
+ return strtol<i64>(value, radix);
97
+ }
98
+
99
+ toString(this: i64, radix: i32 = 10): String {
100
+ return itoa64(this, radix);
101
+ }
102
+ }
103
+
104
+
105
+ @final @unmanaged
106
+ export abstract class Isize {
107
+ // @ts-ignore: decorator
108
+ @lazy
109
+ static readonly MIN_VALUE: isize = isize.MIN_VALUE;
110
+
111
+ // @ts-ignore: decorator
112
+ @lazy
113
+ static readonly MAX_VALUE: isize = isize.MAX_VALUE;
114
+
115
+ /** @deprecated */
116
+ static parseInt(value: string, radix: i32 = 0): isize {
117
+ return <isize>strtol<i64>(value, radix);
118
+ }
119
+
120
+ toString(this: isize, radix: i32 = 10): String {
121
+ if (sizeof<isize>() == 4) {
122
+ return itoa32(<i32>this, radix);
123
+ } else {
124
+ return itoa64(<i64>this, radix);
125
+ }
126
+ }
127
+ }
128
+
129
+
130
+ @final @unmanaged
131
+ export abstract class U8 {
132
+ // @ts-ignore: decorator
133
+ @lazy
134
+ static readonly MIN_VALUE: u8 = u8.MIN_VALUE;
135
+
136
+ // @ts-ignore: decorator
137
+ @lazy
138
+ static readonly MAX_VALUE: u8 = u8.MAX_VALUE;
139
+
140
+ /** @deprecated */
141
+ static parseInt(value: string, radix: i32 = 0): u8 {
142
+ return <u8>strtol<i32>(value, radix);
143
+ }
144
+
145
+ toString(this: u8, radix: i32 = 10): String {
146
+ return utoa32(this, radix);
147
+ }
148
+ }
149
+
150
+
151
+ @final @unmanaged
152
+ export abstract class U16 {
153
+ // @ts-ignore: decorator
154
+ @lazy
155
+ static readonly MIN_VALUE: u16 = u16.MIN_VALUE;
156
+
157
+ // @ts-ignore: decorator
158
+ @lazy
159
+ static readonly MAX_VALUE: u16 = u16.MAX_VALUE;
160
+
161
+ /** @deprecated */
162
+ static parseInt(value: string, radix: i32 = 0): u16 {
163
+ return <u16>strtol<i32>(value, radix);
164
+ }
165
+
166
+ toString(this: u16, radix: i32 = 10): String {
167
+ return utoa32(this, radix);
168
+ }
169
+ }
170
+
171
+
172
+ @final @unmanaged
173
+ export abstract class U32 {
174
+ // @ts-ignore: decorator
175
+ @lazy
176
+ static readonly MIN_VALUE: u32 = u32.MIN_VALUE;
177
+
178
+ // @ts-ignore: decorator
179
+ @lazy
180
+ static readonly MAX_VALUE: u32 = u32.MAX_VALUE;
181
+
182
+ /** @deprecated */
183
+ static parseInt(value: string, radix: i32 = 0): u32 {
184
+ return <u32>strtol<i32>(value, radix);
185
+ }
186
+
187
+ toString(this: u32, radix: i32 = 10): String {
188
+ return utoa32(this, radix);
189
+ }
190
+ }
191
+
192
+
193
+ @final @unmanaged
194
+ export abstract class U64 {
195
+ // @ts-ignore: decorator
196
+ @lazy
197
+ static readonly MIN_VALUE: u64 = u64.MIN_VALUE;
198
+
199
+ // @ts-ignore: decorator
200
+ @lazy
201
+ static readonly MAX_VALUE: u64 = u64.MAX_VALUE;
202
+
203
+ /** @deprecated */
204
+ static parseInt(value: string, radix: i32 = 0): u64 {
205
+ return <u64>strtol<i64>(value, radix);
206
+ }
207
+
208
+ toString(this: u64, radix: i32 = 10): String {
209
+ return utoa64(this, radix);
210
+ }
211
+ }
212
+
213
+
214
+ @final @unmanaged
215
+ export abstract class Usize {
216
+ // @ts-ignore: decorator
217
+ @lazy
218
+ static readonly MIN_VALUE: usize = usize.MIN_VALUE;
219
+
220
+ // @ts-ignore: decorator
221
+ @lazy
222
+ static readonly MAX_VALUE: usize = usize.MAX_VALUE;
223
+
224
+ /** @deprecated */
225
+ static parseInt(value: string, radix: i32 = 0): usize {
226
+ return <usize>strtol<i64>(value, radix);
227
+ }
228
+
229
+ toString(this: usize, radix: i32 = 10): String {
230
+ if (sizeof<usize>() == 4) {
231
+ return utoa32(<u32>this, radix);
232
+ } else {
233
+ return utoa64(<u64>this, radix);
234
+ }
235
+ }
236
+ }
237
+
238
+
239
+ @final @unmanaged
240
+ export abstract class Bool {
241
+ // @ts-ignore: decorator
242
+ @lazy
243
+ static readonly MIN_VALUE: bool = bool.MIN_VALUE;
244
+
245
+ // @ts-ignore: decorator
246
+ @lazy
247
+ static readonly MAX_VALUE: bool = bool.MAX_VALUE;
248
+
249
+ toString(this: bool, radix: i32 = 0): String {
250
+ return this ? "true" : "false";
251
+ }
252
+ }
253
+
254
+ export { Bool as Boolean };
255
+
256
+
257
+ @final @unmanaged
258
+ export abstract class F32 {
259
+ // @ts-ignore: decorator
260
+ @lazy
261
+ static readonly EPSILON: f32 = f32.EPSILON;
262
+
263
+ // @ts-ignore: decorator
264
+ @lazy
265
+ static readonly MIN_VALUE: f32 = f32.MIN_VALUE;
266
+
267
+ // @ts-ignore: decorator
268
+ @lazy
269
+ static readonly MAX_VALUE: f32 = f32.MAX_VALUE;
270
+
271
+ // @ts-ignore: decorator
272
+ @lazy
273
+ static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER;
274
+
275
+ // @ts-ignore: decorator
276
+ @lazy
277
+ static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER;
278
+
279
+ // @ts-ignore: decorator
280
+ @lazy
281
+ static readonly POSITIVE_INFINITY: f32 = f32.POSITIVE_INFINITY;
282
+
283
+ // @ts-ignore: decorator
284
+ @lazy
285
+ static readonly NEGATIVE_INFINITY: f32 = f32.NEGATIVE_INFINITY;
286
+
287
+ // @ts-ignore: decorator
288
+ @lazy
289
+ static readonly NaN: f32 = f32.NaN;
290
+
291
+ static isNaN(value: f32): bool {
292
+ return isNaN<f32>(value);
293
+ }
294
+
295
+ static isFinite(value: f32): bool {
296
+ return isFinite<f32>(value);
297
+ }
298
+
299
+ static isSafeInteger(value: f32): bool {
300
+ return abs<f32>(value) <= f32.MAX_SAFE_INTEGER && trunc<f32>(value) == value;
301
+ }
302
+
303
+ static isInteger(value: f32): bool {
304
+ return isFinite<f32>(value) && trunc<f32>(value) == value;
305
+ }
306
+
307
+ /** @deprecated */
308
+ static parseInt(value: string, radix: i32 = 0): f32 {
309
+ return <f32>strtol<f64>(value, radix);
310
+ }
311
+
312
+ /** @deprecated */
313
+ static parseFloat(value: string): f32 {
314
+ return <f32>strtod(value);
315
+ }
316
+
317
+ toString(this: f32, radix: i32 = 0): String {
318
+ return dtoa(this);
319
+ }
320
+ }
321
+
322
+
323
+ @final @unmanaged
324
+ export abstract class F64 {
325
+ // @ts-ignore: decorator
326
+ @lazy
327
+ static readonly EPSILON: f64 = f64.EPSILON;
328
+
329
+ // @ts-ignore: decorator
330
+ @lazy
331
+ static readonly MIN_VALUE: f64 = f64.MIN_VALUE;
332
+
333
+ // @ts-ignore: decorator
334
+ @lazy
335
+ static readonly MAX_VALUE: f64 = f64.MAX_VALUE;
336
+
337
+ // @ts-ignore: decorator
338
+ @lazy
339
+ static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER;
340
+
341
+ // @ts-ignore: decorator
342
+ @lazy
343
+ static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER;
344
+
345
+ // @ts-ignore: decorator
346
+ @lazy
347
+ static readonly POSITIVE_INFINITY: f64 = f64.POSITIVE_INFINITY;
348
+
349
+ // @ts-ignore: decorator
350
+ @lazy
351
+ static readonly NEGATIVE_INFINITY: f64 = f64.NEGATIVE_INFINITY;
352
+
353
+ // @ts-ignore: decorator
354
+ @lazy
355
+ static readonly NaN: f64 = f64.NaN;
356
+
357
+ static isNaN(value: f64): bool {
358
+ return isNaN<f64>(value);
359
+ }
360
+
361
+ static isFinite(value: f64): bool {
362
+ return isFinite<f64>(value);
363
+ }
364
+
365
+ static isSafeInteger(value: f64): bool {
366
+ return abs<f64>(value) <= f64.MAX_SAFE_INTEGER && trunc<f64>(value) == value;
367
+ }
368
+
369
+ static isInteger(value: f64): bool {
370
+ return isFinite<f64>(value) && trunc<f64>(value) == value;
371
+ }
372
+
373
+ /** @deprecated */
374
+ static parseInt(value: string, radix: i32 = 0): f64 {
375
+ return strtol<f64>(value, radix);
376
+ }
377
+
378
+ /** @deprecated */
379
+ static parseFloat(value: string): f64 {
380
+ return strtod(value);
381
+ }
382
+
383
+ toString(this: f64, radix: i32 = 0): String {
384
+ return dtoa(this);
385
+ }
386
+ }
387
+
388
+ export { F64 as Number };
@@ -0,0 +1,30 @@
1
+ export abstract class Object {
2
+ static is<T>(x: T, y: T): bool {
3
+ if (isFloat<T>()) {
4
+ // Float pointing is special we shoulr presere following identities:
5
+ // 0.0 !=-0.0
6
+ // NaN == NaN
7
+ if (sizeof<T>() == 8) {
8
+ return bool((u32(x != x) & u32(y != y)) | u32(reinterpret<u64>(f64(x)) == reinterpret<u64>(f64(y))));
9
+ } else {
10
+ return bool((u32(x != x) & u32(y != y)) | u32(reinterpret<u32>(f32(x)) == reinterpret<u32>(f32(y))));
11
+ }
12
+ }
13
+ // For references, strings, integers and booleans
14
+ return x == y;
15
+ }
16
+
17
+ // TODO: Wrapper classes like `Function<T>` override the `this` type of
18
+ // `toString`, which is covariant and hence fails to overload. Wrapper classes
19
+ // might need a different mechanism to indicate such special `this` types.
20
+ // toString(): string {
21
+ // return "[object Object]";
22
+ // }
23
+ }
24
+
25
+ // TODO: The types `Object` and `object` differ in TypeScript, in that the
26
+ // latter indicates any non-primitive type, not including `string` for example.
27
+ // The `object` type hence remains reserved for now, also to potentially address
28
+ // the above `toString` TODO in alternative ways.
29
+ // @ts-ignore: nolib
30
+ // export type object = Object;
@@ -0,0 +1,24 @@
1
+ export function bswap<T extends number>(value: T): T {
2
+ if (isInteger<T>()) {
3
+ if (sizeof<T>() == 1) {
4
+ return value;
5
+ }
6
+ if (sizeof<T>() == 2) {
7
+ return <T>(((<u16>value) << 8) | ((<u16>value) >> 8));
8
+ }
9
+ if (sizeof<T>() == 4) {
10
+ return <T>(rotl((<u32>value) & 0xff00ff00, 8) | rotr((<u32>value) & 0x00ff00ff, 8));
11
+ }
12
+ if (sizeof<T>() == 8) {
13
+ let a = ((<u64>value) >> 8) & 0x00ff00ff00ff00ff;
14
+ let b = ((<u64>value) & 0x00ff00ff00ff00ff) << 8;
15
+ let v = a | b;
16
+
17
+ a = (v >>> 16) & 0x0000ffff0000ffff;
18
+ b = (v & 0x0000ffff0000ffff) << 16;
19
+
20
+ return <T>rotr(a | b, 32);
21
+ }
22
+ }
23
+ ERROR("Unsupported generic type");
24
+ }
@@ -0,0 +1,7 @@
1
+ export namespace process {
2
+ // @ts-ignore: decorator
3
+ @lazy export const arch = "wasm32";
4
+
5
+ // @ts-ignore: decorator
6
+ @lazy export const platform = "wasm";
7
+ }