toilscript 0.0.1 → 0.1.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 (120) 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 +0 -0
  6. package/dist/asc.generated.d.ts +10022 -0
  7. package/dist/asc.js +24457 -0
  8. package/dist/asc.js.map +7 -0
  9. package/dist/importmap.json +9 -0
  10. package/dist/toilscript.generated.d.ts +11237 -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 +2891 -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/tsconfig.json +6 -6
  78. package/std/assembly/typedarray.ts +1954 -1954
  79. package/std/assembly/uri.ts +17 -17
  80. package/std/assembly/util/bytes.ts +107 -107
  81. package/std/assembly/util/casemap.ts +497 -497
  82. package/std/assembly/util/error.ts +58 -58
  83. package/std/assembly/util/hash.ts +117 -117
  84. package/std/assembly/util/math.ts +1922 -1922
  85. package/std/assembly/util/memory.ts +290 -290
  86. package/std/assembly/util/number.ts +873 -873
  87. package/std/assembly/util/sort.ts +313 -313
  88. package/std/assembly/util/string.ts +1202 -1202
  89. package/std/assembly/util/uri.ts +275 -275
  90. package/std/assembly/vector.ts +4 -4
  91. package/std/assembly.json +16 -16
  92. package/std/portable/index.d.ts +461 -461
  93. package/std/portable/index.js +416 -416
  94. package/std/portable.json +11 -11
  95. package/std/types/assembly/index.d.ts +1 -1
  96. package/std/types/assembly/package.json +2 -2
  97. package/std/types/portable/index.d.ts +1 -1
  98. package/std/types/portable/package.json +2 -2
  99. package/tsconfig-base.json +13 -13
  100. package/util/README.md +23 -23
  101. package/util/browser/fs.js +1 -1
  102. package/util/browser/module.js +5 -5
  103. package/util/browser/path.js +520 -520
  104. package/util/browser/process.js +59 -59
  105. package/util/browser/url.js +23 -23
  106. package/util/cpu.d.ts +9 -9
  107. package/util/cpu.js +42 -42
  108. package/util/find.d.ts +6 -6
  109. package/util/find.js +20 -20
  110. package/util/node.d.ts +21 -21
  111. package/util/node.js +34 -34
  112. package/util/options.d.ts +70 -70
  113. package/util/options.js +262 -262
  114. package/util/terminal.d.ts +52 -52
  115. package/util/terminal.js +35 -35
  116. package/util/text.d.ts +26 -26
  117. package/util/text.js +114 -114
  118. package/util/tsconfig.json +9 -9
  119. package/util/web.d.ts +11 -11
  120. package/util/web.js +33 -33
