toilscript 0.0.1 → 0.1.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 (121) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +94 -94
  3. package/README.md +101 -114
  4. package/bin/asc.js +0 -0
  5. package/bin/asinit.js +6 -6
  6. package/dist/asc.generated.d.ts +10027 -0
  7. package/dist/asc.js +24474 -0
  8. package/dist/asc.js.map +7 -0
  9. package/dist/importmap.json +9 -0
  10. package/dist/toilscript.generated.d.ts +11242 -0
  11. package/dist/toilscript.js +337 -0
  12. package/dist/toilscript.js.map +7 -0
  13. package/dist/web.js +22 -0
  14. package/lib/binaryen.d.ts +2 -2
  15. package/lib/binaryen.js +2 -2
  16. package/package.json +115 -114
  17. package/std/README.md +6 -6
  18. package/std/assembly/array.ts +550 -550
  19. package/std/assembly/arraybuffer.ts +77 -77
  20. package/std/assembly/atomics.ts +127 -127
  21. package/std/assembly/bindings/asyncify.ts +16 -16
  22. package/std/assembly/bindings/dom.ts +291 -291
  23. package/std/assembly/bindings/node.ts +6 -6
  24. package/std/assembly/bitflags.ts +53 -53
  25. package/std/assembly/builtins.ts +2650 -2650
  26. package/std/assembly/byteslice.ts +177 -177
  27. package/std/assembly/compat.ts +2 -2
  28. package/std/assembly/console.ts +42 -42
  29. package/std/assembly/crypto.ts +9 -9
  30. package/std/assembly/dataview.ts +181 -181
  31. package/std/assembly/date.ts +375 -375
  32. package/std/assembly/diagnostics.ts +11 -11
  33. package/std/assembly/encoding.ts +151 -151
  34. package/std/assembly/endian.ts +45 -45
  35. package/std/assembly/error.ts +44 -44
  36. package/std/assembly/fixedarray.ts +173 -173
  37. package/std/assembly/fixedmap.ts +326 -326
  38. package/std/assembly/fixedset.ts +275 -275
  39. package/std/assembly/function.ts +42 -42
  40. package/std/assembly/index.d.ts +2892 -2891
  41. package/std/assembly/iterator.ts +35 -35
  42. package/std/assembly/map.ts +269 -269
  43. package/std/assembly/math.ts +3289 -3289
  44. package/std/assembly/memory.ts +123 -123
  45. package/std/assembly/number.ts +388 -388
  46. package/std/assembly/object.ts +36 -36
  47. package/std/assembly/performance.ts +9 -9
  48. package/std/assembly/pointer.ts +80 -80
  49. package/std/assembly/polyfills.ts +27 -27
  50. package/std/assembly/process.ts +50 -50
  51. package/std/assembly/reference.ts +48 -48
  52. package/std/assembly/regexp.ts +12 -12
  53. package/std/assembly/rt/README.md +83 -83
  54. package/std/assembly/rt/common.ts +81 -81
  55. package/std/assembly/rt/index-incremental.ts +2 -2
  56. package/std/assembly/rt/index-memory.ts +1 -1
  57. package/std/assembly/rt/index-minimal.ts +2 -2
  58. package/std/assembly/rt/index-stub.ts +1 -1
  59. package/std/assembly/rt/index.d.ts +37 -37
  60. package/std/assembly/rt/itcms.ts +419 -419
  61. package/std/assembly/rt/memory-runtime.ts +94 -94
  62. package/std/assembly/rt/rtrace.ts +15 -15
  63. package/std/assembly/rt/stub.ts +133 -133
  64. package/std/assembly/rt/tcms.ts +254 -254
  65. package/std/assembly/rt/tlsf.ts +592 -592
  66. package/std/assembly/rt.ts +90 -90
  67. package/std/assembly/set.ts +225 -225
  68. package/std/assembly/shared/feature.ts +68 -68
  69. package/std/assembly/shared/runtime.ts +13 -13
  70. package/std/assembly/shared/target.ts +11 -11
  71. package/std/assembly/shared/tsconfig.json +11 -11
  72. package/std/assembly/shared/typeinfo.ts +72 -72
  73. package/std/assembly/staticarray.ts +423 -423
  74. package/std/assembly/string.ts +850 -850
  75. package/std/assembly/symbol.ts +114 -114
  76. package/std/assembly/table.ts +16 -16
  77. package/std/assembly/toilscript.ts +16 -0
  78. package/std/assembly/tsconfig.json +6 -6
  79. package/std/assembly/typedarray.ts +1954 -1954
  80. package/std/assembly/uri.ts +17 -17
  81. package/std/assembly/util/bytes.ts +107 -107
  82. package/std/assembly/util/casemap.ts +497 -497
  83. package/std/assembly/util/error.ts +58 -58
  84. package/std/assembly/util/hash.ts +117 -117
  85. package/std/assembly/util/math.ts +1922 -1922
  86. package/std/assembly/util/memory.ts +290 -290
  87. package/std/assembly/util/number.ts +873 -873
  88. package/std/assembly/util/sort.ts +313 -313
  89. package/std/assembly/util/string.ts +1202 -1202
  90. package/std/assembly/util/uri.ts +275 -275
  91. package/std/assembly/vector.ts +4 -4
  92. package/std/assembly.json +16 -16
  93. package/std/portable/index.d.ts +461 -461
  94. package/std/portable/index.js +416 -416
  95. package/std/portable.json +11 -11
  96. package/std/types/assembly/index.d.ts +1 -1
  97. package/std/types/assembly/package.json +2 -2
  98. package/std/types/portable/index.d.ts +1 -1
  99. package/std/types/portable/package.json +2 -2
  100. package/tsconfig-base.json +13 -13
  101. package/util/README.md +23 -23
  102. package/util/browser/fs.js +1 -1
  103. package/util/browser/module.js +5 -5
  104. package/util/browser/path.js +520 -520
  105. package/util/browser/process.js +59 -59
  106. package/util/browser/url.js +23 -23
  107. package/util/cpu.d.ts +9 -9
  108. package/util/cpu.js +42 -42
  109. package/util/find.d.ts +6 -6
  110. package/util/find.js +20 -20
  111. package/util/node.d.ts +21 -21
  112. package/util/node.js +34 -34
  113. package/util/options.d.ts +70 -70
  114. package/util/options.js +262 -262
  115. package/util/terminal.d.ts +52 -52
  116. package/util/terminal.js +35 -35
  117. package/util/text.d.ts +26 -26
  118. package/util/text.js +114 -114
  119. package/util/tsconfig.json +9 -9
  120. package/util/web.d.ts +11 -11
  121. package/util/web.js +33 -33
