bool SymbolTable::symbolExists(const std::wstring& symbol, unsigned int file, unsigned int section) { if (isValidSymbolName(symbol) == false) return false; setFileSectionValues(symbol,file,section); SymbolKey key = { symbol, file, section }; auto it = symbols.find(key); return it != symbols.end(); }
bool SymbolTable::addEquation(const std::wstring& name, int file, int section, size_t referenceIndex) { if (isValidSymbolName(name) == false) return false; if (symbolExists(name,file,section)) return false; setFileSectionValues(name,file,section); SymbolKey key = { name, file, section }; SymbolInfo value = { EquationSymbol, referenceIndex }; symbols[key] = value; equationsCount++; return true; }
bool SymbolTable::addEquation(const std::wstring& name, unsigned int file, unsigned int section, std::wstring& replacement) { if (isValidSymbolName(name) == false) return false; if (symbolExists(name,file,section)) return false; setFileSectionValues(name,file,section); SymbolKey key = { name, file, section }; SymbolInfo value = { EquationSymbol, equations.size() }; symbols[key] = value; Equation equation = { name, replacement, file, section }; equations.push_back(equation); return true; }
void SymbolTable::addLabels(const std::vector<LabelDefinition>& labels) { for (const LabelDefinition& def: labels) { if (!isValidSymbolName(def.name)) continue; std::shared_ptr<Label> label = getLabel(def.name,Global.FileInfo.FileNum,Global.Section); if (label == nullptr) continue; if (isLocalSymbol(def.name) == false) Global.Section++; label->setDefined(true); label->setValue(def.value); } }