MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / locateVariable_

Method locateVariable_

src/DesignCompile/ElaborationStep.cpp:1085–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1083}
1084
1085Variable* ElaborationStep::locateVariable_(
1086 const std::vector<std::string_view>& var_chain, const FileContent* fC,
1087 NodeId id, Scope* scope, DesignComponent* parentComponent,
1088 ErrorDefinition::ErrorType errtype) {
1089 Variable* the_obj = nullptr;
1090 const DesignComponent* currentComponent = parentComponent;
1091 for (auto var : var_chain) {
1092 if (var == "this") {
1093 } else if (var == "super") {
1094 const ClassDefinition* classDefinition =
1095 valuedcomponenti_cast<const ClassDefinition*>(currentComponent);
1096 if (classDefinition) {
1097 currentComponent = nullptr;
1098 const auto& baseClassMap = classDefinition->getBaseClassMap();
1099 if (!baseClassMap.empty()) {
1100 currentComponent = datatype_cast<const ClassDefinition*>(
1101 baseClassMap.begin()->second);
1102 var = "this";
1103 }
1104 if (currentComponent == nullptr) {
1105 var = "super";
1106 currentComponent = parentComponent;
1107 }
1108 }
1109 }
1110
1111 the_obj =
1112 bindVariable_(var, scope, fC, id, currentComponent, errtype, false);
1113 if (the_obj) {
1114 const DataType* dtype = the_obj->getDataType();
1115 while (dtype && dtype->getDefinition()) {
1116 dtype = dtype->getDefinition();
1117 }
1118 const ClassDefinition* tmpClass =
1119 datatype_cast<const ClassDefinition*>(dtype);
1120 if (tmpClass) {
1121 currentComponent = tmpClass;
1122 }
1123 }
1124 }
1125 return the_obj;
1126}
1127
1128Variable* ElaborationStep::locateStaticVariable_(
1129 const std::vector<std::string_view>& var_chain, const FileContent* fC,

Callers

nothing calls this directly

Calls 2

getDataTypeMethod · 0.45
getDefinitionMethod · 0.45

Tested by

no test coverage detected