mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-23 19:51:47 +00:00
rtti & refactoring
This commit is contained in:
1
std/assembly/common/README.md
Normal file
1
std/assembly/common/README.md
Normal file
@ -0,0 +1 @@
|
||||
These source files are used by both the standard library *and* compiler. Must remain portable.
|
9
std/assembly/common/capability.ts
Normal file
9
std/assembly/common/capability.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/** Indicates module capabilities. */
|
||||
export const enum Capability {
|
||||
/** No specific capabilities. */
|
||||
NONE = 0,
|
||||
/** Uses WebAssembly with 64-bit pointers. */
|
||||
WASM64 = 1 << 0,
|
||||
/** Garbage collector is present (full runtime header). */
|
||||
GC = 1 << 1
|
||||
}
|
15
std/assembly/common/feature.ts
Normal file
15
std/assembly/common/feature.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/** Indicates specific features to activate. */
|
||||
export const enum Feature {
|
||||
/** No additional features. */
|
||||
NONE = 0,
|
||||
/** Sign extension operations. */
|
||||
SIGN_EXTENSION = 1 << 0, // see: https://github.com/WebAssembly/sign-extension-ops
|
||||
/** Mutable global imports and exports. */
|
||||
MUTABLE_GLOBAL = 1 << 1, // see: https://github.com/WebAssembly/mutable-global
|
||||
/** Bulk memory operations. */
|
||||
BULK_MEMORY = 1 << 2, // see: https://github.com/WebAssembly/bulk-memory-operations
|
||||
/** SIMD types and operations. */
|
||||
SIMD = 1 << 3, // see: https://github.com/WebAssembly/simd
|
||||
/** Threading and atomic operations. */
|
||||
THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads
|
||||
}
|
60
std/assembly/common/rtti.ts
Normal file
60
std/assembly/common/rtti.ts
Normal file
@ -0,0 +1,60 @@
|
||||
// ╒═════════════════════ RTTI interpretation ═════════════════════╕
|
||||
// 3 2 1
|
||||
// 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
|
||||
// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ◄─ RTTI_BASE
|
||||
// │ count │
|
||||
// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤
|
||||
// │ reserved │
|
||||
// ╞═══════════════════════════════════════════════════════════════╡ ┐
|
||||
// │ RTTIData#flags [id=1] │ id=1..count
|
||||
// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤
|
||||
// │ RTTIData#base [id=1] │
|
||||
// ├───────────────────────────────────────────────────────────────┤
|
||||
// │ ... │
|
||||
|
||||
/** Runtime type information data structure. */
|
||||
@unmanaged
|
||||
export class RTTIData {
|
||||
flags: RTTIFlags;
|
||||
base: u32;
|
||||
}
|
||||
|
||||
/** Runtime type information flags. */
|
||||
export const enum RTTIFlags {
|
||||
/** No specific flags. */
|
||||
NONE = 0,
|
||||
/** Type is an `Array`. */
|
||||
ARRAY = 1 << 0,
|
||||
/** Type is a `Set`. */
|
||||
SET = 1 << 1,
|
||||
/** Type is a `Map`. */
|
||||
MAP = 1 << 2,
|
||||
/** Value alignment of 1 byte. */
|
||||
VALUE_ALIGN_0 = 1 << 3,
|
||||
/** Value alignment of 2 bytes. */
|
||||
VALUE_ALIGN_1 = 1 << 4,
|
||||
/** Value alignment of 4 bytes. */
|
||||
VALUE_ALIGN_2 = 1 << 5,
|
||||
/** Value alignment of 8 bytes. */
|
||||
VALUE_ALIGN_3 = 1 << 6,
|
||||
/** Value alignment of 16 bytes. */
|
||||
VALUE_ALIGN_4 = 1 << 7,
|
||||
/** Value type is nullable. */
|
||||
VALUE_NULLABLE = 1 << 8,
|
||||
/** Value type is managed. */
|
||||
VALUE_MANAGED = 1 << 9,
|
||||
/** Key alignment of 1 byte. */
|
||||
KEY_ALIGN_0 = 1 << 10,
|
||||
/** Key alignment of 2 bytes. */
|
||||
KEY_ALIGN_1 = 1 << 11,
|
||||
/** Key alignment of 4 bytes. */
|
||||
KEY_ALIGN_2 = 1 << 12,
|
||||
/** Key alignment of 8 bytes. */
|
||||
KEY_ALIGN_3 = 1 << 13,
|
||||
/** Key alignment of 16 bytes. */
|
||||
KEY_ALIGN_4 = 1 << 14,
|
||||
/** Key type is nullable. */
|
||||
KEY_NULLABLE = 1 << 15,
|
||||
/** Key type is managed. */
|
||||
KEY_MANAGED = 1 << 16
|
||||
}
|
9
std/assembly/common/target.ts
Normal file
9
std/assembly/common/target.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/** Compilation target. */
|
||||
export enum Target {
|
||||
/** WebAssembly with 32-bit pointers. */
|
||||
WASM32,
|
||||
/** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */
|
||||
WASM64,
|
||||
/** Portable. */
|
||||
JS
|
||||
}
|
Reference in New Issue
Block a user