From 54b676ea9da3bb5909d755d3814b3a66fa758547 Mon Sep 17 00:00:00 2001 From: LSTM-Kirigaya <1193466151@qq.com> Date: Wed, 18 Dec 2024 00:45:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20entity=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=20module=20=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hdlParser/core.ts | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/hdlParser/core.ts b/src/hdlParser/core.ts index b3f329e..b127d0f 100644 --- a/src/hdlParser/core.ts +++ b/src/hdlParser/core.ts @@ -1153,10 +1153,6 @@ export class HdlFile { // make nameToModule this.nameToModule = new Map(); - if (path.endsWith('vhd')) { - console.log(path); - console.log(modules); - } for (const rawHdlModule of modules) { this.createHdlModule(rawHdlModule); @@ -1238,7 +1234,7 @@ export class HdlFile { } public deleteHdlModule(name: string) { - const hdlModule = this.getHdlModule(name); + let hdlModule = this.getHdlModule(name); if (hdlModule) { // delete child reference in the module which use this for (const childInst of hdlModule.getAllGlobalRefers()) { @@ -1260,7 +1256,27 @@ export class HdlFile { hdlParam.deleteTopModule(hdlModule); hdlParam.deleteTopModuleToSource(hdlModule); hdlParam.modules.delete(hdlModule); - this.nameToModule.delete(hdlModule.name); + + // TODO: 未来迁移这段逻辑 + hdlModule = this.nameToModule.get(name); + if (hdlModule !== undefined) { + this.nameToModule.delete(name); + } else { + let entityComName: undefined | string = undefined; + for (const moduleName of this.nameToModule.keys()) { + if (moduleName.includes('(')) { + const entityName = moduleName.split('(')[0]; + if (entityName === name) { + entityComName = moduleName; + break; + } + } + } + + if (entityComName) { + this.nameToModule.delete(entityComName); + } + } } }