mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-04 00:51:51 +00:00
Add a way to ensure that lazy globals are resolved, fixes #355
This only affects static fields that currently must have a type annotation, while it wouldn't work if there wasn't an annotated type, like on normal globals, which aren't compiled lazily, though. Must be revisted if requirements on type annotations on fields ever become relaxed.
This commit is contained in:
@ -16,7 +16,8 @@ import {
|
||||
|
||||
import {
|
||||
Options,
|
||||
Feature
|
||||
Feature,
|
||||
Compiler
|
||||
} from "./compiler";
|
||||
|
||||
import {
|
||||
@ -730,19 +731,19 @@ export class Program extends DiagnosticEmitter {
|
||||
/** Sets a constant integer value. */
|
||||
setConstantInteger(globalName: string, type: Type, value: I64): void {
|
||||
assert(type.is(TypeFlags.INTEGER));
|
||||
this.elementsLookup.set(globalName,
|
||||
new Global(this, globalName, globalName, type, null, DecoratorFlags.NONE)
|
||||
.withConstantIntegerValue(value)
|
||||
);
|
||||
var global = new Global(this, globalName, globalName, type, null, DecoratorFlags.NONE)
|
||||
.withConstantIntegerValue(value);
|
||||
global.set(CommonFlags.RESOLVED);
|
||||
this.elementsLookup.set(globalName, global);
|
||||
}
|
||||
|
||||
/** Sets a constant float value. */
|
||||
setConstantFloat(globalName: string, type: Type, value: f64): void {
|
||||
assert(type.is(TypeFlags.FLOAT));
|
||||
this.elementsLookup.set(globalName,
|
||||
new Global(this, globalName, globalName, type, null, DecoratorFlags.NONE)
|
||||
.withConstantFloatValue(value)
|
||||
);
|
||||
var global = new Global(this, globalName, globalName, type, null, DecoratorFlags.NONE)
|
||||
.withConstantFloatValue(value);
|
||||
global.set(CommonFlags.RESOLVED);
|
||||
this.elementsLookup.set(globalName, global);
|
||||
}
|
||||
|
||||
/** Tries to locate an import by traversing exports and queued exports. */
|
||||
|
Reference in New Issue
Block a user