From 73dff0ef3b64642879eaf5c3bf6adcc7883d4163 Mon Sep 17 00:00:00 2001 From: qiuyu Date: Wed, 8 Feb 2023 16:41:54 +0800 Subject: [PATCH] Test: Get stat of abc files Test: Get stat of abc files Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/I6DAU3 Signed-off-by: qiuyu Change-Id: I5f37cd174813843bb121ddc3f96f8c9fd919849e --- ts2panda/src/ts2panda.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ts2panda/src/ts2panda.ts b/ts2panda/src/ts2panda.ts index f6d17a09f2e..c326668db70 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"; @@ -135,7 +140,9 @@ export class Ts2Panda { insImms.push(imm.value); } else if (typeof (operand) === "string") { insIds.push(operand); - Ts2Panda.strings.add(operand); + if (!this.escapeLitIdString(insn, 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); -- Gitee