mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-03 08:31:53 +00:00
more
This commit is contained in:
@ -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>`. */
|
||||
|
Reference in New Issue
Block a user