mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-24 12:11:50 +00:00
FixedArray experimentation
This commit is contained in:
@ -175,6 +175,7 @@ export namespace LibrarySymbols {
|
||||
export const V128 = "V128";
|
||||
export const String = "String";
|
||||
export const Array = "Array";
|
||||
export const FixedArray = "FixedArray";
|
||||
export const ArrayBufferView = "ArrayBufferView";
|
||||
export const ArrayBuffer = "ArrayBuffer";
|
||||
export const Math = "Math";
|
||||
|
@ -6445,17 +6445,16 @@ export class Compiler extends DiagnosticEmitter {
|
||||
case LiteralKind.ARRAY: {
|
||||
assert(!implicitNegate);
|
||||
let classType = contextualType.classReference;
|
||||
if (
|
||||
classType &&
|
||||
classType.prototype == this.program.arrayPrototype
|
||||
) {
|
||||
return this.compileArrayLiteral(
|
||||
assert(classType.typeArguments)[0],
|
||||
(<ArrayLiteralExpression>expression).elementExpressions,
|
||||
false, // TODO: isConst?
|
||||
expression,
|
||||
context
|
||||
);
|
||||
if (classType) {
|
||||
if (classType.prototype == this.program.arrayPrototype) {
|
||||
return this.compileArrayLiteral(
|
||||
assert(classType.typeArguments)[0],
|
||||
(<ArrayLiteralExpression>expression).elementExpressions,
|
||||
false, // TODO: isConst?
|
||||
expression,
|
||||
context
|
||||
);
|
||||
}
|
||||
}
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
|
@ -348,6 +348,8 @@ export class Program extends DiagnosticEmitter {
|
||||
arrayBufferInstance: Class | null = null;
|
||||
/** Array prototype reference. */
|
||||
arrayPrototype: ClassPrototype | null = null;
|
||||
/** Fixed array prototype reference. */
|
||||
fixedArrayPrototype: ClassPrototype | null = null;
|
||||
/** String instance reference. */
|
||||
stringInstance: Class | null = null;
|
||||
/** Abort function reference, if present. */
|
||||
@ -798,6 +800,10 @@ export class Program extends DiagnosticEmitter {
|
||||
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
|
||||
this.arrayPrototype = <ClassPrototype>element;
|
||||
}
|
||||
if (element = this.lookupGlobal(LibrarySymbols.FixedArray)) {
|
||||
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
|
||||
this.fixedArrayPrototype = <ClassPrototype>element;
|
||||
}
|
||||
if (element = this.lookupGlobal(LibrarySymbols.abort)) {
|
||||
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
|
||||
this.abortInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
|
||||
|
Reference in New Issue
Block a user