MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / getValueFromSymbol

Method getValueFromSymbol

erpcgen/src/SymbolScanner.cpp:1570–1604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1568}
1569
1570Value *SymbolScanner::getValueFromSymbol(const Token &tok)
1571{
1572 if (tok.getValue() != nullptr)
1573 {
1574 string name = tok.getStringValue();
1575 Symbol *sym = m_globals->getSymbol(name);
1576 if (nullptr != sym)
1577 {
1578 Value *newVal;
1579 if (sym->isConstSymbol())
1580 {
1581 ConstType *constVar = dynamic_cast<ConstType *>(sym);
1582 assert(constVar);
1583 newVal = constVar->getValue()->clone();
1584 }
1585 else if (sym->isEnumMemberSymbol())
1586 {
1587 EnumMember *enumVar = dynamic_cast<EnumMember *>(sym);
1588 assert(enumVar);
1589 newVal = new IntegerValue(enumVar->getValue());
1590 }
1591 else
1592 {
1593 throw semantic_error(format_string("line %d: Cannot get value from symbol type: %s.\n",
1594 tok.getFirstLine(), sym->getDescription().c_str()));
1595 }
1596
1597 return newVal;
1598 }
1599
1600 throw syntax_error(format_string("line %d: Symbol %s is not defined.\n", tok.getFirstLine(), name.c_str()));
1601 }
1602
1603 throw syntax_error(format_string("line %d: cannot get token value.\n", tok.getFirstLine()));
1604}
1605
1606uint64_t SymbolScanner::getIntExprValue(const AstNode *exprNode)
1607{

Callers

nothing calls this directly

Calls 10

semantic_errorClass · 0.85
format_stringFunction · 0.85
syntax_errorClass · 0.85
getSymbolMethod · 0.80
isConstSymbolMethod · 0.80
isEnumMemberSymbolMethod · 0.80
getValueMethod · 0.45
cloneMethod · 0.45
getFirstLineMethod · 0.45
getDescriptionMethod · 0.45

Tested by

no test coverage detected