diff --git a/ts2panda/src/compilerDriver.ts b/ts2panda/src/compilerDriver.ts index 16c0921f81545a0e80a3a9878438e1defa8a43b6..ca2e9f1f622909742de8f667ce63683fb90698c8 100644 --- a/ts2panda/src/compilerDriver.ts +++ b/ts2panda/src/compilerDriver.ts @@ -48,7 +48,10 @@ import { Ts2Panda } from "./ts2panda"; import { TypeRecorder } from "./typeRecorder"; import { LiteralBuffer } from "./base/literal"; import { findOuterNodeOfParenthesis } from "./expression/parenthesizedExpression"; -import { IRNode } from "./irnodes"; +import { + Label, + IRNode +} from "./irnodes"; import { LexicalBinder } from "./lexicalBinder"; export class PendingCompilationUnit { @@ -177,6 +180,7 @@ export class CompilerDriver { } }); } + Label.resetGlobalId(); let recorder = this.compilePrologue(node, true, false); let lexBinder = new LexicalBinder(node, recorder); diff --git a/ts2panda/templates/irnodes.ts.erb b/ts2panda/templates/irnodes.ts.erb index 54edae0d337c5bc57fc559b56e5ac19fec75cef7..a083d8b5a37114070095ef6ae3969363216c3c6c 100755 --- a/ts2panda/templates/irnodes.ts.erb +++ b/ts2panda/templates/irnodes.ts.erb @@ -339,7 +339,7 @@ export class VReg { private typeIndex: number | undefined; private variableName: string | undefined; num: number = -1; - + toString(): string { return "V" + this.num; } @@ -386,6 +386,10 @@ export class Label extends IRNode { this.id = Label.global_id++; } + static resetGlobalId() { + Label.global_id = 0; + } + toString(): string { return "LABEL_" + this.id; } diff --git a/ts2panda/ts2abc/ts2abc.cpp b/ts2panda/ts2abc/ts2abc.cpp index 9d06625f7837da7940411e2a26cbd57ae0986be0..1ea1ece3c9f22492abb8c0b724b1cf87d241f69d 100644 --- a/ts2panda/ts2abc/ts2abc.cpp +++ b/ts2panda/ts2abc/ts2abc.cpp @@ -1499,6 +1499,7 @@ static bool EmitAndRestoreProgram(panda::pandasm::Program &prog, panda::ts2abc:: } prog = panda::pandasm::Program(); prog.lang = panda::pandasm::extensions::Language::ECMASCRIPT; + g_newLiteralArrayIndex = -1; return true; }