@yabgu_gm/tensionscript 0.0.0-stage → 0.11.0

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 (117) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +97 -0
  3. package/README.md +156 -2
  4. package/bin/tensionscript.js +35 -0
  5. package/dist/asc.d.ts +4 -0
  6. package/dist/asc.generated.d.ts +12007 -0
  7. package/dist/asc.js +23474 -0
  8. package/dist/asc.js.map +7 -0
  9. package/dist/assemblyscript.d.ts +4 -0
  10. package/dist/assemblyscript.generated.d.ts +13221 -0
  11. package/dist/assemblyscript.js +337 -0
  12. package/dist/assemblyscript.js.map +7 -0
  13. package/dist/importmap.json +9 -0
  14. package/dist/transform.cjs +1 -0
  15. package/dist/transform.d.ts +1 -0
  16. package/dist/transform.js +1 -0
  17. package/dist/web.js +22 -0
  18. package/lib/binaryen.d.ts +2 -0
  19. package/lib/binaryen.js +2 -0
  20. package/package.json +116 -4
  21. package/std/README.md +6 -0
  22. package/std/assembly/array.ts +526 -0
  23. package/std/assembly/arraybuffer.ts +77 -0
  24. package/std/assembly/atomics.ts +127 -0
  25. package/std/assembly/bindings/asyncify.ts +16 -0
  26. package/std/assembly/bindings/dom.ts +291 -0
  27. package/std/assembly/bindings/node.ts +6 -0
  28. package/std/assembly/builtins.ts +2642 -0
  29. package/std/assembly/closures.ts +22 -0
  30. package/std/assembly/compat.ts +2 -0
  31. package/std/assembly/console.ts +42 -0
  32. package/std/assembly/crypto.ts +9 -0
  33. package/std/assembly/dataview.ts +181 -0
  34. package/std/assembly/date.ts +373 -0
  35. package/std/assembly/diagnostics.ts +11 -0
  36. package/std/assembly/error.ts +44 -0
  37. package/std/assembly/function.ts +38 -0
  38. package/std/assembly/index.d.ts +2721 -0
  39. package/std/assembly/iterator.ts +35 -0
  40. package/std/assembly/map.ts +260 -0
  41. package/std/assembly/math.ts +3289 -0
  42. package/std/assembly/memory.ts +123 -0
  43. package/std/assembly/number.ts +388 -0
  44. package/std/assembly/object.ts +36 -0
  45. package/std/assembly/performance.ts +9 -0
  46. package/std/assembly/polyfills.ts +27 -0
  47. package/std/assembly/process.ts +50 -0
  48. package/std/assembly/reference.ts +48 -0
  49. package/std/assembly/regexp.ts +12 -0
  50. package/std/assembly/rt/README.md +81 -0
  51. package/std/assembly/rt/common.ts +81 -0
  52. package/std/assembly/rt/index-incremental.ts +2 -0
  53. package/std/assembly/rt/index-minimal.ts +2 -0
  54. package/std/assembly/rt/index-stub.ts +1 -0
  55. package/std/assembly/rt/index.d.ts +37 -0
  56. package/std/assembly/rt/itcms.ts +419 -0
  57. package/std/assembly/rt/rtrace.ts +15 -0
  58. package/std/assembly/rt/stub.ts +133 -0
  59. package/std/assembly/rt/tcms.ts +254 -0
  60. package/std/assembly/rt/tlsf.ts +592 -0
  61. package/std/assembly/rt.ts +87 -0
  62. package/std/assembly/set.ts +220 -0
  63. package/std/assembly/shared/feature.ts +65 -0
  64. package/std/assembly/shared/runtime.ts +11 -0
  65. package/std/assembly/shared/target.ts +11 -0
  66. package/std/assembly/shared/tsconfig.json +11 -0
  67. package/std/assembly/shared/typeinfo.ts +72 -0
  68. package/std/assembly/staticarray.ts +401 -0
  69. package/std/assembly/string.ts +847 -0
  70. package/std/assembly/symbol.ts +114 -0
  71. package/std/assembly/table.ts +16 -0
  72. package/std/assembly/task-rt.ts +609 -0
  73. package/std/assembly/task.ts +90 -0
  74. package/std/assembly/tsconfig.json +6 -0
  75. package/std/assembly/typedarray.ts +1945 -0
  76. package/std/assembly/uri.ts +17 -0
  77. package/std/assembly/util/bytes.ts +135 -0
  78. package/std/assembly/util/casemap.ts +497 -0
  79. package/std/assembly/util/error.ts +54 -0
  80. package/std/assembly/util/hash.ts +117 -0
  81. package/std/assembly/util/math.ts +1922 -0
  82. package/std/assembly/util/memory.ts +290 -0
  83. package/std/assembly/util/number.ts +873 -0
  84. package/std/assembly/util/sort.ts +313 -0
  85. package/std/assembly/util/string.ts +1202 -0
  86. package/std/assembly/util/uri.ts +275 -0
  87. package/std/assembly/vector.ts +4 -0
  88. package/std/assembly.json +16 -0
  89. package/std/portable/index.d.ts +462 -0
  90. package/std/portable/index.js +416 -0
  91. package/std/portable.json +11 -0
  92. package/std/types/assembly/index.d.ts +1 -0
  93. package/std/types/assembly/package.json +3 -0
  94. package/std/types/portable/index.d.ts +1 -0
  95. package/std/types/portable/package.json +3 -0
  96. package/tsconfig-base.json +13 -0
  97. package/util/README.md +23 -0
  98. package/util/browser/fs.js +1 -0
  99. package/util/browser/module.js +5 -0
  100. package/util/browser/path.js +520 -0
  101. package/util/browser/process.js +59 -0
  102. package/util/browser/url.js +23 -0
  103. package/util/cpu.d.ts +9 -0
  104. package/util/cpu.js +42 -0
  105. package/util/find.d.ts +6 -0
  106. package/util/find.js +20 -0
  107. package/util/node.d.ts +21 -0
  108. package/util/node.js +34 -0
  109. package/util/options.d.ts +70 -0
  110. package/util/options.js +262 -0
  111. package/util/terminal.d.ts +52 -0
  112. package/util/terminal.js +35 -0
  113. package/util/text.d.ts +26 -0
  114. package/util/text.js +114 -0
  115. package/util/tsconfig.json +9 -0
  116. package/util/web.d.ts +11 -0
  117. package/util/web.js +33 -0
