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

Method locateStaticVariable_

src/DesignCompile/ElaborationStep.cpp:1128–1212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128Variable* ElaborationStep::locateStaticVariable_(
1129 const std::vector<std::string_view>& var_chain, const FileContent* fC,
1130 NodeId id, Scope* scope, DesignComponent* parentComponent,
1131 ErrorDefinition::ErrorType errtype) {
1132 std::string name;
1133 for (uint32_t i = 0; i < var_chain.size(); i++) {
1134 name += var_chain[i];
1135 if (i < var_chain.size() - 1) name += "::";
1136 }
1137 std::map<std::string, Variable*>::iterator itr = m_staticVariables.find(name);
1138 if (itr != m_staticVariables.end()) return (*itr).second;
1139 Variable* result = nullptr;
1140 Design* design = m_compileDesign->getCompiler()->getDesign();
1141 if (!var_chain.empty()) {
1142 Package* package = design->getPackage(var_chain[0]);
1143 if (package) {
1144 if (var_chain.size() > 1) {
1145 ClassDefinition* classDefinition =
1146 package->getClassDefinition(var_chain[1]);
1147 if (classDefinition) {
1148 if (var_chain.size() == 2) {
1149 result =
1150 new Variable(classDefinition, classDefinition->getFileContent(),
1151 classDefinition->getNodeId(), InvalidNodeId,
1152 classDefinition->getName());
1153 }
1154 if (var_chain.size() == 3) {
1155 std::vector<std::string_view> tmp;
1156 tmp.emplace_back(var_chain[2]);
1157 result =
1158 locateVariable_(tmp, fC, id, scope, classDefinition, errtype);
1159 }
1160 }
1161 }
1162 }
1163
1164 if (result == nullptr) {
1165 ClassDefinition* classDefinition =
1166 design->getClassDefinition(var_chain[0]);
1167 if (classDefinition == nullptr) {
1168 if (parentComponent && parentComponent->getParentScope()) {
1169 const std::string name = StrCat(
1170 ((DesignComponent*)parentComponent->getParentScope())->getName(),
1171 "::", var_chain[0]);
1172 classDefinition = design->getClassDefinition(name);
1173 }
1174 }
1175 if (classDefinition) {
1176 if (var_chain.size() == 1)
1177 result =
1178 new Variable(classDefinition, classDefinition->getFileContent(),
1179 classDefinition->getNodeId(), InvalidNodeId,
1180 classDefinition->getName());
1181 if (var_chain.size() == 2) {
1182 std::vector<std::string_view> tmp;
1183 tmp.emplace_back(var_chain[1]);
1184
1185 const DataType* dtype =

Callers

nothing calls this directly

Calls 9

StrCatFunction · 0.85
getDesignMethod · 0.80
getCompilerMethod · 0.45
getPackageMethod · 0.45
getClassDefinitionMethod · 0.45
getFileContentMethod · 0.45
getNodeIdMethod · 0.45
getNameMethod · 0.45
getParentScopeMethod · 0.45

Tested by

no test coverage detected