mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 17:01:37 +00:00
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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user