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

Method evalExpr

src/Expression/ExprBuilder.cpp:72–921  ·  view source on GitHub ↗

Often, there are assignments to muteErrors here, that are never read. It seems like there is a (future?) intention here. So for now, disable warnings from clang-tidy. TODO(Alain): remove N0LINTBEGIN, run .github/bin/run-clang-tidy.sh and fix the intended places. NOLINTBEGIN(*.DeadStores)

Source from the content-addressed store, hash-verified

70//
71// NOLINTBEGIN(*.DeadStores)
72Value* ExprBuilder::evalExpr(const FileContent* fC, NodeId parent,
73 ValuedComponentI* instance, bool muteErrors) {
74 Value* value = m_valueFactory.newLValue();
75 NodeId child = fC->Child(parent);
76 VObjectType type = fC->Type(parent);
77 switch (type) {
78 case VObjectType::paPackage_scope: {
79 Value* sval = nullptr;
80 const std::string_view packageName = fC->SymName(child);
81 const std::string_view name = fC->SymName(fC->Sibling(parent));
82 if (m_design) {
83 Package* pack = m_design->getPackage(packageName);
84 if (pack) {
85 if (pack->getComplexValue(name)) {
86 muteErrors = true;
87 value->setInvalid();
88 break;
89 } else {
90 sval = pack->getValue(name);
91 }
92 }
93 }
94 std::string fullName;
95 if (sval == nullptr) fullName = StrCat(packageName, "::", name);
96 if (sval == nullptr) {
97 if (muteErrors == false) {
98 Location loc(fC->getFileId(parent), fC->Line(parent),
99 fC->Column(parent), m_symbols->registerSymbol(fullName));
100 Error err(ErrorDefinition::ELAB_UNDEF_VARIABLE, loc);
101 m_errors->addError(err);
102 }
103 value->setInvalid();
104 return value;
105 }
106 if (sval->getType() == Value::Type::String ||
107 sval->getType() == Value::Type::Hexadecimal) {
108 m_valueFactory.deleteValue(value);
109 value = clone(sval);
110 } else {
111 value->u_plus(sval);
112 }
113 return value;
114 }
115 default:
116 break;
117 }
118
119 if (child) {
120 VObjectType childType = fC->Type(child);
121 switch (childType) {
122 case VObjectType::paIncDec_PlusPlus: {
123 // Pre increment
124 NodeId sibling = fC->Sibling(child);
125 Value* tmp = evalExpr(fC, sibling, instance, muteErrors);
126 value->u_plus(tmp);
127 value->incr();
128 m_valueFactory.deleteValue(tmp);
129 break;

Callers 8

TESTFunction · 0.80
compileTfPortListMethod · 0.80
compileTypeDefMethod · 0.80
elaborateInstance_Method · 0.80
collectParams_Method · 0.80
compileTypespecMethod · 0.80
compileRangesMethod · 0.80

Calls 15

StrCatFunction · 0.85
parseInt64Function · 0.85
parseHexFunction · 0.85
parseBinaryFunction · 0.85
parseOctalFunction · 0.85
parseUint64Function · 0.85
newLValueMethod · 0.80
newStValueMethod · 0.80
equivMethod · 0.80
notEqualMethod · 0.80
logFunction · 0.50
ChildMethod · 0.45

Tested by 1

TESTFunction · 0.64