mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-03 08:31:53 +00:00
Implement optional type parameters (#360)
* Add a NATIVE<T> macro type to simplify use of a native WebAssembly type * Add default type parameters for internal helpers for explicit loads and stores * Unify loadUnsafe/loadUnsafeWithOffset etc. into one * Renamed loadUnsafe etc. into just LOAD, like a macro * Implement parsing of index signatures, but ignore them, for properly linting code * Refactor TypedArray<T> to use macros
This commit is contained in:
@ -965,6 +965,7 @@ export class Program extends DiagnosticEmitter {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NodeKind.INDEXSIGNATUREDECLARATION: break; // ignored for now
|
||||
default: {
|
||||
assert(false); // should have been reported while parsing
|
||||
return;
|
||||
@ -2413,6 +2414,21 @@ export class FunctionPrototype extends Element {
|
||||
this.decoratorFlags = decoratorFlags;
|
||||
}
|
||||
|
||||
/** Applies class type arguments to the context of a partially resolved instance method. */
|
||||
applyClassTypeArguments(contextualTypeArguments: Map<string,Type>): void {
|
||||
var classTypeArguments = assert(this.classTypeArguments); // set only if partial
|
||||
var classDeclaration = assert(this.classPrototype).declaration;
|
||||
var classTypeParameters = classDeclaration.typeParameters;
|
||||
var numClassTypeParameters = classTypeParameters.length;
|
||||
assert(numClassTypeParameters == classTypeArguments.length);
|
||||
for (let i = 0; i < numClassTypeParameters; ++i) {
|
||||
contextualTypeArguments.set(
|
||||
classTypeParameters[i].name.text,
|
||||
classTypeArguments[i]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
toString(): string { return this.simpleName; }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user