Skip to content

Commit f1bf214

Browse files
committed
some changes to fix asc errors
1 parent 70fa222 commit f1bf214

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/compiler.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6043,7 +6043,7 @@ export class Compiler extends DiagnosticEmitter {
60436043
switch (target.kind) {
60446044
case ElementKind.LOCAL: {
60456045
let local = <Local>target;
6046-
if (local.closureContextOffset) {
6046+
if (local.closureContextOffset >= 0) {
60476047
// TODO: ability to update closed over locals
60486048
this.error(
60496049
DiagnosticCode.Not_implemented,
@@ -6444,7 +6444,7 @@ export class Compiler extends DiagnosticEmitter {
64446444
module.local_get(closureContextLocal.index, this.options.nativeSizeType),
64456445
module.local_get(local.index, nativeType),
64466446
nativeType,
6447-
assert(local.closureContextOffset)
6447+
assert(local.closureContextOffset >= 0)
64486448
);
64496449
}
64506450
return module.block(null, exprs);
@@ -6687,6 +6687,7 @@ export class Compiler extends DiagnosticEmitter {
66876687
// Once we get here, we have a function reference. With the new scheme, this function
66886688
// could possibly be a closure. So here we check to see if it's a closure, then apply
66896689
// the appropriate call logic
6690+
signature = assert(signature) // FIXME: asc can't see this yet
66906691
var returnType = signature.returnType;
66916692
var tempFunctionReferenceLocal = this.currentFlow.getTempLocal(this.options.usizeType);
66926693
var usize = this.options.nativeSizeType;
@@ -6695,7 +6696,7 @@ export class Compiler extends DiagnosticEmitter {
66956696
this.ifClosure(
66966697
module.local_get(tempFunctionReferenceLocal.index, usize),
66976698
this.compileCallIndirect( // If this is a closure
6698-
assert(signature).toClosureSignature(), // FIXME: asc can't see this yet
6699+
signature.toClosureSignature(),
66996700
module.block(null, [
67006701
module.load(
67016702
4,
@@ -6715,7 +6716,7 @@ export class Compiler extends DiagnosticEmitter {
67156716
contextualType == Type.void
67166717
),
67176718
this.compileCallIndirect( // If this function isn't a closure
6718-
assert(signature), // FIXME: asc can't see this yet
6719+
signature,
67196720
module.local_get(tempFunctionReferenceLocal.index, usize),
67206721
expression.args,
67216722
expression,
@@ -8448,7 +8449,7 @@ export class Compiler extends DiagnosticEmitter {
84488449
let localType = local.type;
84498450
assert(localType != Type.void);
84508451
var localClosureContextOffset = local.closureContextOffset;
8451-
if (localClosureContextOffset !== null) {
8452+
if (localClosureContextOffset >= 0) {
84528453
let contextLocal = assert(flow.lookupLocal(CommonNames.this_));
84538454

84548455
// TODO: replace this with a class field access, once we are able to construct the class before

src/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,7 +3277,7 @@ export class Local extends VariableLikeElement {
32773277
/** Declaration reference. */
32783278
declaration: VariableLikeDeclarationStatement = parent.program.makeNativeVariableDeclaration(name),
32793279
/** Offset of this variable within closure context, if it's value is held there */
3280-
public closureContextOffset: usize | null = null,
3280+
public closureContextOffset: usize = -1,
32813281
) {
32823282
super(
32833283
ElementKind.LOCAL,
@@ -3495,7 +3495,7 @@ export class Function extends TypedElement {
34953495
let local = new Local(
34963496
CommonNames.this_,
34973497
localIndex++,
3498-
signature.thisType,
3498+
signature.thisType!, // asc can't see the !== null above
34993499
this
35003500
);
35013501
this.localsByName.set(CommonNames.this_, local);

0 commit comments

Comments
 (0)