| 1079 | reInstance(object); |
| 1080 | } |
| 1081 | void reInstance(const any* cobject) { |
| 1082 | if (cobject == nullptr) return; |
| 1083 | any* object = (any*)cobject; |
| 1084 | const instance* inst = nullptr; |
| 1085 | if (typespec* tps = any_cast<typespec*>(object)) { |
| 1086 | inst = tps->Instance(); |
| 1087 | } else if (function* tps = any_cast<function*>(object)) { |
| 1088 | inst = tps->Instance(); |
| 1089 | } else if (task* tps = any_cast<task*>(object)) { |
| 1090 | inst = tps->Instance(); |
| 1091 | } |
| 1092 | if (inst) { |
| 1093 | const std::string_view name = inst->VpiName(); |
| 1094 | design* d = (design*)m_package->VpiParent(); |
| 1095 | if (d->AllPackages() != nullptr) { |
| 1096 | for (auto pack : *d->AllPackages()) { |
| 1097 | if (pack->VpiName() == name) { |
| 1098 | if (typespec* tps = any_cast<typespec*>(object)) { |
| 1099 | tps->Instance(pack); |
| 1100 | if (const enum_typespec* et = |
| 1101 | any_cast<const enum_typespec*>(cobject)) { |
| 1102 | reInstance(et->Base_typespec()); |
| 1103 | } |
| 1104 | } else if (function* tps = any_cast<function*>(object)) { |
| 1105 | tps->Instance(pack); |
| 1106 | } else if (task* tps = any_cast<task*>(object)) { |
| 1107 | tps->Instance(pack); |
| 1108 | } |
| 1109 | break; |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | private: |
| 1117 | package* m_package = nullptr; |