mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-07 10:31:57 +00:00
implement __runtime_flags
This commit is contained in:
@ -316,6 +316,45 @@ export enum CollectorKind {
|
||||
COUNTING
|
||||
}
|
||||
|
||||
/** Runtime flags. */
|
||||
export const enum RuntimeFlags { // keep in sync with std/runtime.ts
|
||||
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
|
||||
}
|
||||
|
||||
/** Represents an AssemblyScript program. */
|
||||
export class Program extends DiagnosticEmitter {
|
||||
|
||||
@ -357,6 +396,10 @@ export class Program extends DiagnosticEmitter {
|
||||
arrayBufferInstance: Class | null = null;
|
||||
/** Array prototype reference. */
|
||||
arrayPrototype: ClassPrototype | null = null;
|
||||
/** Set prototype reference. */
|
||||
setPrototype: ClassPrototype | null = null;
|
||||
/** Map prototype reference. */
|
||||
mapPrototype: ClassPrototype | null = null;
|
||||
/** Fixed array prototype reference. */
|
||||
fixedArrayPrototype: ClassPrototype | null = null;
|
||||
/** String instance reference. */
|
||||
@ -820,6 +863,14 @@ export class Program extends DiagnosticEmitter {
|
||||
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
|
||||
this.fixedArrayPrototype = <ClassPrototype>element;
|
||||
}
|
||||
if (element = this.lookupGlobal(CommonSymbols.Set)) {
|
||||
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
|
||||
this.setPrototype = <ClassPrototype>element;
|
||||
}
|
||||
if (element = this.lookupGlobal(CommonSymbols.Map)) {
|
||||
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
|
||||
this.mapPrototype = <ClassPrototype>element;
|
||||
}
|
||||
if (element = this.lookupGlobal(CommonSymbols.abort)) {
|
||||
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
|
||||
this.abortInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
|
||||
|
Reference in New Issue
Block a user