@@ -1101,6 +1101,7 @@ UHDM::any *CompileHelper::compileSelectExpression(
11011101 VectorOfexpr *exprs = s.MakeExprVec ();
11021102 var_select->Exprs (exprs);
11031103 var_select->VpiName (name);
1104+ var_select->VpiParent (pexpr);
11041105 result = var_select;
11051106 }
11061107 NodeId lastBitExp;
@@ -1132,27 +1133,26 @@ UHDM::any *CompileHelper::compileSelectExpression(
11321133
11331134 if (result) {
11341135 UHDM::var_select *var_select = (UHDM::var_select *)result;
1136+ var_select->VpiParent (pexpr);
11351137 VectorOfexpr *exprs = var_select->Exprs ();
11361138 exprs->push_back (sel);
1137- if (sel-> VpiParent () == nullptr ) sel->VpiParent (var_select);
1139+ sel->VpiParent (var_select);
11381140 } else if (fC ->Child (Bit_select) && fC ->Sibling (Bit_select)) {
11391141 UHDM::var_select *var_select = s.MakeVar_select ();
11401142 VectorOfexpr *exprs = s.MakeExprVec ();
11411143 var_select->Exprs (exprs);
11421144 var_select->VpiName (name);
1145+ var_select->VpiParent (pexpr);
1146+ sel->VpiParent (var_select);
11431147 exprs->push_back (sel);
11441148 result = var_select;
1145- if (sel->VpiParent () == nullptr ) sel->VpiParent (var_select);
11461149 } else {
11471150 bit_select *bit_select = s.MakeBit_select ();
11481151 bit_select->VpiName (name);
11491152 bit_select->VpiIndex (sel);
1153+ bit_select->VpiParent (pexpr);
1154+ sel->VpiParent (bit_select);
11501155 result = bit_select;
1151- if (sel->VpiParent () == nullptr ) sel->VpiParent (bit_select);
1152- ref_obj *ref = s.MakeRef_obj ();
1153- bit_select->VpiParent (ref);
1154- ref->VpiName (name);
1155- ref->VpiParent (pexpr);
11561156 }
11571157 lastBitExp = bitexp;
11581158 if (advanceBitSelect) Bit_select = bitexp;
@@ -1176,6 +1176,7 @@ UHDM::any *CompileHelper::compileSelectExpression(
11761176 VectorOfexpr *exprs = s.MakeExprVec ();
11771177 var_select->Exprs (exprs);
11781178 var_select->VpiName (name);
1179+ var_select->VpiParent (pexpr);
11791180 exprs->push_back (sel);
11801181 sel->VpiParent (var_select);
11811182 } else {
@@ -1218,50 +1219,16 @@ UHDM::any *CompileHelper::compileSelectExpression(
12181219 compileExpression (component, fC , Bit_select, compileDesign,
12191220 reduce, pexpr, instance, muteErrors);
12201221 if (sel) {
1222+ hname.append (" ." ).append (sel->VpiName ());
12211223 if (sel->UhdmType () == uhdmhier_path) {
12221224 hier_path *p = (hier_path *)sel;
12231225 for (auto el : *p->Path_elems ()) {
1226+ el->VpiParent (path);
12241227 elems->push_back (el);
1225- std::string n (el->VpiName ());
1226- if (el->UhdmType () == uhdmbit_select) {
1227- bit_select *bs = (bit_select *)el;
1228- const expr *index = bs->VpiIndex ();
1229- std::string_view ind = index->VpiDecompile ();
1230- if (ind.empty ()) ind = index->VpiName ();
1231- n.append (" [" ).append (ind).append (" ]" );
1232- hname += " ." + n;
1233- ref_obj *r = nullptr ;
1234- if ((bs->VpiParent () != nullptr ) &&
1235- (bs->VpiParent ()->UhdmType () == uhdmref_obj)) {
1236- r = (ref_obj *)bs->VpiParent ();
1237- } else {
1238- r = s.MakeRef_obj ();
1239- bs->VpiParent (r);
1240- }
1241- r->VpiName (hname);
1242- r->VpiParent (path);
1243- } else {
1244- hname += " ." + n;
1245- el->VpiParent (path);
1246- }
12471228 }
12481229 break ;
12491230 } else {
1250- hname.append (" ." ).append (sel->VpiName ());
1251- if (sel->UhdmType () == uhdmbit_select) {
1252- ref_obj *r = nullptr ;
1253- if ((sel->VpiParent () != nullptr ) &&
1254- (sel->VpiParent ()->UhdmType () == uhdmref_obj)) {
1255- r = (ref_obj *)sel->VpiParent ();
1256- } else {
1257- r = s.MakeRef_obj ();
1258- sel->VpiParent (r);
1259- }
1260- r->VpiName (hname);
1261- r->VpiParent (path);
1262- } else {
1263- sel->VpiParent (path);
1264- }
1231+ sel->VpiParent (path);
12651232 elems->push_back (sel);
12661233 }
12671234 }
@@ -1970,7 +1937,7 @@ UHDM::any *CompileHelper::compileExpression(
19701937 operation->VpiParent (pexpr);
19711938 operation->Attributes (attributes);
19721939 if (opL) {
1973- setParentNoOverride ( opL, operation);
1940+ opL-> VpiParent ( operation);
19741941 operands->push_back (opL);
19751942 }
19761943 if (vopType == 0 ) {
@@ -2041,7 +2008,7 @@ UHDM::any *CompileHelper::compileExpression(
20412008 compileExpression (component, fC , rval, compileDesign, reduce,
20422009 operation, instance, muteErrors);
20432010 if (opR) {
2044- setParentNoOverride ( opR, operation);
2011+ opR-> VpiParent ( operation);
20452012 operands->push_back (opR);
20462013 }
20472014 if (opType == VObjectType::slQmark ||
@@ -3672,54 +3639,43 @@ UHDM::any *CompileHelper::compilePartSelectRange(
36723639 UHDM::any *result = nullptr ;
36733640 NodeId Constant_expression = fC ->Child (Constant_range);
36743641 if (fC ->Type (Constant_range) == VObjectType::slConstant_range) {
3675- UHDM::expr *lexp =
3676- (expr *)compileExpression (component, fC , Constant_expression,
3677- compileDesign, Reduce::No, pexpr, instance);
3642+ UHDM::part_select *part_select = s.MakePart_select ();
3643+ UHDM::expr *lexp = (expr *)compileExpression (
3644+ component, fC , Constant_expression, compileDesign, Reduce::No,
3645+ part_select, instance);
36783646 UHDM::expr *rexp = (expr *)compileExpression (
36793647 component, fC , fC ->Sibling (Constant_expression), compileDesign,
3680- Reduce::No, pexpr, instance);
3681- UHDM::part_select *part_select = s.MakePart_select ();
3648+ Reduce::No, part_select, instance);
36823649 part_select->Left_range (lexp);
36833650 part_select->Right_range (rexp);
3684- if (name == " CREATE_UNNAMED_PARENT" ) {
3685- UHDM::ref_obj *ref = s.MakeRef_obj ();
3686- part_select->VpiParent (ref);
3687- } else if (!name.empty ()) {
3688- UHDM::ref_obj *ref = s.MakeRef_obj ();
3689- ref->VpiName (name);
3690- ref->VpiDefName (name);
3691- ref->VpiParent (pexpr);
3692- part_select->VpiParent (ref);
3651+ if (!name.empty () && (name != " CREATE_UNNAMED_PARENT" )) {
3652+ part_select->VpiName (name);
3653+ part_select->VpiDefName (name);
36933654 }
3655+ part_select->VpiParent (pexpr);
36943656 part_select->VpiConstantSelect (true );
36953657 result = part_select;
36963658 } else {
36973659 // constant_indexed_range
3660+ UHDM::indexed_part_select *part_select = s.MakeIndexed_part_select ();
36983661 UHDM::expr *lexp = (expr *)compileExpression (
3699- component, fC , Constant_expression, compileDesign, reduce, pexpr ,
3662+ component, fC , Constant_expression, compileDesign, reduce, part_select ,
37003663 instance, muteErrors);
37013664 NodeId op = fC ->Sibling (Constant_expression);
37023665 UHDM::expr *rexp =
37033666 (expr *)compileExpression (component, fC , fC ->Sibling (op), compileDesign,
3704- reduce, pexpr, instance, muteErrors);
3705-
3706- UHDM::indexed_part_select *part_select = s.MakeIndexed_part_select ();
3667+ reduce, part_select, instance, muteErrors);
37073668 part_select->Base_expr (lexp);
37083669 part_select->Width_expr (rexp);
37093670 if (fC ->Type (op) == VObjectType::slIncPartSelectOp)
37103671 part_select->VpiIndexedPartSelectType (vpiPosIndexed);
37113672 else
37123673 part_select->VpiIndexedPartSelectType (vpiNegIndexed);
3713- if (name == " CREATE_UNNAMED_PARENT" ) {
3714- UHDM::ref_obj *ref = s.MakeRef_obj ();
3715- part_select->VpiParent (ref);
3716- } else if (!name.empty ()) {
3717- UHDM::ref_obj *ref = s.MakeRef_obj ();
3718- ref->VpiName (name);
3719- ref->VpiDefName (name);
3720- ref->VpiParent (pexpr);
3721- part_select->VpiParent (ref);
3674+ if (!name.empty () && (name != " CREATE_UNNAMED_PARENT" )) {
3675+ part_select->VpiName (name);
3676+ part_select->VpiDefName (name);
37223677 }
3678+ part_select->VpiParent (pexpr);
37233679 part_select->VpiConstantSelect (true );
37243680 result = part_select;
37253681
@@ -4185,6 +4141,7 @@ UHDM::any *CompileHelper::compileBits(
41854141 } else if (sizeMode) {
41864142 UHDM::sys_func_call *sys = s.MakeSys_func_call ();
41874143 sys->VpiName (" $size" );
4144+ sys->VpiParent (pexpr);
41884145 VectorOfany *arguments =
41894146 compileTfCallArguments (component, fC , List_of_arguments, compileDesign,
41904147 reduce, sys, instance, muteErrors);
@@ -4193,6 +4150,7 @@ UHDM::any *CompileHelper::compileBits(
41934150 } else {
41944151 UHDM::sys_func_call *sys = s.MakeSys_func_call ();
41954152 sys->VpiName (" $bits" );
4153+ sys->VpiParent (pexpr);
41964154 VectorOfany *arguments =
41974155 compileTfCallArguments (component, fC , List_of_arguments, compileDesign,
41984156 reduce, sys, instance, muteErrors);
@@ -4431,6 +4389,7 @@ UHDM::any *CompileHelper::compileClog2(
44314389 } else {
44324390 UHDM::sys_func_call *sys = s.MakeSys_func_call ();
44334391 sys->VpiName (" $clog2" );
4392+ sys->VpiParent (pexpr);
44344393 VectorOfany *arguments =
44354394 compileTfCallArguments (component, fC , List_of_arguments, compileDesign,
44364395 reduce, sys, instance, muteErrors);
@@ -4495,14 +4454,15 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
44954454 } else if (fC ->Type (nameId) == VObjectType::slConstant_expression) {
44964455 NodeId Constant_expresion = fC ->Child (nameId);
44974456 if (Constant_expresion) {
4498- name += " [ " ;
4457+ bit_select *sel = s. MakeBit_select () ;
44994458 expr *select = (expr *)compileExpression (
4500- component, fC , Constant_expresion, compileDesign, reduce, pexpr ,
4459+ component, fC , Constant_expresion, compileDesign, reduce, sel ,
45014460 instance, muteErrors);
4502- name += select-> VpiDecompile ( );
4503- name += " ] " ;
4504- bit_select * sel = s. MakeBit_select ( );
4461+ std::string bsname = decompileHelper (select );
4462+ name += bsname ;
4463+ sel-> VpiName (bsname );
45054464 sel->VpiIndex (select);
4465+ sel->VpiParent (path);
45064466 elems->push_back (sel);
45074467 }
45084468 } else {
@@ -4511,6 +4471,7 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
45114471 nameId = fC ->Sibling (nameId);
45124472 }
45134473 path->VpiName (name);
4474+ path->VpiParent (pexpr);
45144475 result = path;
45154476 } else if (fC ->Type (name) == VObjectType::slDollar_keyword) {
45164477 NodeId Dollar_keyword = name;
@@ -4537,6 +4498,7 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
45374498 NodeId List_of_arguments = fC ->Sibling (nameId);
45384499 UHDM::sys_func_call *sys = s.MakeSys_func_call ();
45394500 sys->VpiName (StrCat (" $" , name));
4501+ sys->VpiParent (pexpr);
45404502 VectorOfany *arguments = compileTfCallArguments (
45414503 component, fC , List_of_arguments, compileDesign, reduce, sys,
45424504 instance, muteErrors);
@@ -4716,15 +4678,15 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
47164678 ref->VpiName (StrCat (packagename, " ::" , functionname));
47174679 ref->VpiFullName (StrCat (packagename, " ::" , functionname));
47184680 ref->Actual_group (param);
4719- ref->VpiParent (pexpr );
4681+ ref->VpiParent (path );
47204682 fC ->populateCoreMembers (name, name, ref);
47214683 elems->push_back (ref);
47224684 while (List_of_arguments) {
47234685 if ((fC ->Type (List_of_arguments) ==
47244686 VObjectType::slStringConst)) {
47254687 ref_obj *ref = s.MakeRef_obj ();
47264688 ref->VpiName (fC ->SymName (List_of_arguments));
4727- ref->VpiParent (pexpr );
4689+ ref->VpiParent (path );
47284690 fC ->populateCoreMembers (List_of_arguments, List_of_arguments,
47294691 ref);
47304692 elems->push_back (ref);
@@ -4785,11 +4747,6 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
47854747 instance, muteErrors);
47864748 if (result && (result->UhdmType () == UHDM::uhdmpart_select)) {
47874749 fC ->populateCoreMembers (name, dotedName, result);
4788- if ((result->VpiParent () != nullptr ) &&
4789- (result->VpiParent ()->UhdmType () == UHDM::uhdmref_obj)) {
4790- ref_obj *const parent = (ref_obj *)result->VpiParent ();
4791- fC ->populateCoreMembers (name, name, parent);
4792- }
47934750 }
47944751 return result;
47954752 } else if ((!selectName) &&
@@ -4806,6 +4763,7 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
48064763 instance);
48074764 if (index) {
48084765 bit_select *select = s.MakeBit_select ();
4766+ index->VpiParent (select);
48094767 select->VpiIndex (index);
48104768 the_name += decompileHelper (index);
48114769 select->VpiFullName (the_name);
@@ -4898,10 +4856,8 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
48984856 compileDesign, reduce, nullptr , instance, muteErrors);
48994857 // Fix start/end to include the name
49004858 select->VpiColumnNo (fC ->Column (name));
4901- ref_obj *parent = (ref_obj *)select->VpiParent ();
4902- if (parent) parent->VpiName (tmpName);
4903- if (tmpName.empty ()) {
4904- select->VpiParent (nullptr );
4859+ if (ref_obj *ro = any_cast<ref_obj *>(select)) {
4860+ ro->VpiName (tmpName);
49054861 }
49064862 elems->push_back (select);
49074863 the_name += decompileHelper (select);
@@ -4914,8 +4870,9 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
49144870 compileDesign, reduce, nullptr , instance, muteErrors);
49154871 // Fix start/end to include the name
49164872 select->VpiColumnNo (fC ->Column (name));
4917- ref_obj *parent = (ref_obj *)select->VpiParent ();
4918- if (parent) parent->VpiDefName (tmpName);
4873+ if (ref_obj *ro = any_cast<ref_obj *>(select)) {
4874+ ro->VpiDefName (tmpName);
4875+ }
49194876 elems->push_back (select);
49204877 the_name += decompileHelper (select);
49214878 } else if (Expression) {
@@ -4924,24 +4881,17 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
49244881 instance, muteErrors);
49254882 if (index) {
49264883 bit_select *select = s.MakeBit_select ();
4927- elems->push_back (select);
4928- ref_obj *ref = s.MakeRef_obj ();
4929- ref->VpiName (tmpName);
4930- ref->VpiParent (path);
4931- if (!tmpName.empty ()) select->VpiParent (ref);
49324884 select->VpiIndex (index);
49334885 select->VpiName (tmpName);
4934- select->VpiFullName (tmpName );
4886+ select->VpiParent (path );
49354887 fC ->populateCoreMembers (name, name, select);
4936- std::string indexName = decompileHelper (index);
4937- the_name += indexName;
4938- if (!tmpName.empty ()) ref->VpiName (tmpName + indexName);
4888+ elems->push_back (select);
4889+ the_name += decompileHelper (index);
49394890 }
49404891 } else {
49414892 ref_obj *ref = s.MakeRef_obj ();
49424893 elems->push_back (ref);
49434894 ref->VpiName (tmpName);
4944- ref->VpiFullName (tmpName);
49454895 ref->VpiParent (path);
49464896 fC ->populateCoreMembers (name, name, ref);
49474897 }
@@ -5128,7 +5078,8 @@ UHDM::any *CompileHelper::compileComplexFuncCall(
51285078 result = ref;
51295079 }
51305080 } else if (fC ->Type (dotedName) == VObjectType::slList_of_arguments) {
5131- result = compileTfCall (component, fC , fC ->Parent (name), compileDesign);
5081+ result =
5082+ compileTfCall (component, fC , fC ->Parent (name), compileDesign, pexpr);
51325083 } else if (fC ->Type (name) == VObjectType::slStringConst) {
51335084 const std::string_view n = fC ->SymName (name);
51345085 ref_obj *ref = s.MakeRef_obj ();
0 commit comments