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

Method addSymbol

erpcgen/src/types/Type.cpp:191–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void SymbolScope::addSymbol(Symbol *sym, int32_t pos)
192{
193 assert(sym);
194
195 // Check for existing symbol with same name.
196 // sym->getName() == "" for anonymous struct and enums
197 if (hasSymbol(sym->getName()) && sym->getName() != "")
198 {
199 Symbol *existing = getSymbol(sym->getName());
200 if (existing->isDatatypeSymbol() && dynamic_cast<DataType *>(existing)->isBuiltin())
201 {
202 throw semantic_error(format_string("line %d: attempted redefinition of builtin symbol '%s'",
203 sym->getFirstLine(), sym->getName().c_str()));
204 }
205 else
206 {
207 throw semantic_error(format_string("line %d: duplicate symbol with name '%s' (original on line %d)",
208 sym->getFirstLine(), sym->getName().c_str(), existing->getFirstLine()));
209 }
210 }
211
212 // Add the symbol.
213 m_symbolMap[sym->getName()] = sym;
214 if (pos >= 0)
215 {
216 m_symbolVector.insert(m_symbolVector.begin() + pos, sym);
217 }
218 else
219 {
220 m_symbolVector.push_back(sym);
221 }
222}
223
224void SymbolScope::replaceSymbol(Symbol *oldSym, Symbol *newSym)
225{

Callers 7

handleUnionMethod · 0.80
addGlobalSymbolMethod · 0.80
createBuiltinTypesMethod · 0.80
findChildDataTypeMethod · 0.80
addMemberMethod · 0.80
addFunctionMethod · 0.80
addFunctionTypeMethod · 0.80

Calls 8

semantic_errorClass · 0.85
format_stringFunction · 0.85
isDatatypeSymbolMethod · 0.80
isBuiltinMethod · 0.80
push_backMethod · 0.80
getNameMethod · 0.45
getFirstLineMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected