warpo 2.3.0 → 2.5.0-alpha-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 (119) hide show
  1. package/asconfig.schema.json +25 -3
  2. package/create/index.ts +4 -1
  3. package/dist/debug_server/dapServer.d.ts +1 -0
  4. package/dist/debug_server/dapServer.js +27 -0
  5. package/dist/debug_server/dapServer.js.map +1 -0
  6. package/dist/debug_server/debugSession.d.ts +19 -0
  7. package/dist/debug_server/debugSession.js +71 -0
  8. package/dist/debug_server/debugSession.js.map +1 -0
  9. package/dist/debug_server/tests/debugSession.test.d.ts +1 -0
  10. package/dist/debug_server/tests/debugSession.test.js +61 -0
  11. package/dist/debug_server/tests/debugSession.test.js.map +1 -0
  12. package/dist/debug_server/tests/launcher.d.ts +10 -0
  13. package/dist/debug_server/tests/launcher.js +21 -0
  14. package/dist/debug_server/tests/launcher.js.map +1 -0
  15. package/dist/scripts/lib.d.ts +7 -0
  16. package/dist/{lib.js → scripts/lib.js} +20 -6
  17. package/dist/scripts/lib.js.map +1 -0
  18. package/dist/test_runner/cli.d.ts +2 -0
  19. package/dist/test_runner/cli.js +85 -0
  20. package/dist/test_runner/cli.js.map +1 -0
  21. package/dist/test_runner/core/analyze.d.ts +13 -0
  22. package/dist/test_runner/core/analyze.js +58 -0
  23. package/dist/test_runner/core/analyze.js.map +1 -0
  24. package/dist/test_runner/core/compile.d.ts +4 -0
  25. package/dist/test_runner/core/compile.js +23 -0
  26. package/dist/test_runner/core/compile.js.map +1 -0
  27. package/dist/test_runner/core/compiler.d.ts +11 -0
  28. package/dist/test_runner/core/compiler.js +47 -0
  29. package/dist/test_runner/core/compiler.js.map +1 -0
  30. package/dist/test_runner/core/covRecorder.d.ts +5 -0
  31. package/dist/test_runner/core/covRecorder.js +26 -0
  32. package/dist/test_runner/core/covRecorder.js.map +1 -0
  33. package/dist/test_runner/core/execute.d.ts +4 -0
  34. package/dist/test_runner/core/execute.js +76 -0
  35. package/dist/test_runner/core/execute.js.map +1 -0
  36. package/dist/test_runner/core/executionRecorder.d.ts +52 -0
  37. package/dist/test_runner/core/executionRecorder.js +164 -0
  38. package/dist/test_runner/core/executionRecorder.js.map +1 -0
  39. package/dist/test_runner/core/mockStatusRecorder.d.ts +10 -0
  40. package/dist/test_runner/core/mockStatusRecorder.js +62 -0
  41. package/dist/test_runner/core/mockStatusRecorder.js.map +1 -0
  42. package/dist/test_runner/executionResult.d.ts +11 -0
  43. package/dist/test_runner/executionResult.js +112 -0
  44. package/dist/test_runner/executionResult.js.map +1 -0
  45. package/dist/test_runner/generator/html-generator/genCode.d.ts +2 -0
  46. package/dist/test_runner/generator/html-generator/genCode.js +124 -0
  47. package/dist/test_runner/generator/html-generator/genCode.js.map +1 -0
  48. package/dist/test_runner/generator/html-generator/genFolder.d.ts +2 -0
  49. package/dist/test_runner/generator/html-generator/genFolder.js +155 -0
  50. package/dist/test_runner/generator/html-generator/genFolder.js.map +1 -0
  51. package/dist/test_runner/generator/html-generator/index.d.ts +2 -0
  52. package/dist/test_runner/generator/html-generator/index.js +33 -0
  53. package/dist/test_runner/generator/html-generator/index.js.map +1 -0
  54. package/dist/test_runner/generator/index.d.ts +9 -0
  55. package/dist/test_runner/generator/index.js +30 -0
  56. package/dist/test_runner/generator/index.js.map +1 -0
  57. package/dist/test_runner/generator/json-generator/index.d.ts +2 -0
  58. package/dist/test_runner/generator/json-generator/index.js +45 -0
  59. package/dist/test_runner/generator/json-generator/index.js.map +1 -0
  60. package/dist/test_runner/generator/table-generator/index.d.ts +2 -0
  61. package/dist/test_runner/generator/table-generator/index.js +85 -0
  62. package/dist/test_runner/generator/table-generator/index.js.map +1 -0
  63. package/dist/test_runner/index.d.ts +3 -0
  64. package/dist/test_runner/index.js +70 -0
  65. package/dist/test_runner/index.js.map +1 -0
  66. package/dist/test_runner/interface.d.ts +36 -0
  67. package/dist/test_runner/interface.js +12 -0
  68. package/dist/test_runner/interface.js.map +1 -0
  69. package/dist/test_runner/parser/index.d.ts +35 -0
  70. package/dist/test_runner/parser/index.js +146 -0
  71. package/dist/test_runner/parser/index.js.map +1 -0
  72. package/dist/test_runner/parser/singleFileAnalysis.d.ts +8 -0
  73. package/dist/test_runner/parser/singleFileAnalysis.js +51 -0
  74. package/dist/test_runner/parser/singleFileAnalysis.js.map +1 -0
  75. package/dist/test_runner/parser/singleFunctionAnalysis.d.ts +16 -0
  76. package/dist/test_runner/parser/singleFunctionAnalysis.js +97 -0
  77. package/dist/test_runner/parser/singleFunctionAnalysis.js.map +1 -0
  78. package/dist/test_runner/testOption.d.ts +16 -0
  79. package/dist/test_runner/testOption.js +2 -0
  80. package/dist/test_runner/testOption.js.map +1 -0
  81. package/dist/test_runner/utils/errorTraceHandler.d.ts +12 -0
  82. package/dist/test_runner/utils/errorTraceHandler.js +87 -0
  83. package/dist/test_runner/utils/errorTraceHandler.js.map +1 -0
  84. package/dist/test_runner/utils/escape.d.ts +1 -0
  85. package/dist/test_runner/utils/escape.js +14 -0
  86. package/dist/test_runner/utils/escape.js.map +1 -0
  87. package/dist/test_runner/utils/index.d.ts +14 -0
  88. package/dist/test_runner/utils/index.js +88 -0
  89. package/dist/test_runner/utils/index.js.map +1 -0
  90. package/dist/test_runner/utils/interface.d.ts +100 -0
  91. package/dist/test_runner/utils/interface.js +86 -0
  92. package/dist/test_runner/utils/interface.js.map +1 -0
  93. package/dist/test_runner/utils/name.d.ts +2 -0
  94. package/dist/test_runner/utils/name.js +3 -0
  95. package/dist/test_runner/utils/name.js.map +1 -0
  96. package/dist/test_runner/utils/pathResolver.d.ts +6 -0
  97. package/dist/test_runner/utils/pathResolver.js +98 -0
  98. package/dist/test_runner/utils/pathResolver.js.map +1 -0
  99. package/dist/test_runner/utils/projectRoot.d.ts +1 -0
  100. package/dist/test_runner/utils/projectRoot.js +4 -0
  101. package/dist/test_runner/utils/projectRoot.js.map +1 -0
  102. package/dist/test_runner/utils/wasm.d.ts +12 -0
  103. package/dist/test_runner/utils/wasm.js +45 -0
  104. package/dist/test_runner/utils/wasm.js.map +1 -0
  105. package/dist/warpo.d.ts +7 -1
  106. package/dist/warpo.js +83 -3
  107. package/dist/warpo.js.map +1 -0
  108. package/package.json +36 -8
  109. package/tsconfig-warpo.json +2 -3
  110. package/{assemblyscript/std/assembly → types/std}/index.d.ts +26 -340
  111. package/types/std/package.json +3 -0
  112. package/types/std/tsconfig.json +4 -0
  113. package/types/tsconfig-base.json +15 -0
  114. package/types/tsconfig-std.json +13 -0
  115. package/types/warpo/index.d.ts +95 -1
  116. package/types/wasi_snapshot_preview1/index.d.ts +52 -0
  117. package/types/wasi_snapshot_preview1/package.json +3 -0
  118. package/types/wasi_snapshot_preview1/tsconfig.json +4 -0
  119. package/dist/lib.d.ts +0 -5
package/package.json CHANGED
@@ -1,23 +1,25 @@
1
1
  {
2
2
  "name": "warpo",
3
- "version": "2.3.0",
3
+ "version": "2.5.0-alpha-1",
4
4
  "description": "next generation AssemblyScript compiler with optimizations",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "warpo": "dist/warpo.js"
8
8
  },
9
9
  "scripts": {
10
- "build:ts": "tsc -p tools/scripts/tsconfig.json",
10
+ "update": "cmake -S . -B build && cmake --build build --parallel --target warpo_binaryen_enums_gen && ./build/bin/warpo_binaryen_enums_gen",
11
+ "build:ts": "tsc -p tools/tsconfig.json",
11
12
  "build:cpp": "cmake -S . -B build && cmake --build build --parallel",
12
13
  "build": "npm run build:ts && npm run build:cpp",
13
- "test:as:ut": "as-test",
14
+ "test:as:ut": "node dist/warpo.js test",
14
15
  "test:cpp:ut": "cd build && ctest --output-on-failure",
15
16
  "test:as:snapshot": "cross-env-shell ./build/tests/frontend/warpo_frontend_test",
16
17
  "test:opt:snapshot": "node tests/snapshot_diff/index.mjs",
17
18
  "test:bootstrap:debug": "./tests/bootstrap/debug.sh",
18
19
  "test:bootstrap:release": "./tests/bootstrap/release.sh",
19
- "test:debug_symbol": "cross-env-shell ./build/tests/DebugSymbol/TestDebugSymbol",
20
- "test:debug_symbol:update": "cross-env-shell build/tests/DebugSymbol/TestDebugSymbol --update-fixtures",
20
+ "test:debug_symbol": "cross-env-shell ./build/tests/dwarf/TestDebugSymbol",
21
+ "test:debug_symbol:update": "cross-env-shell build/tests/dwarf/TestDebugSymbol --update-fixtures",
22
+ "test:debug_server": "node --import tsx --test tools/debug_server/tests/**/*.test.ts",
21
23
  "test:driver": "node tests/driver/index.mjs",
22
24
  "test": "npm run test:as:ut && npm run test:cpp:ut && npm run test:as:snapshot && npm run test:opt:snapshot && npm run test:driver && npm run test:debug_symbol",
23
25
  "test:all": "npm run test && npm run test:bootstrap:debug && npm run test:bootstrap:release",
@@ -26,6 +28,7 @@
26
28
  "docs:build": "vitepress build docs",
27
29
  "prettier": "prettier --check .",
28
30
  "prettier:fix": "prettier --write .",
31
+ "lint": "npx eslint --config tools/debug_server/eslint.config.mjs tools/debug_server/ && npx eslint --config debugger/eslint.config.mjs debugger/src/",
29
32
  "cspell": "cspell ."
30
33
  },
31
34
  "license": "Apache-2.0",
@@ -49,16 +52,41 @@
49
52
  ],
50
53
  "devDependencies": {
51
54
  "@assemblyscript/loader": "^0.28.9",
55
+ "@eslint/js": "^9.0.0",
56
+ "@types/fs-extra": "^11.0.4",
52
57
  "@types/node": "^22.15.21",
58
+ "@types/vscode": "^1.80.0",
59
+ "@vscode/debugadapter-testsupport": "^1.65.0",
60
+ "@vscode/vsce": "^3.0.0",
53
61
  "assemblyscript": "^0.28.9",
54
- "assemblyscript-prettier": "^3.0.1",
55
- "assemblyscript-unittest-framework": "^2.0.1",
62
+ "assemblyscript-prettier": "^3.0.4",
56
63
  "chalk": "^5.6.2",
57
64
  "cross-env": "^10.1.0",
58
65
  "cspell": "^9.3.0",
59
66
  "diff": "^8.0.0",
60
- "prettier": "^3.6.2",
67
+ "eslint": "^9.0.0",
68
+ "eslint-import-resolver-typescript": "^4.4.4",
69
+ "eslint-plugin-import": "^2.32.0",
70
+ "eslint-plugin-n": "^17.23.2",
71
+ "eslint-plugin-promise": "^7.2.1",
72
+ "eslint-plugin-sonarjs": "^4.0.0",
73
+ "eslint-plugin-unicorn": "^63.0.0",
74
+ "eslint-plugin-unused-imports": "^4.4.1",
75
+ "expect": "^30.2.0",
76
+ "ignore": "^7.0.5",
77
+ "prettier": "^3.8.1",
78
+ "tsx": "^4.0.0",
61
79
  "typescript": "^5.8.3",
80
+ "typescript-eslint": "^8.55.0",
62
81
  "vitepress": "^2.0.0-alpha.15"
82
+ },
83
+ "dependencies": {
84
+ "@vscode/debugadapter": "^1.68.0",
85
+ "@vscode/debugprotocol": "^1.68.0",
86
+ "commander": "^14.0.3",
87
+ "fs-extra": "^11.3.3",
88
+ "glob": "^13.0.0",
89
+ "mermaid": "^11.12.1",
90
+ "source-map": "^0.7.6"
63
91
  }
64
92
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "./assemblyscript/tsconfig-base.json",
2
+ "extends": "./types/tsconfig-base.json",
3
3
  "compilerOptions": {
4
4
  "target": "esnext",
5
5
  "module": "commonjs",
@@ -8,7 +8,6 @@
8
8
  "allowJs": false,
9
9
  "typeRoots": ["types"],
10
10
  "types": ["warpo"],
11
- "baseUrl": ".",
12
- "paths": { "*": ["./assembly/*"] }
11
+ "baseUrl": "."
13
12
  }
14
13
  }
@@ -82,10 +82,12 @@ declare type stringview_iter = ref_stringview_iter | null;
82
82
 
83
83
  // Compiler hints
84
84
 
85
- /** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
85
+ /** Compiler target. 0 = JS, 1 = WASM32. */
86
86
  declare const ASC_TARGET: i32;
87
87
  /** Runtime type. 0 = Stub, 1 = Radical, 2 = Incremental. */
88
88
  declare const ASC_RUNTIME: i32;
89
+ /** Host selection. 0 = None, 1 = WASI Snapshot Preview 1. */
90
+ declare const ASC_HOST: i32;
89
91
  /** Provided noAssert option. */
90
92
  declare const ASC_NO_ASSERT: bool;
91
93
  /** Provided memoryBase option. */
@@ -110,8 +112,6 @@ declare const ASC_FEATURE_NONTRAPPING_F2I: bool;
110
112
  declare const ASC_FEATURE_BULK_MEMORY: bool;
111
113
  /** Whether the SIMD feature is enabled. */
112
114
  declare const ASC_FEATURE_SIMD: bool;
113
- /** Whether the threads feature is enabled. */
114
- declare const ASC_FEATURE_THREADS: bool;
115
115
  /** Whether the exception handling feature is enabled. */
116
116
  declare const ASC_FEATURE_EXCEPTION_HANDLING: bool;
117
117
  /** Whether the tail calls feature is enabled. */
@@ -281,44 +281,6 @@ declare function decodeURI(str: string): string;
281
281
  /** Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent. */
282
282
  declare function decodeURIComponent(str: string): string;
283
283
 
