From 49d93cd0b9f0d0ae276aa1479fa96bf130c8bf47 Mon Sep 17 00:00:00 2001 From: gavin1012_hw Date: Mon, 30 Jan 2023 14:43:14 +0800 Subject: [PATCH] fixed 7892a87 from https://gitee.com/gavin1012_hw/ark_ts2abc/pulls/817 Fix inconsistency in compiling protoBin in ts2panda Issue: I6BPVO Signed-off-by: gavin1012_hw Change-Id: Ic9db89514e7d79e6766c6c7610c548e2bccfed56 --- ts2panda/src/compilerDriver.ts | 6 +++++- ts2panda/templates/irnodes.ts.erb | 6 +++++- ts2panda/ts2abc/ts2abc.cpp | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ts2panda/src/compilerDriver.ts b/ts2panda/src/compilerDriver.ts index 16c0921f81..ca2e9f1f62 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 54edae0d33..a083d8b5a3 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 9d06625f78..1ea1ece3c9 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; } -- Gitee