diff --git a/ts2panda/src/ts2panda.ts b/ts2panda/src/ts2panda.ts index f6d17a09f2e198a277d59755a337f5bf718caf38..5057c74af210296e78082b7e1f37aa847fe53b5d 100644 --- a/ts2panda/src/ts2panda.ts +++ b/ts2panda/src/ts2panda.ts @@ -17,12 +17,17 @@ import * as ts from "typescript"; import { CmdOptions } from "./cmdOptions"; import { SourceTextModuleRecord } from "./ecmaModule"; import { + Createarraywithbuffer, + Createobjectwithbuffer, + Defineclasswithbuffer, Imm, IRNode, IRNodeKind, Label, + Newlexenvwithname, OperandType, - VReg + VReg, + WideNewlexenvwithname, } from "./irnodes"; import { LOGD } from "./log"; import { PandaGen } from "./pandagen"; @@ -134,8 +139,10 @@ export class Ts2Panda { let imm = operand; insImms.push(imm.value); } else if (typeof (operand) === "string") { - insIds.push(operand); - Ts2Panda.strings.add(operand); + if (!this.escapeLitIdString(insn, operand)) { + insIds.push(operand); + Ts2Panda.strings.add(operand); + } } else if (operand instanceof Label) { let labelName = Ts2Panda.labelPrefix + operand.id; insIds.push(labelName); @@ -162,6 +169,23 @@ export class Ts2Panda { }; } + static escapeLitIdString(insn: IRNode, operand: string): boolean { + if (insn instanceof Createarraywithbuffer || insn instanceof Createobjectwithbuffer || + insn instanceof Newlexenvwithname || insn instanceof WideNewlexenvwithname) { + return true; + } + + if (!(insn instanceof Defineclasswithbuffer)) { + return false; + } + + if (insn.operands[2] == operand) { + return true; + } + + return false; + } + static dumpStringsArray(ts2abc: any) { let strings_arr = Array.from(Ts2Panda.strings);