Skip to content

Commit

Permalink
fix: Move compilation of instanceof helpers post override discovery (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrCai0907 committed Mar 3, 2023
1 parent b745216 commit 9497c3d
Show file tree
Hide file tree
Showing 4 changed files with 722 additions and 520 deletions.
38 changes: 19 additions & 19 deletions src/compiler.ts
Expand Up @@ -559,25 +559,6 @@ export class Compiler extends DiagnosticEmitter {
}
} while (lazyFunctions.size);

// compile pending instanceof helpers
for (let _keys = Map_keys(this.pendingInstanceOf), i = 0, k = _keys.length; i < k; ++i) {
let elem = _keys[i];
let name = assert(this.pendingInstanceOf.get(elem));
switch (elem.kind) {
case ElementKind.Class:
case ElementKind.Interface: {
this.finalizeInstanceOf(<Class>elem, name);
break;
}
case ElementKind.ClassPrototype:
case ElementKind.InterfacePrototype: {
this.finalizeAnyInstanceOf(<ClassPrototype>elem, name);
break;
}
default: assert(false);
}
}

// set up override stubs
let functionTable = this.functionTable;
let overrideStubs = this.overrideStubs;
Expand Down Expand Up @@ -611,6 +592,25 @@ export class Compiler extends DiagnosticEmitter {
this.finalizeOverrideStub(_values[i]);
}

// compile pending instanceof helpers
for (let _keys = Map_keys(this.pendingInstanceOf), i = 0, k = _keys.length; i < k; ++i) {
let elem = _keys[i];
let name = assert(this.pendingInstanceOf.get(elem));
switch (elem.kind) {
case ElementKind.Class:
case ElementKind.Interface: {
this.finalizeInstanceOf(<Class>elem, name);
break;
}
case ElementKind.ClassPrototype:
case ElementKind.InterfacePrototype: {
this.finalizeAnyInstanceOf(<ClassPrototype>elem, name);
break;
}
default: assert(false);
}
}

// finalize runtime features
module.removeGlobal(BuiltinNames.rtti_base);
if (this.runtimeFeatures & RuntimeFeatures.Rtti) compileRTTI(this);
Expand Down

0 comments on commit 9497c3d

Please sign in to comment.