修复 entity 类型 module 删除错误的问题

This commit is contained in:
锦恢 2024-12-18 00:45:27 +08:00
parent 8900b2b920
commit 54b676ea9d

View File

@ -1153,10 +1153,6 @@ export class HdlFile {
// make nameToModule // make nameToModule
this.nameToModule = new Map<string, HdlModule>(); this.nameToModule = new Map<string, HdlModule>();
if (path.endsWith('vhd')) {
console.log(path);
console.log(modules);
}
for (const rawHdlModule of modules) { for (const rawHdlModule of modules) {
this.createHdlModule(rawHdlModule); this.createHdlModule(rawHdlModule);
@ -1238,7 +1234,7 @@ export class HdlFile {
} }
public deleteHdlModule(name: string) { public deleteHdlModule(name: string) {
const hdlModule = this.getHdlModule(name); let hdlModule = this.getHdlModule(name);
if (hdlModule) { if (hdlModule) {
// delete child reference in the module which use this // delete child reference in the module which use this
for (const childInst of hdlModule.getAllGlobalRefers()) { for (const childInst of hdlModule.getAllGlobalRefers()) {
@ -1260,7 +1256,27 @@ export class HdlFile {
hdlParam.deleteTopModule(hdlModule); hdlParam.deleteTopModule(hdlModule);
hdlParam.deleteTopModuleToSource(hdlModule); hdlParam.deleteTopModuleToSource(hdlModule);
hdlParam.modules.delete(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);
}
}
} }
} }