@@ -1,114 +1,114 @@
1
- import { Map } from "./map";
2
-
3
- // @ts-ignore: decorator
4
- @lazy let stringToId: Map<string, usize> = new Map();
5
-
6
- // @ts-ignore: decorator
7
- @lazy let idToString: Map<usize, string> = new Map();
8
-
9
- // @ts-ignore: decorator
10
- @lazy let nextId: usize = 12; // Symbol.unscopables + 1
11
-
12
- @unmanaged @final abstract class _Symbol {
13
-
14
- // TODO: all of the following default symbols are unused currently yet add to
15
- // binary size if #toString becomes compiled. Ultimately we'll most likely want
16
- // to remove the unsupported ones and only keep what's actually supported.
17
-
18
- // @ts-ignore: decorator
19
- @lazy
20
- static readonly hasInstance: symbol = changetype<symbol>(1);
21
-
22
- // @ts-ignore: decorator
23
- @lazy
24
- static readonly isConcatSpreadable: symbol = changetype<symbol>(2);
25
-
26
- // @ts-ignore: decorator
27
- @lazy
28
- static readonly isRegExp: symbol = changetype<symbol>(3);
29
-
30
- // @ts-ignore: decorator
31
- @lazy
32
- static readonly iterator: symbol = changetype<symbol>(3);
33
-
34
- // @ts-ignore: decorator
35
- @lazy
36
- static readonly match: symbol = changetype<symbol>(4);
37
-
38
- // @ts-ignore: decorator
39
- @lazy
40
- static readonly replace: symbol = changetype<symbol>(5);
41
-
42
- // @ts-ignore: decorator
43
- @lazy
44
- static readonly search: symbol = changetype<symbol>(6);
45
-
46
- // @ts-ignore: decorator
47
- @lazy
48
- static readonly species: symbol = changetype<symbol>(7);
49
-
50
- // @ts-ignore: decorator
51
- @lazy
52
- static readonly split: symbol = changetype<symbol>(8);
53
-
54
- // @ts-ignore: decorator
55
- @lazy
56
- static readonly toPrimitive: symbol = changetype<symbol>(9);
57
-
58
- // @ts-ignore: decorator
59
- @lazy
60
- static readonly toStringTag: symbol = changetype<symbol>(10);
61
-
62
- // @ts-ignore: decorator
63
- @lazy
64
- static readonly unscopables: symbol = changetype<symbol>(11);
65
-
66
- static for(key: string): symbol {
67
- if (stringToId.has(key)) return changetype<symbol>(stringToId.get(key));
68
- let id = nextId++;
69
- if (!id) unreachable(); // out of ids
70
- stringToId.set(key, id);
71
- idToString.set(id, key);
72
- return changetype<symbol>(id);
73
- }
74
-
75
- static keyFor(sym: symbol): string | null {
76
- return idToString.has(changetype<usize>(sym))
77
- ? idToString.get(changetype<usize>(sym))
78
- : null;
79
- }
80
-
81
- toString(): string {
82
- let id = changetype<usize>(this);
83
- let str = "";
84
- switch (<u32>id) {
85
- case 1: { str = "hasInstance"; break; }
86
- case 2: { str = "isConcatSpreadable"; break; }
87
- case 3: { str = "isRegExp"; break; }
88
- case 4: { str = "match"; break; }
89
- case 5: { str = "replace"; break; }
90
- case 6: { str = "search"; break; }
91
- case 7: { str = "species"; break; }
92
- case 8: { str = "split"; break; }
93
- case 9: { str = "toPrimitive"; break; }
94
- case 10: { str = "toStringTag"; break; }
95
- case 11: { str = "unscopables"; break; }
96
- default: {
97
- if (idToString != null && idToString.has(id)) str = idToString.get(id);
98
- break;
99
- }
100
- }
101
- return "Symbol(" + str + ")";
102
- }
103
- }
104
-
105
- export function Symbol(description: string | null = null): symbol {
106
- let id = nextId++;
107
- if (!id) unreachable(); // out of ids
108
- return changetype<symbol>(id);
109
- }
110
-
111
- export type Symbol = _Symbol;
112
-
113
- // @ts-ignore: nolib
114
- export type symbol = _Symbol;
1
+ import { Map } from "./map";
2
+
3
+ // @ts-ignore: decorator
4
+ @lazy let stringToId: Map<string, usize> = new Map();
5
+
6
+ // @ts-ignore: decorator
7
+ @lazy let idToString: Map<usize, string> = new Map();
8
+
9
+ // @ts-ignore: decorator
10
+ @lazy let nextId: usize = 12; // Symbol.unscopables + 1
11
+
12
+ @unmanaged @final abstract class _Symbol {
13
+
14
+ // TODO: all of the following default symbols are unused currently yet add to
15
+ // binary size if #toString becomes compiled. Ultimately we'll most likely want
16
+ // to remove the unsupported ones and only keep what's actually supported.
17
+
18
+ // @ts-ignore: decorator
19
+ @lazy
20
+ static readonly hasInstance: symbol = changetype<symbol>(1);
21
+
22
+ // @ts-ignore: decorator
23
+ @lazy
24
+ static readonly isConcatSpreadable: symbol = changetype<symbol>(2);
25
+
26
+ // @ts-ignore: decorator
27
+ @lazy
28
+ static readonly isRegExp: symbol = changetype<symbol>(3);
29
+
30
+ // @ts-ignore: decorator
31
+ @lazy
32
+ static readonly iterator: symbol = changetype<symbol>(3);
33
+
34
+ // @ts-ignore: decorator
35
+ @lazy
36
+ static readonly match: symbol = changetype<symbol>(4);
37
+
38
+ // @ts-ignore: decorator
39
+ @lazy
40
+ static readonly replace: symbol = changetype<symbol>(5);
41
+
42
+ // @ts-ignore: decorator
43
+ @lazy
44
+ static readonly search: symbol = changetype<symbol>(6);
45
+
46
+ // @ts-ignore: decorator
47
+ @lazy
48
+ static readonly species: symbol = changetype<symbol>(7);
49
+
50
+ // @ts-ignore: decorator
51
+ @lazy
52
+ static readonly split: symbol = changetype<symbol>(8);
53
+
54
+ // @ts-ignore: decorator
55
+ @lazy
56
+ static readonly toPrimitive: symbol = changetype<symbol>(9);
57
+
58
+ // @ts-ignore: decorator
59
+ @lazy
60
+ static readonly toStringTag: symbol = changetype<symbol>(10);
61
+
62
+ // @ts-ignore: decorator
63
+ @lazy
64
+ static readonly unscopables: symbol = changetype<symbol>(11);
65
+
66
+ static for(key: string): symbol {
67
+ if (stringToId.has(key)) return changetype<symbol>(stringToId.get(key));
68
+ let id = nextId++;
69
+ if (!id) unreachable(); // out of ids
70
+ stringToId.set(key, id);
71
+ idToString.set(id, key);
72
+ return changetype<symbol>(id);
73
+ }
74
+
75
+ static keyFor(sym: symbol): string | null {
76
+ return idToString.has(changetype<usize>(sym))
77
+ ? idToString.get(changetype<usize>(sym))
78
+ : null;
79
+ }
80
+
81
+ toString(): string {
82
+ let id = changetype<usize>(this);
83
+ let str = "";
84
+ switch (<u32>id) {
85
+ case 1: { str = "hasInstance"; break; }
86
+ case 2: { str = "isConcatSpreadable"; break; }
87
+ case 3: { str = "isRegExp"; break; }
88
+ case 4: { str = "match"; break; }
89
+ case 5: { str = "replace"; break; }
90
+ case 6: { str = "search"; break; }
91
+ case 7: { str = "species"; break; }
92
+ case 8: { str = "split"; break; }
93
+ case 9: { str = "toPrimitive"; break; }
94
+ case 10: { str = "toStringTag"; break; }
95
+ case 11: { str = "unscopables"; break; }
96
+ default: {
97
+ if (idToString != null && idToString.has(id)) str = idToString.get(id);
98
+ break;
99
+ }
100
+ }
101
+ return "Symbol(" + str + ")";
102
+ }
103
+ }
104
+
105
+ export function Symbol(description: string | null = null): symbol {
106
+ let id = nextId++;
107
+ if (!id) unreachable(); // out of ids
108
+ return changetype<symbol>(id);
109
+ }
110
+
111
+ export type Symbol = _Symbol;
112
+
113
+ // @ts-ignore: nolib
114
+ export type symbol = _Symbol;
@@ -1,16 +1,16 @@
1
- import { E_NOTIMPLEMENTED } from "./util/error";
2
-
3
- export namespace table {
4
-
5
- export function copy(dst: u32, src: u32, n: u32): void {
6
- throw new Error(E_NOTIMPLEMENTED);
7
- }
8
-
9
- export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void {
10
- throw new Error(E_NOTIMPLEMENTED);
11
- }
12
-
13
- export function drop(elementIndex: u32): void {
14
- throw new Error(E_NOTIMPLEMENTED);
15
- }
16
- }
1
+ import { E_NOTIMPLEMENTED } from "./util/error";
2
+
3
+ export namespace table {
4
+
5
+ export function copy(dst: u32, src: u32, n: u32): void {
6
+ throw new Error(E_NOTIMPLEMENTED);
7
+ }
8
+
9
+ export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void {
10
+ throw new Error(E_NOTIMPLEMENTED);
11
+ }
12
+
13
+ export function drop(elementIndex: u32): void {
14
+ throw new Error(E_NOTIMPLEMENTED);
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * ToilScript-native declarations.
3
+ *
4
+ * Compiler-level natives available everywhere with no import. `@main` is handled
5
+ * directly by the ToilScript compiler — it exports the decorated top-level
6
+ * function as the module's `main` entry — so this declaration exists only so
7
+ * editors and type-checking recognize the decorator. Future zero-import toil
8
+ * natives (globals/decorators) belong here too.
9
+ */
10
+
11
+ /**
12
+ * Marks a single top-level function as the module entry point. The compiler
13
+ * exports it as the WebAssembly export `main` — no `export` keyword needed.
14
+ * Exactly one `@main` is allowed per module.
15
+ */
16
+ declare function main(...args: any[]): any;
@@ -1,6 +1,6 @@
1
- {
2
- "extends": "../assembly.json",
3
- "include": [
4
- "./**/*.ts"
5
- ]
6
- }
1
+ {
2
+ "extends": "../assembly.json",
3
+ "include": [
4
+ "./**/*.ts"
5
+ ]
6
+ }