284
- /** Atomic operations. */
285
- declare namespace atomic {
286
- /** Atomically loads an integer value from memory and returns it. */
287
- export function load<T>(ptr: usize, immOffset?: usize): T;
288
- /** Atomically stores an integer value to memory. */
289
- export function store<T>(ptr: usize, value: T, immOffset?: usize): void;
290
- /** Atomically adds an integer value in memory. */
291
- export function add<T>(ptr: usize, value: T, immOffset?: usize): T;
292
- /** Atomically subtracts an integer value in memory. */
293
- export function sub<T>(ptr: usize, value: T, immOffset?: usize): T;
294
- /** Atomically performs a bitwise AND operation on an integer value in memory. */
295
- export function and<T>(ptr: usize, value: T, immOffset?: usize): T;
296
- /** Atomically performs a bitwise OR operation on an integer value in memory. */
297
- export function or<T>(ptr: usize, value: T, immOffset?: usize): T;
298
- /** Atomically performs a bitwise XOR operation on an integer value in memory. */
299
- export function xor<T>(ptr: usize, value: T, immOffset?: usize): T;
300
- /** Atomically exchanges an integer value in memory. */
301
- export function xchg<T>(ptr: usize, value: T, immOffset?: usize): T;
302
- /** Atomically compares and exchanges an integer value in memory if the condition is met. */
303
- export function cmpxchg<T>(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;
304
- /** Performs a wait operation on an address in memory suspending this agent if the integer condition is met. */
305
- export function wait<T>(ptr: usize, expected: T, timeout?: i64): AtomicWaitResult;
306
- /** Performs a notify operation on an address in memory waking up suspended agents. */
307
- export function notify(ptr: usize, count?: i32): i32;
308
- /** Performs a fence operation, preserving synchronization guarantees of higher level languages. */
309
- export function fence(): void;
310
- }
311
-
312
- /** Describes the result of an atomic wait operation. */
313
- declare enum AtomicWaitResult {
314
- /** Woken by another agent. */
315
- OK,
316
- /** Loaded value did not match the expected value. */
317
- NOT_EQUAL,
318
- /** Not woken before the timeout expired. */
319
- TIMED_OUT,
320
- }
321
-
322
284
  /** Converts any other numeric value to an 8-bit signed integer. */
323
285
  declare function i8(value: any): i8;
324
286
  declare namespace i8 {
@@ -394,73 +356,6 @@ declare namespace i32 {
394
356
  export function rem_s(left: i32, right: i32): i32;
395
357
  /** Computes the unsigned remainder of two 32-bit integers. */
396
358
  export function rem_u(left: u32, right: u32): u32;
397
-
398
- /** Atomic 32-bit integer operations. */
399
- export namespace atomic {
400
- /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */
401
- export function load8_u(ptr: usize, immOffset?: usize): i32;
402
- /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */
403
- export function load16_u(ptr: usize, immOffset?: usize): i32;
404
- /** Atomically loads a 32-bit integer value from memory and returns it. */
405
- export function load(ptr: usize, immOffset?: usize): i32;
406
- /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */
407
- export function store8(ptr: usize, value: i32, immOffset?: usize): void;
408
- /** Atomically stores a 32-bit integer value to memory as a 16-bit integer. */
409
- export function store16(ptr: usize, value: i32, immOffset?: usize): void;
410
- /** Atomically stores a 32-bit integer value to memory. */
411
- export function store(ptr: usize, value: i32, immOffset?: usize): void;
412
- /** Atomic 32-bit integer read-modify-write operations on 8-bit values. */
413
- export namespace rmw8 {
414
- /** Atomically adds an 8-bit unsigned integer value in memory. */
415
- export function add_u(ptr: usize, value: i32, immOffset?: usize): i32;
416
- /** Atomically subtracts an 8-bit unsigned integer value in memory. */
417
- export function sub_u(ptr: usize, value: i32, immOffset?: usize): i32;
418
- /** Atomically performs a bitwise AND operation an 8-bit unsigned integer value in memory. */
419
- export function and_u(ptr: usize, value: i32, immOffset?: usize): i32;
420
- /** Atomically performs a bitwise OR operation an 8-bit unsigned integer value in memory. */
421
- export function or_u(ptr: usize, value: i32, immOffset?: usize): i32;
422
- /** Atomically performs a bitwise XOR operation an 8-bit unsigned integer value in memory. */
423
- export function xor_u(ptr: usize, value: i32, immOffset?: usize): i32;
424
- /** Atomically exchanges an 8-bit unsigned integer value in memory. */
425
- export function xchg_u(ptr: usize, value: i32, immOffset?: usize): i32;
426
- /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */
427
- export function cmpxchg_u(ptr: usize, expected: i32, replacement: i32, immOffset?: usize): i32;
428
- }
429
- /** Atomic 32-bit integer read-modify-write operations on 16-bit values. */
430
- export namespace rmw16 {
431
- /** Atomically adds a 16-bit unsigned integer value in memory. */
432
- export function add_u(ptr: usize, value: i32, immOffset?: usize): i32;
433
- /** Atomically adds a 16-bit unsigned integer value in memory. */
434
- export function sub_u(ptr: usize, value: i32, immOffset?: usize): i32;
435
- /** Atomically performs a bitwise AND operation a 16-bit unsigned integer value in memory. */
436
- export function and_u(ptr: usize, value: i32, immOffset?: usize): i32;
437
- /** Atomically performs a bitwise OR operation a 16-bit unsigned integer value in memory. */
438
- export function or_u(ptr: usize, value: i32, immOffset?: usize): i32;
439
- /** Atomically performs a bitwise XOR operation a 16-bit unsigned integer value in memory. */
440
- export function xor_u(ptr: usize, value: i32, immOffset?: usize): i32;
441
- /** Atomically exchanges a 16-bit unsigned integer value in memory. */
442
- export function xchg_u(ptr: usize, value: i32, immOffset?: usize): i32;
443
- /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */
444
- export function cmpxchg_u(ptr: usize, expected: i32, replacement: i32, immOffset?: usize): i32;
445
- }
446
- /** Atomic 32-bit integer read-modify-write operations. */
447
- export namespace rmw {
448
- /** Atomically adds a 32-bit integer value in memory. */
449
- export function add(ptr: usize, value: i32, immOffset?: usize): i32;
450
- /** Atomically subtracts a 32-bit integer value in memory. */
451
- export function sub(ptr: usize, value: i32, immOffset?: usize): i32;
452
- /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */
453
- export function and(ptr: usize, value: i32, immOffset?: usize): i32;
454
- /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */
455
- export function or(ptr: usize, value: i32, immOffset?: usize): i32;
456
- /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */
457
- export function xor(ptr: usize, value: i32, immOffset?: usize): i32;
458
- /** Atomically exchanges a 32-bit integer value in memory. */
459
- export function xchg(ptr: usize, value: i32, immOffset?: usize): i32;
460
- /** Atomically compares and exchanges a 32-bit integer value in memory if the condition is met. */
461
- export function cmpxchg(ptr: usize, expected: i32, replacement: i32, immOffset?: usize): i32;
462
- }
463
- }
464
359
  }
465
360
  /** Converts any other numeric value to a 64-bit signed integer. */
466
361
  declare function i64(value: any): i64;
@@ -523,97 +418,9 @@ declare namespace i64 {
523
418
  export function rem_s(left: i64, right: i64): i64;
524
419
  /** Computes the unsigned remainder of two 64-bit integers. */
525
420
  export function rem_u(left: u64, right: u64): u64;
526
-
527
- /** Atomic 64-bit integer operations. */
528
- export namespace atomic {
529
- /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */
530
- export function load8_u(ptr: usize, immOffset?: usize): i64;
531
- /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */
532
- export function load16_u(ptr: usize, immOffset?: usize): i64;
533
- /** Atomically loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */
534
- export function load32_u(ptr: usize, immOffset?: usize): i64;
535
- /** Atomically loads a 64-bit integer value from memory and returns it. */
536
- export function load(ptr: usize, immOffset?: usize): i64;
537
- /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */
538
- export function store8(ptr: usize, value: i64, immOffset?: usize): void;
539
- /** Atomically stores a 64-bit integer value to memory as a 16-bit integer. */
540
- export function store16(ptr: usize, value: i64, immOffset?: usize): void;
541
- /** Atomically stores a 64-bit integer value to memory as a 32-bit integer. */
542
- export function store32(ptr: usize, value: i64, immOffset?: usize): void;
543
- /** Atomically stores a 64-bit integer value to memory. */
544
- export function store(ptr: usize, value: i64, immOffset?: usize): void;
545
- /** Atomic 64-bit integer read-modify-write operations on 8-bit values. */
546
- export namespace rmw8 {
547
- /** Atomically adds an 8-bit unsigned integer value in memory. */
548
- export function add_u(ptr: usize, value: i64, immOffset?: usize): i64;
549
- /** Atomically subtracts an 8-bit unsigned integer value in memory. */
550
- export function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;
551
- /** Atomically performs a bitwise AND operation on an 8-bit unsigned integer value in memory. */
552
- export function and_u(ptr: usize, value: i64, immOffset?: usize): i64;
553
- /** Atomically performs a bitwise OR operation on an 8-bit unsigned integer value in memory. */
554
- export function or_u(ptr: usize, value: i64, immOffset?: usize): i64;
555
- /** Atomically performs a bitwise XOR operation on an 8-bit unsigned integer value in memory. */
556
- export function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;
557
- /** Atomically exchanges an 8-bit unsigned integer value in memory. */
558
- export function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;
559
- /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */
560
- export function cmpxchg_u(ptr: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
561
- }
562
- /** Atomic 64-bit integer read-modify-write operations on 16-bit values. */
563
- export namespace rmw16 {
564
- /** Atomically adds a 16-bit unsigned integer value in memory. */
565
- export function add_u(ptr: usize, value: i64, immOffset?: usize): i64;
566
- /** Atomically subtracts a 16-bit unsigned integer value in memory. */
567
- export function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;
568
- /** Atomically performs a bitwise AND operation on a 16-bit unsigned integer value in memory. */
569
- export function and_u(ptr: usize, value: i64, immOffset?: usize): i64;
570
- /** Atomically performs a bitwise OR operation on a 16-bit unsigned integer value in memory. */
571
- export function or_u(ptr: usize, value: i64, immOffset?: usize): i64;
572
- /** Atomically performs a bitwise XOR operation on a 16-bit unsigned integer value in memory. */
573
- export function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;
574
- /** Atomically exchanges a 16-bit unsigned integer value in memory. */
575
- export function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;
576
- /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */
577
- export function cmpxchg_u(ptr: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
578
- }
579
- /** Atomic 64-bit integer read-modify-write operations on 32-bit values. */
580
- export namespace rmw32 {
581
- /** Atomically adds a 32-bit unsigned integer value in memory. */
582
- export function add_u(ptr: usize, value: i64, immOffset?: usize): i64;
583
- /** Atomically subtracts a 32-bit unsigned integer value in memory. */
584
- export function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;
585
- /** Atomically performs a bitwise AND operation on a 32-bit unsigned integer value in memory. */
586
- export function and_u(ptr: usize, value: i64, immOffset?: usize): i64;
587
- /** Atomically performs a bitwise OR operation on a 32-bit unsigned integer value in memory. */
588
- export function or_u(ptr: usize, value: i64, immOffset?: usize): i64;
589
- /** Atomically performs a bitwise XOR operation on a 32-bit unsigned integer value in memory. */
590
- export function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;
591
- /** Atomically exchanges a 32-bit unsigned integer value in memory. */
592
- export function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;
593
- /** Atomically compares and exchanges a 32-bit unsigned integer value in memory if the condition is met. */
594
- export function cmpxchg_u(ptr: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
595
- }
596
- /** Atomic 64-bit integer read-modify-write operations. */
597
- export namespace rmw {
598
- /** Atomically adds a 64-bit integer value in memory. */
599
- export function add(ptr: usize, value: i64, immOffset?: usize): i64;
600
- /** Atomically subtracts a 64-bit integer value in memory. */
601
- export function sub(ptr: usize, value: i64, immOffset?: usize): i64;
602
- /** Atomically performs a bitwise AND operation on a 64-bit integer value in memory. */
603
- export function and(ptr: usize, value: i64, immOffset?: usize): i64;
604
- /** Atomically performs a bitwise OR operation on a 64-bit integer value in memory. */
605
- export function or(ptr: usize, value: i64, immOffset?: usize): i64;
606
- /** Atomically performs a bitwise XOR operation on a 64-bit integer value in memory. */
607
- export function xor(ptr: usize, value: i64, immOffset?: usize): i64;
608
- /** Atomically exchanges a 64-bit integer value in memory. */
609
- export function xchg(ptr: usize, value: i64, immOffset?: usize): i64;
610
- /** Atomically compares and exchanges a 64-bit integer value in memory if the condition is met. */
611
- export function cmpxchg(ptr: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
612
- }
613
- }
614
421
  }
615
- /** Converts any other numeric value to a 32-bit (in WASM32) respectively 64-bit (in WASM64) signed integer. */
616
- declare let isize: typeof i32 | typeof i64;
422
+ /** Converts any other numeric value to a 32-bit signed integer. */
423
+ declare let isize: typeof i32;
617
424
  /** Converts any other numeric value to an 8-bit unsigned integer. */
618
425
  declare function u8(value: any): u8;
619
426
  declare namespace u8 {
@@ -654,8 +461,8 @@ declare namespace u64 {
654
461
  /** Parses a string as an u64. */
655
462
  export function parse(value: string, radix?: i32): u64;
656
463
  }
657
- /** Converts any other numeric value to a 32-bit (in WASM32) respectively 64-bit (in WASM64) unsigned integer. */
658
- declare let usize: typeof u32 | typeof u64;
464
+ /** Converts any other numeric value to a 32-bit unsigned integer. */
465
+ declare let usize: typeof u32;
659
466
  /** Converts any other numeric value to a 1-bit unsigned integer. */
660
467
  declare function bool(value: any): bool;
661
468
  declare namespace bool {
@@ -1714,6 +1521,10 @@ declare namespace f64x2 {
1714
1521
  export function relaxed_max(a: v128, b: v128): v128;
1715
1522
  }
1716
1523
 
1524
+ declare namespace ffi {
1525
+ function set_ffi_closure_env(value: i32): void;
1526
+ }
1527
+
1717
1528
  declare abstract class i31 {
1718
1529
  /** Creates a new 31-bit integer reference from the specified integer value. */
1719
1530
  static new(value: i32): ref_i31;
@@ -1851,13 +1662,6 @@ declare namespace memory {
1851
1662
  export function data(size: i32, align?: i32): usize;
1852
1663
  /** Gets a pointer to a pre-initialized static chunk of memory. Alignment defaults to the size of `T`. Arguments must be compile-time constants. */
1853
1664
  export function data<T>(values: T[], align?: i32): usize;
1854
-
1855
- export namespace atomic {
1856
- /** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */
1857
- export function wait32(ptr: usize, expected: i32, timeout?: i64): AtomicWaitResult;
1858
- /** Performs a wait operation on a 64-bit integer value in memory suspending this agent if the condition is met. */
1859
- export function wait64(ptr: usize, expected: i64, timeout?: i64): AtomicWaitResult;
1860
- }
1861
1665
  }
1862
1666
 
1863
1667
  /** Heap memory interface. */
@@ -1880,63 +1684,6 @@ declare namespace table {
1880
1684
  export function copy(dest: u32, src: u32, n: u32): void;
1881
1685
  }
1882
1686
 
1883
- declare namespace Atomics {
1884
- export function load<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(array: TypedArray<T>, index: i32): T;
1885
- export function store<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1886
- array: TypedArray<T>,
1887
- index: i32,
1888
- value: T
1889
- ): void;
1890
- export function add<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1891
- array: TypedArray<T>,
1892
- index: i32,
1893
- value: T
1894
- ): T;
1895
- export function sub<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1896
- array: TypedArray<T>,
1897
- index: i32,
1898
- value: T
1899
- ): T;
1900
- export function and<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1901
- array: TypedArray<T>,
1902
- index: i32,
1903
- value: T
1904
- ): T;
1905
- export function or<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1906
- array: TypedArray<T>,
1907
- index: i32,
1908
- value: T
1909
- ): T;
1910
- export function xor<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1911
- array: TypedArray<T>,
1912
- index: i32,
1913
- value: T
1914
- ): T;
1915
- export function exchange<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1916
- array: TypedArray<T>,
1917
- index: i32,
1918
- value: T
1919
- ): T;
1920
- export function compareExchange<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1921
- array: TypedArray<T>,
1922
- index: i32,
1923
- expectedValue: T,
1924
- replacementValue: T
1925
- ): T;
1926
- export function wait<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1927
- array: TypedArray<T>,
1928
- value: T,
1929
- timeout?: i64
1930
- ): AtomicWaitResult;
1931
- export function notify<T extends i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64>(
1932
- array: TypedArray<T>,
1933
- index: i32,
1934
- count?: i32
1935
- ): i32;
1936
- /** The static Atomics.isLockFree() method is used to determine whether to use locks or atomic operations. It returns true, if the given size is one of the BYTES_PER_ELEMENT */
1937
- export function isLockFree(size: usize): bool;
1938
- }
1939
-
1940
1687
  /** Class representing a generic, fixed-length raw binary data buffer. */
