toilscript 0.0.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.
- package/LICENSE +201 -0
- package/NOTICE +94 -0
- package/README.md +114 -0
- package/bin/asc.js +35 -0
- package/bin/asinit.js +468 -0
- package/dist/asc.d.ts +4 -0
- package/dist/toilscript.d.ts +4 -0
- package/dist/transform.cjs +1 -0
- package/dist/transform.d.ts +1 -0
- package/dist/transform.js +1 -0
- package/lib/binaryen.d.ts +2 -0
- package/lib/binaryen.js +2 -0
- package/package.json +114 -0
- package/std/README.md +6 -0
- package/std/assembly/array.ts +550 -0
- package/std/assembly/arraybuffer.ts +77 -0
- package/std/assembly/atomics.ts +127 -0
- package/std/assembly/bindings/asyncify.ts +16 -0
- package/std/assembly/bindings/dom.ts +291 -0
- package/std/assembly/bindings/node.ts +6 -0
- package/std/assembly/bitflags.ts +53 -0
- package/std/assembly/builtins.ts +2650 -0
- package/std/assembly/byteslice.ts +177 -0
- package/std/assembly/compat.ts +2 -0
- package/std/assembly/console.ts +42 -0
- package/std/assembly/crypto.ts +9 -0
- package/std/assembly/dataview.ts +181 -0
- package/std/assembly/date.ts +375 -0
- package/std/assembly/diagnostics.ts +11 -0
- package/std/assembly/encoding.ts +151 -0
- package/std/assembly/endian.ts +45 -0
- package/std/assembly/error.ts +44 -0
- package/std/assembly/fixedarray.ts +173 -0
- package/std/assembly/fixedmap.ts +326 -0
- package/std/assembly/fixedset.ts +275 -0
- package/std/assembly/function.ts +42 -0
- package/std/assembly/index.d.ts +2891 -0
- package/std/assembly/iterator.ts +35 -0
- package/std/assembly/map.ts +269 -0
- package/std/assembly/math.ts +3289 -0
- package/std/assembly/memory.ts +123 -0
- package/std/assembly/number.ts +388 -0
- package/std/assembly/object.ts +36 -0
- package/std/assembly/performance.ts +9 -0
- package/std/assembly/pointer.ts +80 -0
- package/std/assembly/polyfills.ts +27 -0
- package/std/assembly/process.ts +50 -0
- package/std/assembly/reference.ts +48 -0
- package/std/assembly/regexp.ts +12 -0
- package/std/assembly/rt/README.md +83 -0
- package/std/assembly/rt/common.ts +81 -0
- package/std/assembly/rt/index-incremental.ts +2 -0
- package/std/assembly/rt/index-memory.ts +1 -0
- package/std/assembly/rt/index-minimal.ts +2 -0
- package/std/assembly/rt/index-stub.ts +1 -0
- package/std/assembly/rt/index.d.ts +37 -0
- package/std/assembly/rt/itcms.ts +419 -0
- package/std/assembly/rt/memory-runtime.ts +94 -0
- package/std/assembly/rt/rtrace.ts +15 -0
- package/std/assembly/rt/stub.ts +133 -0
- package/std/assembly/rt/tcms.ts +254 -0
- package/std/assembly/rt/tlsf.ts +592 -0
- package/std/assembly/rt.ts +90 -0
- package/std/assembly/set.ts +225 -0
- package/std/assembly/shared/feature.ts +68 -0
- package/std/assembly/shared/runtime.ts +13 -0
- package/std/assembly/shared/target.ts +11 -0
- package/std/assembly/shared/tsconfig.json +11 -0
- package/std/assembly/shared/typeinfo.ts +72 -0
- package/std/assembly/staticarray.ts +423 -0
- package/std/assembly/string.ts +850 -0
- package/std/assembly/symbol.ts +114 -0
- package/std/assembly/table.ts +16 -0
- package/std/assembly/tsconfig.json +6 -0
- package/std/assembly/typedarray.ts +1954 -0
- package/std/assembly/uri.ts +17 -0
- package/std/assembly/util/bytes.ts +107 -0
- package/std/assembly/util/casemap.ts +497 -0
- package/std/assembly/util/error.ts +58 -0
- package/std/assembly/util/hash.ts +117 -0
- package/std/assembly/util/math.ts +1922 -0
- package/std/assembly/util/memory.ts +290 -0
- package/std/assembly/util/number.ts +873 -0
- package/std/assembly/util/sort.ts +313 -0
- package/std/assembly/util/string.ts +1202 -0
- package/std/assembly/util/uri.ts +275 -0
- package/std/assembly/vector.ts +4 -0
- package/std/assembly.json +16 -0
- package/std/portable/index.d.ts +461 -0
- package/std/portable/index.js +416 -0
- package/std/portable.json +11 -0
- package/std/types/assembly/index.d.ts +1 -0
- package/std/types/assembly/package.json +3 -0
- package/std/types/portable/index.d.ts +1 -0
- package/std/types/portable/package.json +3 -0
- package/tsconfig-base.json +13 -0
- package/util/README.md +23 -0
- package/util/browser/fs.js +1 -0
- package/util/browser/module.js +5 -0
- package/util/browser/path.js +520 -0
- package/util/browser/process.js +59 -0
- package/util/browser/url.js +23 -0
- package/util/cpu.d.ts +9 -0
- package/util/cpu.js +42 -0
- package/util/find.d.ts +6 -0
- package/util/find.js +20 -0
- package/util/node.d.ts +21 -0
- package/util/node.js +34 -0
- package/util/options.d.ts +70 -0
- package/util/options.js +262 -0
- package/util/terminal.d.ts +52 -0
- package/util/terminal.js +35 -0
- package/util/text.d.ts +26 -0
- package/util/text.js +114 -0
- package/util/tsconfig.json +9 -0
- package/util/web.d.ts +11 -0
- package/util/web.js +33 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/// <reference path="./rt/index.d.ts" />
|
|
2
|
+
|
|
3
|
+
import { HASH } from "./util/hash";
|
|
4
|
+
import { Runtime } from "shared/runtime";
|
|
5
|
+
|
|
6
|
+
// A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht
|
|
7
|
+
|
|
8
|
+
// @ts-ignore: decorator
|
|
9
|
+
@inline const INITIAL_CAPACITY = 4;
|
|
10
|
+
|
|
11
|
+
// @ts-ignore: decorator
|
|
12
|
+
@inline const FILL_FACTOR_N = 8;
|
|
13
|
+
|
|
14
|
+
// @ts-ignore: decorator
|
|
15
|
+
@inline const FILL_FACTOR_D = 3;
|
|
16
|
+
|
|
17
|
+
// @ts-ignore: decorator
|
|
18
|
+
@inline const FREE_FACTOR_N = 3;
|
|
19
|
+
|
|
20
|
+
// @ts-ignore: decorator
|
|
21
|
+
@inline const FREE_FACTOR_D = 4;
|
|
22
|
+
|
|
23
|
+
/** Structure of a set entry. */
|
|
24
|
+
@unmanaged class SetEntry<K> {
|
|
25
|
+
key: K;
|
|
26
|
+
taggedNext: usize; // LSB=1 indicates EMPTY
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Empty bit. */
|
|
30
|
+
// @ts-ignore: decorator
|
|
31
|
+
@inline const EMPTY: usize = 1 << 0;
|
|
32
|
+
|
|
33
|
+
/** Size of a bucket. */
|
|
34
|
+
// @ts-ignore: decorator
|
|
35
|
+
@inline const BUCKET_SIZE = sizeof<usize>();
|
|
36
|
+
|
|
37
|
+
/** Computes the alignment of an entry. */
|
|
38
|
+
// @ts-ignore: decorator
|
|
39
|
+
@inline
|
|
40
|
+
function ENTRY_ALIGN<T>(): usize {
|
|
41
|
+
// can align to 4 instead of 8 if 32-bit and K is <= 32-bits
|
|
42
|
+
const align = (sizeof<T>() > sizeof<usize>() ? sizeof<T>() : sizeof<usize>()) - 1;
|
|
43
|
+
return align;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Computes the aligned size of an entry. */
|
|
47
|
+
// @ts-ignore: decorator
|
|
48
|
+
@inline
|
|
49
|
+
function ENTRY_SIZE<T>(): usize {
|
|
50
|
+
const align = ENTRY_ALIGN<T>();
|
|
51
|
+
const size = (offsetof<SetEntry<T>>() + align) & ~align;
|
|
52
|
+
return size;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class Set<T> {
|
|
56
|
+
|
|
57
|
+
// buckets referencing their respective first entry, usize[bucketsMask + 1]
|
|
58
|
+
private buckets: ArrayBuffer = new ArrayBuffer(INITIAL_CAPACITY * <i32>BUCKET_SIZE);
|
|
59
|
+
private bucketsMask: u32 = INITIAL_CAPACITY - 1;
|
|
60
|
+
|
|
61
|
+
// entries in insertion order, SetEntry<K>[entriesCapacity]
|
|
62
|
+
private entries: ArrayBuffer = new ArrayBuffer(INITIAL_CAPACITY * <i32>ENTRY_SIZE<T>());
|
|
63
|
+
private entriesCapacity: i32 = INITIAL_CAPACITY;
|
|
64
|
+
private entriesOffset: i32 = 0;
|
|
65
|
+
private entriesCount: i32 = 0;
|
|
66
|
+
|
|
67
|
+
constructor() {
|
|
68
|
+
/* nop */
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get size(): i32 {
|
|
72
|
+
return this.entriesCount;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
clear(): void {
|
|
76
|
+
this.buckets = new ArrayBuffer(INITIAL_CAPACITY * <i32>BUCKET_SIZE);
|
|
77
|
+
this.bucketsMask = INITIAL_CAPACITY - 1;
|
|
78
|
+
this.entries = new ArrayBuffer(INITIAL_CAPACITY * <i32>ENTRY_SIZE<T>());
|
|
79
|
+
this.entriesCapacity = INITIAL_CAPACITY;
|
|
80
|
+
this.entriesOffset = 0;
|
|
81
|
+
this.entriesCount = 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private find(key: T, hashCode: u32): SetEntry<T> | null {
|
|
85
|
+
let entry = load<SetEntry<T>>( // unmanaged!
|
|
86
|
+
changetype<usize>(this.buckets) + <usize>(hashCode & this.bucketsMask) * BUCKET_SIZE
|
|
87
|
+
);
|
|
88
|
+
while (entry) {
|
|
89
|
+
let taggedNext = entry.taggedNext;
|
|
90
|
+
if (!(taggedNext & EMPTY) && entry.key == key) return entry;
|
|
91
|
+
entry = changetype<SetEntry<T>>(taggedNext & ~EMPTY);
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@operator("[]")
|
|
97
|
+
has(key: T): bool {
|
|
98
|
+
return this.find(key, HASH<T>(key)) != null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
add(key: T): this {
|
|
102
|
+
let hashCode = HASH<T>(key);
|
|
103
|
+
let entry = this.find(key, hashCode); // unmanaged!
|
|
104
|
+
if (!entry) {
|
|
105
|
+
// check if rehashing is necessary
|
|
106
|
+
if (this.entriesOffset == this.entriesCapacity) {
|
|
107
|
+
this.rehash(
|
|
108
|
+
this.entriesCount < this.entriesCapacity * FREE_FACTOR_N / FREE_FACTOR_D
|
|
109
|
+
? this.bucketsMask // just rehash if 1/4+ entries are empty
|
|
110
|
+
: (this.bucketsMask << 1) | 1 // grow capacity to next 2^N
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
// append new entry
|
|
114
|
+
entry = changetype<SetEntry<T>>(changetype<usize>(this.entries) + <usize>(this.entriesOffset++) * ENTRY_SIZE<T>());
|
|
115
|
+
entry.key = key;
|
|
116
|
+
if (isManaged<T>()) {
|
|
117
|
+
if (ASC_RUNTIME != Runtime.Memory) {
|
|
118
|
+
__link(changetype<usize>(this), changetype<usize>(key), true);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
++this.entriesCount;
|
|
122
|
+
// link with previous entry in bucket
|
|
123
|
+
let bucketPtrBase = changetype<usize>(this.buckets) + <usize>(hashCode & this.bucketsMask) * BUCKET_SIZE;
|
|
124
|
+
entry.taggedNext = load<usize>(bucketPtrBase);
|
|
125
|
+
store<usize>(bucketPtrBase, changetype<usize>(entry));
|
|
126
|
+
}
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@operator("[]=")
|
|
131
|
+
private __set(key: T, value: bool): void {
|
|
132
|
+
if (value) this.add(key);
|
|
133
|
+
else this.delete(key);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
delete(key: T): bool {
|
|
137
|
+
let entry = this.find(key, HASH<T>(key)); // unmanaged!
|
|
138
|
+
if (!entry) return false;
|
|
139
|
+
entry.taggedNext |= EMPTY;
|
|
140
|
+
--this.entriesCount;
|
|
141
|
+
// check if rehashing is appropriate
|
|
142
|
+
let halfBucketsMask = this.bucketsMask >> 1;
|
|
143
|
+
if (
|
|
144
|
+
halfBucketsMask + 1 >= max<u32>(INITIAL_CAPACITY, this.entriesCount) &&
|
|
145
|
+
this.entriesCount < this.entriesCapacity * FREE_FACTOR_N / FREE_FACTOR_D
|
|
146
|
+
) this.rehash(halfBucketsMask);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private rehash(newBucketsMask: u32): void {
|
|
151
|
+
let newBucketsCapacity = <i32>(newBucketsMask + 1);
|
|
152
|
+
let newBuckets = new ArrayBuffer(newBucketsCapacity * <i32>BUCKET_SIZE);
|
|
153
|
+
let newEntriesCapacity = newBucketsCapacity * FILL_FACTOR_N / FILL_FACTOR_D;
|
|
154
|
+
let newEntries = new ArrayBuffer(newEntriesCapacity * <i32>ENTRY_SIZE<T>());
|
|
155
|
+
|
|
156
|
+
// copy old entries to new entries
|
|
157
|
+
let oldPtr = changetype<usize>(this.entries);
|
|
158
|
+
let oldEnd = oldPtr + <usize>this.entriesOffset * ENTRY_SIZE<T>();
|
|
159
|
+
let newPtr = changetype<usize>(newEntries);
|
|
160
|
+
while (oldPtr != oldEnd) {
|
|
161
|
+
let oldEntry = changetype<SetEntry<T>>(oldPtr); // unmanaged!
|
|
162
|
+
if (!(oldEntry.taggedNext & EMPTY)) {
|
|
163
|
+
let newEntry = changetype<SetEntry<T>>(newPtr); // unmanaged!
|
|
164
|
+
let oldEntryKey = oldEntry.key;
|
|
165
|
+
newEntry.key = oldEntryKey;
|
|
166
|
+
let newBucketIndex = HASH<T>(oldEntryKey) & newBucketsMask;
|
|
167
|
+
let newBucketPtrBase = changetype<usize>(newBuckets) + <usize>newBucketIndex * BUCKET_SIZE;
|
|
168
|
+
newEntry.taggedNext = load<usize>(newBucketPtrBase);
|
|
169
|
+
store<usize>(newBucketPtrBase, newPtr);
|
|
170
|
+
newPtr += ENTRY_SIZE<T>();
|
|
171
|
+
}
|
|
172
|
+
oldPtr += ENTRY_SIZE<T>();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.buckets = newBuckets;
|
|
176
|
+
this.bucketsMask = newBucketsMask;
|
|
177
|
+
this.entries = newEntries;
|
|
178
|
+
this.entriesCapacity = newEntriesCapacity;
|
|
179
|
+
this.entriesOffset = this.entriesCount;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
values(): T[] {
|
|
183
|
+
// FIXME: this is preliminary, needs iterators/closures
|
|
184
|
+
let start = changetype<usize>(this.entries);
|
|
185
|
+
let size = this.entriesOffset;
|
|
186
|
+
let values = new Array<T>(size);
|
|
187
|
+
let length = 0;
|
|
188
|
+
for (let i = 0; i < size; ++i) {
|
|
189
|
+
let entry = changetype<SetEntry<T>>(start + <usize>i * ENTRY_SIZE<T>());
|
|
190
|
+
if (!(entry.taggedNext & EMPTY)) {
|
|
191
|
+
unchecked(values[length++] = entry.key);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
values.length = length;
|
|
195
|
+
return values;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
toString(): string {
|
|
199
|
+
return "[object Set]";
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// RT integration
|
|
203
|
+
|
|
204
|
+
@unsafe private __visit(cookie: u32): void {
|
|
205
|
+
if (ASC_RUNTIME != Runtime.Memory) {
|
|
206
|
+
__visit(changetype<usize>(this.buckets), cookie);
|
|
207
|
+
let entries = changetype<usize>(this.entries);
|
|
208
|
+
if (isManaged<T>()) {
|
|
209
|
+
let cur = entries;
|
|
210
|
+
let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<T>();
|
|
211
|
+
while (cur < end) {
|
|
212
|
+
let entry = changetype<SetEntry<T>>(cur);
|
|
213
|
+
if (!(entry.taggedNext & EMPTY)) {
|
|
214
|
+
let val = changetype<usize>(entry.key);
|
|
215
|
+
if (isNullable<T>()) {
|
|
216
|
+
if (val) __visit(val, cookie);
|
|
217
|
+
} else __visit(val, cookie);
|
|
218
|
+
}
|
|
219
|
+
cur += ENTRY_SIZE<T>();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
__visit(entries, cookie);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// This file is shared with the compiler and must remain portable
|
|
2
|
+
|
|
3
|
+
/** Indicates specific features to activate. */
|
|
4
|
+
export const enum Feature {
|
|
5
|
+
/** No additional features. */
|
|
6
|
+
None = 0,
|
|
7
|
+
/** Sign extension operations. */
|
|
8
|
+
SignExtension = 1 << 0, // see: https://github.com/WebAssembly/sign-extension-ops
|
|
9
|
+
/** Mutable global imports and exports. */
|
|
10
|
+
MutableGlobals = 1 << 1, // see: https://github.com/WebAssembly/mutable-global
|
|
11
|
+
/** Non-trapping float to integer operations. */
|
|
12
|
+
NontrappingF2I = 1 << 2, // see: https://github.com/WebAssembly/nontrapping-float-to-int-conversions
|
|
13
|
+
/** Bulk memory operations. */
|
|
14
|
+
BulkMemory = 1 << 3, // see: https://github.com/WebAssembly/bulk-memory-operations
|
|
15
|
+
/** SIMD types and operations. */
|
|
16
|
+
Simd = 1 << 4, // see: https://github.com/WebAssembly/simd
|
|
17
|
+
/** Threading and atomic operations. */
|
|
18
|
+
Threads = 1 << 5, // see: https://github.com/WebAssembly/threads
|
|
19
|
+
/** Exception handling operations. */
|
|
20
|
+
ExceptionHandling = 1 << 6, // see: https://github.com/WebAssembly/exception-handling
|
|
21
|
+
/** Tail call operations. */
|
|
22
|
+
TailCalls = 1 << 7, // see: https://github.com/WebAssembly/tail-call
|
|
23
|
+
/** Reference types. */
|
|
24
|
+
ReferenceTypes = 1 << 8, // see: https://github.com/WebAssembly/reference-types
|
|
25
|
+
/** Multi value types. */
|
|
26
|
+
MultiValue = 1 << 9, // see: https://github.com/WebAssembly/multi-value
|
|
27
|
+
/** Garbage collection. */
|
|
28
|
+
GC = 1 << 10, // see: https://github.com/WebAssembly/gc
|
|
29
|
+
/** Memory64. */
|
|
30
|
+
Memory64 = 1 << 11, // see: https://github.com/WebAssembly/memory64
|
|
31
|
+
/** Relaxed SIMD. */
|
|
32
|
+
RelaxedSimd = 1 << 12, // see: https://github.com/WebAssembly/relaxed-simd
|
|
33
|
+
/** Extended const expressions. */
|
|
34
|
+
ExtendedConst = 1 << 13, // see: https://github.com/WebAssembly/extended-const
|
|
35
|
+
/** Reference typed strings. */
|
|
36
|
+
Strings = 1 << 14, // see: https://github.com/WebAssembly/stringref
|
|
37
|
+
/** Shared-everything threads. */
|
|
38
|
+
SharedEverything = 1 << 15, // see: https://github.com/WebAssembly/shared-everything-threads
|
|
39
|
+
/** Closures. */
|
|
40
|
+
Closures = 1 << 16,
|
|
41
|
+
/** All features. */
|
|
42
|
+
All = (1 << 17) - 1
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Gets the name of the specified feature one would specify on the command line. */
|
|
46
|
+
export function featureToString(feature: Feature): string {
|
|
47
|
+
switch (feature) {
|
|
48
|
+
case Feature.SignExtension: return "sign-extension";
|
|
49
|
+
case Feature.MutableGlobals: return "mutable-globals";
|
|
50
|
+
case Feature.NontrappingF2I: return "nontrapping-f2i";
|
|
51
|
+
case Feature.BulkMemory: return "bulk-memory";
|
|
52
|
+
case Feature.Simd: return "simd";
|
|
53
|
+
case Feature.Threads: return "threads";
|
|
54
|
+
case Feature.ExceptionHandling: return "exception-handling";
|
|
55
|
+
case Feature.TailCalls: return "tail-calls";
|
|
56
|
+
case Feature.ReferenceTypes: return "reference-types";
|
|
57
|
+
case Feature.MultiValue: return "multi-value";
|
|
58
|
+
case Feature.GC: return "gc";
|
|
59
|
+
case Feature.Memory64: return "memory64";
|
|
60
|
+
case Feature.RelaxedSimd: return "relaxed-simd";
|
|
61
|
+
case Feature.ExtendedConst: return "extended-const";
|
|
62
|
+
case Feature.Strings: return "stringref";
|
|
63
|
+
case Feature.SharedEverything: return "shared-everything";
|
|
64
|
+
case Feature.Closures: return "closures";
|
|
65
|
+
}
|
|
66
|
+
assert(false);
|
|
67
|
+
return "";
|
|
68
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This file is shared with the compiler and must remain portable
|
|
2
|
+
|
|
3
|
+
/** Runtime types. */
|
|
4
|
+
export enum Runtime {
|
|
5
|
+
/** Simple bump allocator without GC. */
|
|
6
|
+
Stub = 0,
|
|
7
|
+
/** Stop the world semi-automatic GC. */
|
|
8
|
+
Minimal = 1,
|
|
9
|
+
/** incremental GC. */
|
|
10
|
+
Incremental = 2,
|
|
11
|
+
/** Bare minimum allocator, no GC. */
|
|
12
|
+
Memory = 3,
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is shared with the compiler and must remain portable
|
|
2
|
+
|
|
3
|
+
/** Compilation target. */
|
|
4
|
+
export enum Target {
|
|
5
|
+
/** Portable. */
|
|
6
|
+
Js = 0,
|
|
7
|
+
/** WebAssembly with 32-bit pointers. */
|
|
8
|
+
Wasm32 = 1,
|
|
9
|
+
/** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */
|
|
10
|
+
Wasm64 = 2,
|
|
11
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// This file is shared with the compiler and must remain portable
|
|
2
|
+
|
|
3
|
+
// ╒═══════════════════ Typeinfo interpretation ═══════════════════╕
|
|
4
|
+
// 3 2 1
|
|
5
|
+
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits
|
|
6
|
+
// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ◄─ __rtti_base
|
|
7
|
+
// │ count │
|
|
8
|
+
// ╞═══════════════════════════════════════════════════════════════╡ ┐
|
|
9
|
+
// │ Typeinfo#flags [id=0] │ id < count
|
|
10
|
+
// ├───────────────────────────────────────────────────────────────┤
|
|
11
|
+
// │ ... │
|
|
12
|
+
|
|
13
|
+
/** Runtime type information data structure. */
|
|
14
|
+
@unmanaged
|
|
15
|
+
export class Typeinfo {
|
|
16
|
+
/** Flags describing the shape of this class type. */
|
|
17
|
+
flags: TypeinfoFlags = TypeinfoFlags.NONE;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Runtime type information flags. */
|
|
21
|
+
export const enum TypeinfoFlags {
|
|
22
|
+
/** No specific flags. */
|
|
23
|
+
NONE = 0,
|
|
24
|
+
/** Type is an `ArrayBufferView`. */
|
|
25
|
+
ARRAYBUFFERVIEW = 1 << 0,
|
|
26
|
+
/** Type is an `Array`. */
|
|
27
|
+
ARRAY = 1 << 1,
|
|
28
|
+
/** Type is a `StaticArray`. */
|
|
29
|
+
STATICARRAY = 1 << 2,
|
|
30
|
+
/** Type is a `Set`. */
|
|
31
|
+
SET = 1 << 3,
|
|
32
|
+
/** Type is a `Map`. */
|
|
33
|
+
MAP = 1 << 4,
|
|
34
|
+
/** Type has no outgoing pointers. */
|
|
35
|
+
POINTERFREE = 1 << 5,
|
|
36
|
+
/** Value alignment of 1 byte. */
|
|
37
|
+
VALUE_ALIGN_0 = 1 << 6,
|
|
38
|
+
/** Value alignment of 2 bytes. */
|
|
39
|
+
VALUE_ALIGN_1 = 1 << 7,
|
|
40
|
+
/** Value alignment of 4 bytes. */
|
|
41
|
+
VALUE_ALIGN_2 = 1 << 8,
|
|
42
|
+
/** Value alignment of 8 bytes. */
|
|
43
|
+
VALUE_ALIGN_3 = 1 << 9,
|
|
44
|
+
/** Value alignment of 16 bytes. */
|
|
45
|
+
VALUE_ALIGN_4 = 1 << 10,
|
|
46
|
+
/** Value is a signed type. */
|
|
47
|
+
VALUE_SIGNED = 1 << 11,
|
|
48
|
+
/** Value is a float type. */
|
|
49
|
+
VALUE_FLOAT = 1 << 12,
|
|
50
|
+
/** Value type is nullable. */
|
|
51
|
+
VALUE_NULLABLE = 1 << 13,
|
|
52
|
+
/** Value type is managed. */
|
|
53
|
+
VALUE_MANAGED = 1 << 14,
|
|
54
|
+
/** Key alignment of 1 byte. */
|
|
55
|
+
KEY_ALIGN_0 = 1 << 15,
|
|
56
|
+
/** Key alignment of 2 bytes. */
|
|
57
|
+
KEY_ALIGN_1 = 1 << 16,
|
|
58
|
+
/** Key alignment of 4 bytes. */
|
|
59
|
+
KEY_ALIGN_2 = 1 << 17,
|
|
60
|
+
/** Key alignment of 8 bytes. */
|
|
61
|
+
KEY_ALIGN_3 = 1 << 18,
|
|
62
|
+
/** Key alignment of 16 bytes. */
|
|
63
|
+
KEY_ALIGN_4 = 1 << 19,
|
|
64
|
+
/** Key is a signed type. */
|
|
65
|
+
KEY_SIGNED = 1 << 20,
|
|
66
|
+
/** Key is a float type. */
|
|
67
|
+
KEY_FLOAT = 1 << 21,
|
|
68
|
+
/** Key type is nullable. */
|
|
69
|
+
KEY_NULLABLE = 1 << 22,
|
|
70
|
+
/** Key type is managed. */
|
|
71
|
+
KEY_MANAGED = 1 << 23
|
|
72
|
+
}
|