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

Method compileVariable

src/DesignCompile/CompileType.cpp:250–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250UHDM::any* CompileHelper::compileVariable(
251 DesignComponent* component, const FileContent* fC, NodeId declarationId,
252 CompileDesign* compileDesign, Reduce reduce, UHDM::any* pstmt,
253 SURELOG::ValuedComponentI* instance, bool muteErrors) {
254 UHDM::Serializer& s = compileDesign->getSerializer();
255 Design* design = compileDesign->getCompiler()->getDesign();
256 UHDM::any* result = nullptr;
257 NodeId variable = declarationId;
258 VObjectType the_type = fC->Type(variable);
259 if (the_type == VObjectType::paData_type ||
260 the_type == VObjectType::paPs_or_hierarchical_identifier) {
261 variable = fC->Child(variable);
262 the_type = fC->Type(variable);
263 if (the_type == VObjectType::paVIRTUAL) {
264 variable = fC->Sibling(variable);
265 the_type = fC->Type(variable);
266 }
267 } else if (the_type == VObjectType::paImplicit_class_handle) {
268 NodeId Handle = fC->Child(variable);
269 if (fC->Type(Handle) == VObjectType::paThis_keyword) {
270 variable = fC->Sibling(variable);
271 the_type = fC->Type(variable);
272 }
273 } else if (the_type == VObjectType::sl_INVALID_) {
274 return nullptr;
275 }
276 if (the_type == VObjectType::paComplex_func_call) {
277 variable = fC->Child(variable);
278 the_type = fC->Type(variable);
279 }
280 NodeId Packed_dimension = fC->Sibling(variable);
281 if (!Packed_dimension) {
282 // Implicit return value:
283 // function [1:0] fct();
284 if (fC->Type(variable) == VObjectType::paConstant_range) {
285 Packed_dimension = variable;
286 }
287 }
288
289 if (fC->Type(variable) == VObjectType::slStringConst &&
290 fC->Type(Packed_dimension) == VObjectType::slStringConst) {
291 UHDM::hier_path* path = s.MakeHier_path();
292 VectorOfany* elems = s.MakeAnyVec();
293 path->Path_elems(elems);
294 std::string fullName(fC->SymName(variable));
295 ref_obj* obj = s.MakeRef_obj();
296 obj->VpiName(fullName);
297 obj->VpiParent(path);
298 elems->push_back(obj);
299 fC->populateCoreMembers(variable, variable, obj);
300 while (fC->Type(Packed_dimension) == VObjectType::slStringConst) {
301 ref_obj* obj = s.MakeRef_obj();
302 const std::string_view name = fC->SymName(Packed_dimension);
303 fullName.append(".").append(name);
304 obj->VpiName(name);
305 obj->VpiParent(path);
306 elems->push_back(obj);
307 Packed_dimension = fC->Sibling(Packed_dimension);

Callers

nothing calls this directly

Calls 15

StrCatFunction · 0.85
getDesignMethod · 0.80
populateCoreMembersMethod · 0.80
getUhdmDefinitionMethod · 0.80
getCompilerMethod · 0.45
TypeMethod · 0.45
ChildMethod · 0.45
SiblingMethod · 0.45
SymNameMethod · 0.45
appendMethod · 0.45
getDataTypeMethod · 0.45

Tested by

no test coverage detected