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

Method swapForSpecifiedVar

src/DesignCompile/UhdmWriter.cpp:2440–2521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2438}
2439
2440UHDM::any* UhdmWriter::swapForSpecifiedVar(UHDM::Serializer& s,
2441 DesignComponent* mod, any* tmp,
2442 VectorOfvariables* lvariables,
2443 variables* lvariable,
2444 std::string_view name,
2445 const any* var, const any* parent) {
2446 FileSystem* const fileSystem = FileSystem::getInstance();
2447 if (tmp->VpiName() == name) {
2448 if (var->UhdmType() == uhdmref_var) {
2449 ref_var* ref = (ref_var*)var;
2450 const typespec* tp = nullptr;
2451 if (ref_typespec* rt = ref->Typespec()) tp = rt->Actual_typespec();
2452 if (tp && tp->UhdmType() == uhdmunsupported_typespec) {
2453 const typespec* indexTypespec = nullptr;
2454 if (lvariables) {
2455 for (auto var : *lvariables) {
2456 if (var->UhdmType() == uhdmhier_path) {
2457 PathId parentFileId = fileSystem->toPathId(
2458 parent->VpiFile(),
2459 m_compileDesign->getCompiler()->getSymbolTable());
2460 bool invalidValue = false;
2461 indexTypespec = (typespec*)m_helper.decodeHierPath(
2462 (hier_path*)var, invalidValue, mod, m_compileDesign,
2463 Reduce::Yes, nullptr, parentFileId, parent->VpiLineNo(),
2464 (any*)parent, true /*mute for now*/, true);
2465 }
2466 }
2467 } else if (const variables* var = lvariable) {
2468 if (var->UhdmType() == uhdmhier_path) {
2469 PathId parentFileId = fileSystem->toPathId(
2470 parent->VpiFile(),
2471 m_compileDesign->getCompiler()->getSymbolTable());
2472 bool invalidValue = false;
2473 indexTypespec = (typespec*)m_helper.decodeHierPath(
2474 (hier_path*)var, invalidValue, mod, m_compileDesign,
2475 Reduce::Yes, nullptr, parentFileId, parent->VpiLineNo(),
2476 (any*)parent, true /*mute for now*/, true);
2477 } else if (var->UhdmType() == uhdmref_var) {
2478 bool invalidValue = false;
2479 hier_path* path = s.MakeHier_path();
2480 VectorOfany* elems = s.MakeAnyVec();
2481 path->Path_elems(elems);
2482 ref_obj* ref = s.MakeRef_obj();
2483 elems->push_back(ref);
2484 ref->VpiName(var->VpiName());
2485 path->VpiFullName(var->VpiName());
2486 PathId parentFileId = fileSystem->toPathId(
2487 parent->VpiFile(),
2488 m_compileDesign->getCompiler()->getSymbolTable());
2489 indexTypespec = (typespec*)m_helper.decodeHierPath(
2490 path, invalidValue, mod, m_compileDesign, Reduce::Yes, nullptr,
2491 parentFileId, parent->VpiLineNo(), (any*)parent,
2492 true /*mute for now*/, true);
2493 }
2494 }
2495 variables* swapVar = nullptr;
2496 if (indexTypespec) {
2497 swapVar = m_helper.getSimpleVarFromTypespec((typespec*)indexTypespec,

Callers

nothing calls this directly

Calls 5

toPathIdMethod · 0.80
decodeHierPathMethod · 0.80
getSymbolTableMethod · 0.45
getCompilerMethod · 0.45

Tested by

no test coverage detected