wire __runtime_instanceof to 'instanceof' on upcasts

also adds runtime.instanceOf that can be exported for use by the host
This commit is contained in:
dcode
2019-04-02 23:58:58 +02:00
parent b62927f5e5
commit b58683aff4
12 changed files with 2569 additions and 141 deletions

View File

@ -128,4 +128,15 @@ export namespace runtime {
if (source) memory.copy(buffer, source, bufferSize);
return array;
}
// @ts-ignore: decorator
@unsafe
export function instanceOf(ref: usize, id: u32): bool {
return ref
? __runtime_instanceof(
changetype<HEADER>(ref - HEADER_SIZE).classId,
id
)
: false;
}
}