@@ -0,0 +1,90 @@
1
+ /// <reference path="./rt/index.d.ts" />
2
+
3
+ /**
4
+ * The base class of a task's on-heap record.
5
+ *
6
+ * The eight fields are `docs/async-await-plan-v2.md` §3.2's layout, verbatim and
7
+ * in order — the byte offsets are the contract codegen's typed read depends on
8
+ * (`src/compiler.ts:8025-8027` reads `payload` at 8 for the integer and `bool`
9
+ * kinds, and `f0`/`f1` at 16 for `f32` and the 64-bit kinds), so the declaration
10
+ * order and the types below are load-bearing:
11
+ *
12
+ * | field | offset | meaning |
13
+ * |---|---|---|
14
+ * | `class_` | 0 | the class the completion arrived as; 0 before delivery |
15
+ * | `key` | 4 | the producer's submit-time id (§3.1) |
16
+ * | `payload` | 8 | the producer's `b`, verbatim |
17
+ * | `status` | 12 | 0, or the capability's errno (§3.4) |
18
+ * | `f0` | 16 | the producer's `f0` |
19
+ * | `f1` | 20 | the producer's `f1` |
20
+ * | `tag` | 24 | the await tag; 0 today |
21
+ * | `done` | 28 | 0 = parked, 1 = settled |
22
+ *
23
+ * **Why std and not the framework** (Phase 4 ruling, plan §3.2): §7.1 gives the
24
+ * task machine to std and §3.2 gives it these offsets; a machine that must read
25
+ * `payload` at 8 cannot be written over a class that declares no fields. A
26
+ * capability that needs more subclasses `TaskRecord` — a subclass's fields start
27
+ * after the base's, so the offsets above are unchanged — and
28
+ * `__taskBindRecordFactory` (`task-rt.ts`) is how `__taskRegister` comes to
29
+ * allocate that subclass.
30
+ *
31
+ * It is a *managed* class so that `Task<T>._record` is a traced reference: a
32
+ * class-typed field is visited by the compiler-generated visitor (the
33
+ * `fieldType.isManaged` arm, `builtins.ts:10951-10962`), where a `usize` would
34
+ * not be. That trace is the bottom half of §4.4's root chain — task table →
35
+ * `TaskRecord` → state struct → environment — and it is what keeps a suspended
36
+ * task's record, state struct and environment alive when the only remaining
37
+ * reference is a handle the guest is holding.
38
+ */
39
+ export class TaskRecord {
40
+ /** Offset 0: the class the completion arrived as; 0 before delivery. */
41
+ class_: i32 = 0;
42
+ /** Offset 4: the producer's submit-time id (§3.1). */
43
+ key: i32 = 0;
44
+ /** Offset 8: the producer's `b`, verbatim — integer and `bool` results. */
45
+ payload: i32 = 0;
46
+ /** Offset 12: 0, or the capability's errno (§3.4). */
47
+ status: i32 = 0;
48
+ /** Offset 16: the producer's `f0` — `f32` results, and the low half of 64-bit ones. */
49
+ f0: f32 = 0;
50
+ /** Offset 20: the producer's `f1` — the high half of 64-bit results. */
51
+ f1: f32 = 0;
52
+ /** Offset 24: the await tag (§3.1's limitation); 0 today. */
53
+ tag: i32 = 0;
54
+ /** Offset 28: 0 = parked, 1 = settled. */
55
+ done: i32 = 0;
56
+ }
57
+
58
+ /**
59
+ * A handle to an asynchronous operation's result.
60
+ *
61
+ * `Task<T>` is what a call to an `async function f(): T` produces, and what a
62
+ * capability's reader returns for work the host completes later
63
+ * (`docs/async-await-plan-v2.md` §1.2 rule 2 and §3.3). One handle type, one
64
+ * name: the design has no `Promise` and no second `Awaitable<T>` (§2.4).
65
+ *
66
+ * The type argument exists for the type checker. The layout is identical for
67
+ * every `T` — one word — exactly as `Function<T>`'s is (`std/assembly/function.ts`):
68
+ * the runtime's task record holds the value, and `await` reads it back through
69
+ * the record's typed read (§3.2).
70
+ *
71
+ * The runtime table, not this field, is the record's strong reference while a
72
+ * task is parked; a settled record nothing references is ordinary garbage (§3.2).
73
+ * The field is nonetheless a traced managed reference rather than an opaque
74
+ * `usize` (the divergence §2.4's "single opaque `usize` field" left open, resolved
75
+ * in favor of §3.2's "managed reference to the owning `TaskRecord`"): a `usize`
76
+ * field is not traced by the generated visitor, so a handle the guest holds across
77
+ * a suspension would be the *only* path to the record and the collector could not
78
+ * see through it — the record, its state struct and its environment could be
79
+ * collected while the task was still parked, and the resume would be a
80
+ * use-after-free. As a class-typed field it is traced, and the handle alone keeps
81
+ * the chain alive. The layout is unchanged: one word, identical for every `T`.
82
+ *
83
+ * Not `private`: the runtime that creates the record owns the handle's
84
+ * construction, and the lowering reads it from generated code (§4.1's
85
+ * `state.handle`). Nothing else may touch it.
86
+ */
87
+ @final export class Task<T> {
88
+ /** Managed reference to the runtime's record for this task. */
89
+ _record!: TaskRecord;
90
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../assembly.json",
3
+ "include": [
4
+ "./**/*.ts"
5
+ ]
6
+ }