1941
1688
  declare class ArrayBuffer {
1942
1689
  /** The size, in bytes, of the array. */
@@ -2025,7 +1772,7 @@ interface ArrayBufferView {
2025
1772
  }
2026
1773
 
2027
1774
  /** @internal */
2028
- declare abstract class TypedArray<T> implements ArrayBufferView {
1775
+ declare abstract class TypedArray<T> implements ArrayBufferView, Iterable<T> {
2029
1776
  [key: number]: T;
2030
1777
  /** Number of bytes per element. */
2031
1778
  static readonly BYTES_PER_ELEMENT: usize;
@@ -2085,6 +1832,9 @@ declare abstract class TypedArray<T> implements ArrayBufferView {
2085
1832
  set<U extends ArrayLike<number>>(source: U, offset?: i32): void;
2086
1833
  /** The toString() method returns a string representing the specified array and its elements. This method has the same algorithm as Array.prototype.toString() */
2087
1834
  toString(): string;
1835
+
1836
+ /** Returns an iterator over the typed array's values. */
1837
+ [Symbol.iterator](): Iterator<T>;
2088
1838
  }
2089
1839
 
2090
1840
  /** An array of twos-complement 8-bit signed integers. */
@@ -2234,7 +1984,7 @@ declare class StaticArray<T> {
2234
1984
  }
2235
1985
 
2236
1986
  /** Class representing a sequence of characters. */
2237
- declare class String {
1987
+ declare class String implements Iterable<string> {
2238
1988
  [key: i32]: string;
2239
1989
  static fromCharCode(ls: i32, hs?: i32): string;
2240
1990
  static fromCharCodes(arr: i32[]): string;
@@ -2242,17 +1992,18 @@ declare class String {
2242
1992
  static fromCodePoints(arr: i32[]): string;
2243
1993
  static raw(parts: TemplateStringsArray, ...args: any[]): string;
2244
1994
  readonly length: i32;
1995
+ [Symbol.iterator](): Iterator<string>;
2245
1996
  at(index: i32): string;
2246
1997
  charAt(index: i32): string;
2247
1998
  charCodeAt(index: i32): i32;
2248
1999
  codePointAt(index: i32): i32;
2249
2000
  concat(other: string): string;
2250
- endsWith(other: string): bool;
2001
+ endsWith(other: string, position?: i32): bool;
2251
2002
  indexOf(other: string, fromIndex?: i32): i32;
2252
2003
  lastIndexOf(other: string, fromIndex?: i32): i32;
2253
2004
  localeCompare(other: string): i32;
2254
2005
  includes(other: string): bool;
2255
- startsWith(other: string): bool;
2006
+ startsWith(other: string, position?: i32): bool;
2256
2007
  substr(start: i32, length?: i32): string;
2257
2008
  substring(start: i32, end?: i32): string;
2258
2009
  trim(): string;
@@ -2319,16 +2070,9 @@ declare class Object {
2319
2070
  static is<T>(value1: T, value2: T): bool;
2320
2071
  }
2321
2072
 
2322
- declare namespace performance {
2323
- /** Gets a high resolution timestamp measured in milliseconds. */
2324
- export function now(): f64;
2325
- }
2326
-
2327
2073
  declare class Date {
2328
2074
  /** Returns the UTC timestamp in milliseconds of the specified date. */
2329
- static UTC(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32, millisecond: i32): i64;
2330
- /** Returns the current UTC timestamp in milliseconds. */
2331
- static now(): i64;
2075
+ static UTC(year: i32, month?: i32, day?: i32, hour?: i32, minute?: i32, second?: i32, millisecond?: i32): i64;
2332
2076
  /** Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. */
2333
2077
  static parse(dateString: string): Date;
2334
2078
  static fromString(dateString: string): Date;
@@ -2396,6 +2140,8 @@ declare class URIError extends Error {}
2396
2140
  interface Function {
2397
2141
  /** Function table index. */
2398
2142
  readonly index: u32;
2143
+ /** Function closure environment pointer. */
2144
+ readonly env: usize;
2399
2145
  /** Function name. Always an empty string. */
2400
2146
  readonly name: string;
2401
2147
  /** Number of expected parameters. */
@@ -2511,6 +2257,7 @@ declare class Map<K, V> {
2511
2257
  keys(): K[]; // preliminary
2512
2258
  values(): V[]; // preliminary
2513
2259
  toString(): string;
2260
+ [Symbol.iterator](): Iterator<[K, V]>;
2514
2261
  }
2515
2262
 
2516
2263
  declare class Set<K> {
@@ -2665,15 +2412,13 @@ interface INativeMath<T> extends IMath<T> {
2665
2412
  exp2(x: T): T;
2666
2413
  }
2667
2414
 
2668
- /** Double precision math imported from JavaScript. */
2669
- declare const JSMath: IMath<f64>;
2670
2415
  /** Double precision math implemented natively. */
2671
2416
  declare const NativeMath: INativeMath<f64>;
2672
2417
  /** Single precision math implemented natively. */
2673
2418
  declare const NativeMathf: INativeMath<f32>;
2674
- /** Alias of {@link NativeMath} or {@link JSMath} respectively. Defaults to `NativeMath`. */
2419
+ /** Alias of {@link NativeMath}. */
2675
2420
  declare const Math: IMath<f64>;
2676
- /** Alias of {@link NativeMathf} or {@link JSMath} respectively. Defaults to `NativeMathf`. */
2421
+ /** Alias of {@link NativeMathf}. */
2677
2422
  declare const Mathf: IMath<f32>;
2678
2423
 
2679
2424
  /** Environmental abort function. */
@@ -2685,69 +2430,10 @@ declare function seed(): f64;
2685
2430
 
2686
2431
  /** Node-like process. */
2687
2432
  declare namespace process {
2688
- /** String representing the CPU architecture for which the binary was compiled. Either `wasm32` or `wasm64`. */
2433
+ /** String representing the CPU architecture for which the binary was compiled. Always `wasm32`. */
2689
2434
  export const arch: string;
2690
2435
  /** String representing the operating system platform for which the binary was compiled. Always `wasm`. */
2691
2436
  export const platform: string;
2692
- /** Array of command line arguments passed to the binary upon instantiation. */
2693
- export const argv: string[];
2694
- /** Map of variables in the binary's user environment. */
2695
- export const env: Map<string, string>;
2696
- /** Terminates the process with either the given exit code, or `process.exitCode` if omitted. */
2697
- export function exit(code?: i32): void;
2698
- /** `exit()`’s default value. Defaults to `0`. */
2699
- export let exitCode: i32;
2700
- /** Stream connected to `stdin` (fd `0`). */
2701
- export const stdin: ReadableStream;
2702
- /** Stream connected to `stdout` (fd `1`). */
2703
- export const stdout: WritableStream;
2704
- /** Stream connected to `stderr` (fd `2`). */
2705
- export const stderr: WritableStream;
2706
- /** Obtains the system's current time of day, in milliseconds since Unix epoch. */
2707
- export function time(): i64;
2708
- /** Obtains the system's monotonic high resolution time, in nanoseconds since an arbitrary time in the past. */
2709
- export function hrtime(): u64;
2710
-
2711
- interface Stream {
2712
- /** Closes the stream. Throws if already closed or if the stream cannot be closed. */
2713
- close(): void;
2714
- }
2715
- interface ReadableStream extends Stream {
2716
- /** Reads available data from the stream, into `buffer` at offset `offset`, returning the number of bytes read. */
2717
- read(buffer: ArrayBuffer, offset?: isize): i32;
2718
- }
2719
- interface WritableStream extends Stream {
2720
- /** Writes string or buffer to the stream. */
2721
- write<T extends string | ArrayBuffer>(data: T): void;
2722
- }
2723
- }
2724
-
2725
- /** Browser-like console. */
2726
- declare namespace console {
2727
- /** Logs `message` to console if `assertion` is false-ish. */
2728
- export function assert<T>(assertion: T, message?: string): void;
2729
- /** Outputs `message` to the console. */
2730
- export function log(message?: string): void;
2731
- /** Outputs `message` to the console, prefixed with "Debug:". */
2732
- export function debug(message?: string): void;
2733
- /** Outputs `message` to the console, prefixed with "Info:". */
2734
- export function info(message?: string): void;
2735
- /** Outputs `message` to the console, prefixed with "Warning:". */
2736
- export function warn(message?: string): void;
2737
- /** Outputs `message` to the console, prefixed with "Error:". */
2738
- export function error(message?: string): void;
2739
- /** Starts a new timer using the specified `label`. */
2740
- export function time(label?: string): void;
2741
- /** Logs the current value of a timer previously started with `console.time`. */
2742
- export function timeLog(label?: string): void;
2743
- /** Logs the current value of a timer previously started with `console.time` and discards the timer. */
2744
- export function timeEnd(label?: string): void;
2745
- }
2746
-
2747
- /** Browser-like crypto utilities. */
2748
- declare namespace crypto {
2749
- /** Fills `array` with cryptographically strong random values. */
2750
- export function getRandomValues(array: Uint8Array): void;
2751
2437
  }
2752
2438
 
2753
2439
  // Decorators
@@ -0,0 +1,3 @@
1
+ {
2
+ "types": "index.d.ts"
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../tsconfig-std.json",
3
+ "include": ["./**/*.ts"]
4
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "allowJs": false,
5
+ "alwaysStrict": true,
6
+ "noImplicitAny": true,
7
+ "noImplicitReturns": true,
8
+ "noImplicitThis": true,
9
+ "noEmitOnError": true,
10
+ "strictNullChecks": true,
11
+ "experimentalDecorators": true,
12
+ "preserveConstEnums": false,
13
+ "downlevelIteration": true
14
+ }
15
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "./tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "target": "esnext",
5
+ "module": "commonjs",
6
+ "noLib": true,
7
+ "typeRoots": ["."],
8
+ "types": ["std"],
9
+ "paths": {
10
+ "*": ["../assemblyscript/std/assembly/*"]
11
+ }
12
+ }
13
+ }