import { __runtime_id, __runtime_flags } from "runtime"; const enum RuntimeFlags { // keep in sync with src/program.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 } function test(flags: RuntimeFlags): void { assert( __runtime_flags(__runtime_id()) == flags ); } class Ref {} const VALUE_ALIGN_REF = sizeof() == 4 ? RuntimeFlags.VALUE_ALIGN_2 : RuntimeFlags.VALUE_ALIGN_3; const KEY_ALIGN_REF = sizeof() == 4 ? RuntimeFlags.KEY_ALIGN_2 : RuntimeFlags.KEY_ALIGN_3; test>(RuntimeFlags.ARRAY | RuntimeFlags.VALUE_ALIGN_0); test>(RuntimeFlags.ARRAY | RuntimeFlags.VALUE_ALIGN_1); test>(RuntimeFlags.ARRAY | RuntimeFlags.VALUE_ALIGN_2); test>(RuntimeFlags.ARRAY | RuntimeFlags.VALUE_ALIGN_3); test>(RuntimeFlags.ARRAY | RuntimeFlags.VALUE_ALIGN_4); test>(RuntimeFlags.ARRAY | VALUE_ALIGN_REF | RuntimeFlags.VALUE_MANAGED); test>(RuntimeFlags.ARRAY | VALUE_ALIGN_REF | RuntimeFlags.VALUE_NULLABLE | RuntimeFlags.VALUE_MANAGED); test>(RuntimeFlags.SET | RuntimeFlags.VALUE_ALIGN_0); test>(RuntimeFlags.SET | RuntimeFlags.VALUE_ALIGN_1); test>(RuntimeFlags.SET | RuntimeFlags.VALUE_ALIGN_2); test>(RuntimeFlags.SET | RuntimeFlags.VALUE_ALIGN_3); test>(RuntimeFlags.SET | RuntimeFlags.VALUE_ALIGN_4); test>(RuntimeFlags.SET | VALUE_ALIGN_REF | RuntimeFlags.VALUE_MANAGED); test>(RuntimeFlags.SET | VALUE_ALIGN_REF | RuntimeFlags.VALUE_NULLABLE | RuntimeFlags.VALUE_MANAGED); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_4 | RuntimeFlags.VALUE_ALIGN_0); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_3 | RuntimeFlags.VALUE_ALIGN_1); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_2 | RuntimeFlags.VALUE_ALIGN_2); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_1 | RuntimeFlags.VALUE_ALIGN_3); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_0 | RuntimeFlags.VALUE_ALIGN_4); test>(RuntimeFlags.MAP | KEY_ALIGN_REF | RuntimeFlags.KEY_MANAGED | RuntimeFlags.VALUE_ALIGN_0); test>(RuntimeFlags.MAP |KEY_ALIGN_REF | RuntimeFlags.KEY_NULLABLE | RuntimeFlags.KEY_MANAGED | RuntimeFlags.VALUE_ALIGN_0); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_0 | RuntimeFlags.VALUE_MANAGED | VALUE_ALIGN_REF); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_ALIGN_0 | RuntimeFlags.VALUE_NULLABLE | RuntimeFlags.VALUE_MANAGED | VALUE_ALIGN_REF); test>(RuntimeFlags.MAP | RuntimeFlags.KEY_NULLABLE | RuntimeFlags.KEY_MANAGED | KEY_ALIGN_REF | RuntimeFlags.VALUE_NULLABLE | RuntimeFlags.VALUE_MANAGED | VALUE_ALIGN_REF); // TODO: WASM64