This commit is contained in:
dcode
2019-03-16 11:24:13 +01:00
parent b8a08da7a5
commit 05a35f42f6
18 changed files with 15370 additions and 16933 deletions

View File

@ -2837,6 +2837,13 @@ export class ClassPrototype extends DeclaredElement {
return (<ClassDeclaration>this.declaration).implementsTypes;
}
/** Tests if this prototype is of a builtin array type (Array/TypedArray). */
get isBuiltinArray(): bool {
var arrayBufferViewInstance = this.program.arrayBufferViewInstance;
return arrayBufferViewInstance !== null
&& this.extends(arrayBufferViewInstance.prototype);
}
/** Tests if this prototype extends the specified. */
extends(basePtototype: ClassPrototype | null): bool {
var current: ClassPrototype | null = this;
@ -2919,6 +2926,27 @@ export class Class extends TypedElement {
return id;
}
/** Tests if this class is of a builtin array type (Array/TypedArray). */
get isBuiltinArray(): bool {
return this.prototype.isBuiltinArray;
}
/** Tests if this class is array-like. */
get isArrayLike(): bool {
if (this.isBuiltinArray) return true;
var lengthField = this.lookupInSelf("length");
return lengthField !== null && (
lengthField.kind == ElementKind.FIELD ||
(
lengthField.kind == ElementKind.PROPERTY &&
(<Property>lengthField).getterInstance !== null // TODO: resolve & check type?
)
) && (
this.lookupOverload(OperatorKind.INDEXED_GET) !== null ||
this.lookupOverload(OperatorKind.UNCHECKED_INDEXED_GET) !== null
);
}
/** Constructs a new class. */
constructor(
/** Name incl. type parameters, i.e. `Foo<i32>`. */