mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 08:51:34 +00:00
make it 'runtime.instanceof'
This commit is contained in:
@ -15,6 +15,22 @@ export declare function __runtime_id<T>(): u32;
|
||||
@unsafe @builtin
|
||||
export declare function __runtime_instanceof(id: u32, superId: u32): bool;
|
||||
|
||||
/** Runtime implementation. */
|
||||
@unmanaged
|
||||
export class runtime {
|
||||
private constructor() { return unreachable(); }
|
||||
|
||||
@unsafe
|
||||
static instanceof(ref: usize, id: u32): bool { // keyword
|
||||
return ref
|
||||
? __runtime_instanceof(
|
||||
changetype<HEADER>(ref - HEADER_SIZE).classId,
|
||||
id
|
||||
)
|
||||
: false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Runtime implementation. */
|
||||
export namespace runtime {
|
||||
|
||||
@ -128,15 +144,4 @@ 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