@@ -1,77 +1,77 @@
1
- /// <reference path="./rt/index.d.ts" />
2
-
3
- import { OBJECT, BLOCK_MAXSIZE, TOTAL_OVERHEAD } from "./rt/common";
4
- import { Runtime } from "shared/runtime";
5
- import { idof } from "./builtins";
6
- import { E_INVALIDLENGTH } from "./util/error";
7
-
8
- export abstract class ArrayBufferView {
9
-
10
- readonly buffer: ArrayBuffer;
11
- @unsafe readonly dataStart: usize;
12
- readonly byteLength: i32;
13
-
14
- get byteOffset(): i32 {
15
- return <i32>(this.dataStart - changetype<usize>(this.buffer));
16
- }
17
-
18
- protected constructor(length: i32, alignLog2: i32) {
19
- if (<u32>length > <u32>BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);
20
- let buffer = changetype<ArrayBuffer>(__new(length = length << alignLog2, idof<ArrayBuffer>()));
21
- if (ASC_RUNTIME != Runtime.Incremental) {
22
- memory.fill(changetype<usize>(buffer), 0, <usize>length);
23
- }
24
- this.buffer = buffer; // links
25
- this.dataStart = changetype<usize>(buffer);
26
- this.byteLength = length;
27
- }
28
- }
29
-
30
- @final export class ArrayBuffer {
31
-
32
- static isView<T>(value: T): bool {
33
- if (isNullable<T>()) {
34
- if (changetype<usize>(value) == 0) return false;
35
- }
36
- if (value instanceof Int8Array) return true;
37
- if (value instanceof Uint8Array) return true;
38
- if (value instanceof Uint8ClampedArray) return true;
39
- if (value instanceof Int16Array) return true;
40
- if (value instanceof Uint16Array) return true;
41
- if (value instanceof Int32Array) return true;
42
- if (value instanceof Uint32Array) return true;
43
- if (value instanceof Int64Array) return true;
44
- if (value instanceof Uint64Array) return true;
45
- if (value instanceof Float32Array) return true;
46
- if (value instanceof Float64Array) return true;
47
- if (value instanceof DataView) return true;
48
- return false;
49
- }
50
-
51
- constructor(length: i32) {
52
- if (<u32>length > <u32>BLOCK_MAXSIZE) throw new RangeError(E_INVALIDLENGTH);
53
- let buffer = changetype<ArrayBuffer>(__new(<usize>length, idof<ArrayBuffer>()));
54
- if (ASC_RUNTIME != Runtime.Incremental) {
55
- memory.fill(changetype<usize>(buffer), 0, <usize>length);
56
- }
57
- return buffer;
58
- }
59
-
60
- get byteLength(): i32 {
61
- return changetype<OBJECT>(changetype<usize>(this) - TOTAL_OVERHEAD).rtSize;
62
- }
63
-
64
- slice(begin: i32 = 0, end: i32 = BLOCK_MAXSIZE): ArrayBuffer {
65
- let length = this.byteLength;
66
- begin = begin < 0 ? max(length + begin, 0) : min(begin, length);
67
- end = end < 0 ? max(length + end , 0) : min(end , length);
68
- let outSize = <usize>max(end - begin, 0);
69
- let out = changetype<ArrayBuffer>(__new(outSize, idof<ArrayBuffer>()));
70
- memory.copy(changetype<usize>(out), changetype<usize>(this) + <usize>begin, outSize);
71
- return out;
72
- }
73
-
74
- toString(): string {
75
- return "[object ArrayBuffer]";
76
- }
77
- }
1
+ /// <reference path="./rt/index.d.ts" />
2
+
3
+ import { OBJECT, BLOCK_MAXSIZE, TOTAL_OVERHEAD } from "./rt/common";
4
+ import { Runtime } from "shared/runtime";
5
+ import { idof } from "./builtins";
6
+ import { E_INVALIDLENGTH } from "./util/error";
7
+
8
+ export abstract class ArrayBufferView {
9
+
10
+ readonly buffer: ArrayBuffer;
11
+ @unsafe readonly dataStart: usize;
12
+ readonly byteLength: i32;
13
+
14
+ get byteOffset(): i32 {
15
+ return <i32>(this.dataStart - changetype<usize>(this.buffer));
16
+ }
17
+
18
+ protected constructor(length: i32, alignLog2: i32) {
19
+ if (<u32>length > <u32>BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);
20
+ let buffer = changetype<ArrayBuffer>(__new(length = length << alignLog2, idof<ArrayBuffer>()));
21
+ if (ASC_RUNTIME != Runtime.Incremental) {
22
+ memory.fill(changetype<usize>(buffer), 0, <usize>length);
23
+ }
24
+ this.buffer = buffer; // links
25
+ this.dataStart = changetype<usize>(buffer);
26
+ this.byteLength = length;
27
+ }
28
+ }
29
+
30
+ @final export class ArrayBuffer {
31
+
32
+ static isView<T>(value: T): bool {
33
+ if (isNullable<T>()) {
34
+ if (changetype<usize>(value) == 0) return false;
35
+ }
36
+ if (value instanceof Int8Array) return true;
37
+ if (value instanceof Uint8Array) return true;
38
+ if (value instanceof Uint8ClampedArray) return true;
39
+ if (value instanceof Int16Array) return true;
40
+ if (value instanceof Uint16Array) return true;
41
+ if (value instanceof Int32Array) return true;
42
+ if (value instanceof Uint32Array) return true;
43
+ if (value instanceof Int64Array) return true;
44
+ if (value instanceof Uint64Array) return true;
45
+ if (value instanceof Float32Array) return true;
46
+ if (value instanceof Float64Array) return true;
47
+ if (value instanceof DataView) return true;
48
+ return false;
49
+ }
50
+
51
+ constructor(length: i32) {
52
+ if (<u32>length > <u32>BLOCK_MAXSIZE) throw new RangeError(E_INVALIDLENGTH);
53
+ let buffer = changetype<ArrayBuffer>(__new(<usize>length, idof<ArrayBuffer>()));
54
+ if (ASC_RUNTIME != Runtime.Incremental) {
55
+ memory.fill(changetype<usize>(buffer), 0, <usize>length);
56
+ }
57
+ return buffer;
58
+ }
59
+
60
+ get byteLength(): i32 {
61
+ return changetype<OBJECT>(changetype<usize>(this) - TOTAL_OVERHEAD).rtSize;
62
+ }
63
+
64
+ slice(begin: i32 = 0, end: i32 = BLOCK_MAXSIZE): ArrayBuffer {
65
+ let length = this.byteLength;
66
+ begin = begin < 0 ? max(length + begin, 0) : min(begin, length);
67
+ end = end < 0 ? max(length + end , 0) : min(end , length);
68
+ let outSize = <usize>max(end - begin, 0);
69
+ let out = changetype<ArrayBuffer>(__new(outSize, idof<ArrayBuffer>()));
70
+ memory.copy(changetype<usize>(out), changetype<usize>(this) + <usize>begin, outSize);
71
+ return out;
72
+ }
73
+
74
+ toString(): string {
75
+ return "[object ArrayBuffer]";
76
+ }
77
+ }
@@ -1,127 +1,127 @@
1
- import { ArrayBufferView } from "./arraybuffer";
2
- import { E_INDEXOUTOFRANGE } from "./util/error";
3
-
4
- export namespace Atomics {
5
-
6
- // @ts-ignore: decorator
7
- @inline
8
- export function load<T extends ArrayBufferView>(array: T, index: i32): valueof<T> {
9
- const align = alignof<valueof<T>>();
10
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
11
- return atomic.load<valueof<T>>(
12
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset
13
- );
14
- }
15
-
16
- // @ts-ignore: decorator
17
- @inline
18
- export function store<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): void {
19
- const align = alignof<valueof<T>>();
20
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
21
- atomic.store<valueof<T>>(
22
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
23
- value
24
- );
25
- }
26
-
27
- // @ts-ignore: decorator
28
- @inline
29
- export function add<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
30
- const align = alignof<valueof<T>>();
31
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
32
- return atomic.add<valueof<T>>(
33
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
34
- value
35
- );
36
- }
37
-
38
- // @ts-ignore: decorator
39
- @inline
40
- export function sub<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
41
- const align = alignof<valueof<T>>();
42
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
43
- return atomic.sub<valueof<T>>(
44
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
45
- value
46
- );
47
- }
48
-
49
- // @ts-ignore: decorator
50
- @inline
51
- export function and<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
52
- const align = alignof<valueof<T>>();
53
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
54
- return atomic.and<valueof<T>>(
55
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
56
- value
57
- );
58
- }
59
-
60
- // @ts-ignore: decorator
61
- @inline
62
- export function or<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
63
- const align = alignof<valueof<T>>();
64
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
65
- return atomic.or<valueof<T>>(
66
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
67
- value
68
- );
69
- }
70
-
71
- // @ts-ignore: decorator
72
- @inline
73
- export function xor<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
74
- const align = alignof<valueof<T>>();
75
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
76
- return atomic.xor<valueof<T>>(
77
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
78
- value
79
- );
80
- }
81
-
82
- // @ts-ignore: decorator
83
- @inline
84
- export function exchange<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
85
- const align = alignof<valueof<T>>();
86
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
87
- return atomic.xchg<valueof<T>>(
88
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
89
- value
90
- );
91
- }
92
-
93
- // @ts-ignore: decorator
94
- @inline
95
- export function compareExchange<T extends ArrayBufferView>(
96
- array: T,
97
- index: i32,
98
- expectedValue: valueof<T>,
99
- replacementValue: valueof<T>
100
- ): valueof<T> {
101
- const align = alignof<valueof<T>>();
102
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
103
- return atomic.cmpxchg<valueof<T>>(
104
- changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
105
- expectedValue,
106
- replacementValue
107
- );
108
- }
109
-
110
- // @ts-ignore: decorator
111
- @inline
112
- export function wait<T extends ArrayBufferView>(array: T, value: valueof<T>, timeout: i64 = -1): AtomicWaitResult {
113
- return atomic.wait<valueof<T>>(changetype<usize>(array.buffer) + array.byteOffset, value, timeout);
114
- }
115
-
116
- // @ts-ignore: decorator
117
- @inline
118
- export function notify<T extends ArrayBufferView>(array: T, index: i32, count: i32 = -1): i32 {
119
- const align = alignof<valueof<T>>();
120
- if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
121
- return atomic.notify(changetype<usize>(array.buffer) + (index << align) + array.byteOffset, count);
122
- }
123
-
124
- export function isLockFree(size: usize): bool {
125
- return size == 1 || size == 2 || size == 4;
126
- }
127
- }
1
+ import { ArrayBufferView } from "./arraybuffer";
2
+ import { E_INDEXOUTOFRANGE } from "./util/error";
3
+
4
+ export namespace Atomics {
5
+
6
+ // @ts-ignore: decorator
7
+ @inline
8
+ export function load<T extends ArrayBufferView>(array: T, index: i32): valueof<T> {
9
+ const align = alignof<valueof<T>>();
10
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
11
+ return atomic.load<valueof<T>>(
12
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset
13
+ );
14
+ }
15
+
16
+ // @ts-ignore: decorator
17
+ @inline
18
+ export function store<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): void {
19
+ const align = alignof<valueof<T>>();
20
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
21
+ atomic.store<valueof<T>>(
22
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
23
+ value
24
+ );
25
+ }
26
+
27
+ // @ts-ignore: decorator
28
+ @inline
29
+ export function add<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
30
+ const align = alignof<valueof<T>>();
31
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
32
+ return atomic.add<valueof<T>>(
33
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
34
+ value
35
+ );
36
+ }
37
+
38
+ // @ts-ignore: decorator
39
+ @inline
40
+ export function sub<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
41
+ const align = alignof<valueof<T>>();
42
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
43
+ return atomic.sub<valueof<T>>(
44
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
45
+ value
46
+ );
47
+ }
48
+
49
+ // @ts-ignore: decorator
50
+ @inline
51
+ export function and<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
52
+ const align = alignof<valueof<T>>();
53
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
54
+ return atomic.and<valueof<T>>(
55
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
56
+ value
57
+ );
58
+ }
59
+
60
+ // @ts-ignore: decorator
61
+ @inline
62
+ export function or<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
63
+ const align = alignof<valueof<T>>();
64
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
65
+ return atomic.or<valueof<T>>(
66
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
67
+ value
68
+ );
69
+ }
70
+
71
+ // @ts-ignore: decorator
72
+ @inline
73
+ export function xor<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
74
+ const align = alignof<valueof<T>>();
75
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
76
+ return atomic.xor<valueof<T>>(
77
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
78
+ value
79
+ );
80
+ }
81
+
82
+ // @ts-ignore: decorator
83
+ @inline
84
+ export function exchange<T extends ArrayBufferView>(array: T, index: i32, value: valueof<T>): valueof<T> {
85
+ const align = alignof<valueof<T>>();
86
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
87
+ return atomic.xchg<valueof<T>>(
88
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
89
+ value
90
+ );
91
+ }
92
+
93
+ // @ts-ignore: decorator
94
+ @inline
95
+ export function compareExchange<T extends ArrayBufferView>(
96
+ array: T,
97
+ index: i32,
98
+ expectedValue: valueof<T>,
99
+ replacementValue: valueof<T>
100
+ ): valueof<T> {
101
+ const align = alignof<valueof<T>>();
102
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
103
+ return atomic.cmpxchg<valueof<T>>(
104
+ changetype<usize>(array.buffer) + (index << align) + array.byteOffset,
105
+ expectedValue,
106
+ replacementValue
107
+ );
108
+ }
109
+
110
+ // @ts-ignore: decorator
111
+ @inline
112
+ export function wait<T extends ArrayBufferView>(array: T, value: valueof<T>, timeout: i64 = -1): AtomicWaitResult {
113
+ return atomic.wait<valueof<T>>(changetype<usize>(array.buffer) + array.byteOffset, value, timeout);
114
+ }
115
+
116
+ // @ts-ignore: decorator
117
+ @inline
118
+ export function notify<T extends ArrayBufferView>(array: T, index: i32, count: i32 = -1): i32 {
119
+ const align = alignof<valueof<T>>();
120
+ if (index < 0 || (index << align) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
121
+ return atomic.notify(changetype<usize>(array.buffer) + (index << align) + array.byteOffset, count);
122
+ }
123
+
124
+ export function isLockFree(size: usize): bool {
125
+ return size == 1 || size == 2 || size == 4;
126
+ }
127
+ }
@@ -1,16 +1,16 @@
1
- @unmanaged
2
- export class StackDescriptor {
3
- /** The index in linear memory of the start of the “asyncify stack”. */
4
- stackStart: usize;
5
- /** The index of the end of that stack region, which implies how big it is. */
6
- stackEnd: usize;
7
- }
8
-
9
- /** Starts to unwind the call stack. */
10
- export declare function start_unwind(data: StackDescriptor): void;
11
- /** Stops unwinding the call stack. */
12
- export declare function stop_unwind(): void;
13
- /** Starts to rewind the call stack. */
14
- export declare function start_rewind(data: StackDescriptor): void;
15
- /** Stops rewinding the call stack. */
16
- export declare function stop_rewind(): void;
1
+ @unmanaged
2
+ export class StackDescriptor {
3
+ /** The index in linear memory of the start of the “asyncify stack”. */
4
+ stackStart: usize;
5
+ /** The index of the end of that stack region, which implies how big it is. */
6
+ stackEnd: usize;
7
+ }
8
+
9
+ /** Starts to unwind the call stack. */
10
+ export declare function start_unwind(data: StackDescriptor): void;
11
+ /** Stops unwinding the call stack. */
12
+ export declare function stop_unwind(): void;
13
+ /** Starts to rewind the call stack. */
14
+ export declare function start_rewind(data: StackDescriptor): void;
15
+ /** Stops rewinding the call stack. */
16
+ export declare function stop_rewind(): void;