mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-19 18:01:31 +00:00
Add ArrayBuffer.isView and rework Array.isArray (#431)
This commit is contained in:
@ -113,7 +113,6 @@ export function compileCall(
|
||||
let type = evaluateConstantType(compiler, typeArguments, operands, reportNode);
|
||||
compiler.currentType = Type.bool;
|
||||
if (!type) return module.createUnreachable();
|
||||
compiler.currentType = Type.bool;
|
||||
return type.is(TypeFlags.REFERENCE)
|
||||
? module.createI32(1)
|
||||
: module.createI32(0);
|
||||
@ -134,9 +133,9 @@ export function compileCall(
|
||||
compiler.currentType = Type.bool;
|
||||
if (!type) return module.createUnreachable();
|
||||
let classType = type.classReference;
|
||||
return classType !== null && classType.lookupOverload(OperatorKind.INDEXED_GET) !== null
|
||||
? module.createI32(1)
|
||||
: module.createI32(0);
|
||||
return (
|
||||
classType !== null && classType.prototype.extends(compiler.program.arrayPrototype)
|
||||
) ? module.createI32(1) : module.createI32(0);
|
||||
}
|
||||
case "isDefined": { // isDefined(expression) -> bool
|
||||
compiler.currentType = Type.bool;
|
||||
|
@ -2856,6 +2856,14 @@ export class ClassPrototype extends Element {
|
||||
this.decoratorFlags = decoratorFlags;
|
||||
}
|
||||
|
||||
extends(basePtototype: ClassPrototype | null): bool {
|
||||
var current: ClassPrototype | null = this;
|
||||
do {
|
||||
if (current === basePtototype) return true;
|
||||
} while (current = current.basePrototype);
|
||||
return false;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return this.simpleName;
|
||||
}
|
||||
@ -2969,6 +2977,16 @@ export class Class extends Element {
|
||||
return null;
|
||||
}
|
||||
|
||||
lookupField(name: string, shouldReadonly: boolean = false): Element | null {
|
||||
if (this.members == null) return null;
|
||||
var member = this.members.get(name);
|
||||
if (
|
||||
member == null || member.kind != ElementKind.FIELD ||
|
||||
(shouldReadonly && !member.is(CommonFlags.READONLY))
|
||||
) return null;
|
||||
return member;
|
||||
}
|
||||
|
||||
offsetof(fieldName: string): u32 {
|
||||
var members = assert(this.members);
|
||||
assert(members.has(fieldName));
|
||||
|
Reference in New Issue
Block a user