GP-2913 minor adjustments

This commit is contained in:
James 2022-12-02 19:30:21 +00:00
parent 6a75d6c2ab
commit 6e6cf6d935
2 changed files with 9 additions and 4 deletions

View file

@ -2135,8 +2135,11 @@ void SleighCompile::checkCaseSensitivity(void)
SleighSymbol *oldsym = (*check.first).second; SleighSymbol *oldsym = (*check.first).second;
ostringstream s; ostringstream s;
s << "Name collision: " << sym->getName() << " --- "; s << "Name collision: " << sym->getName() << " --- ";
s << "Duplicate symbol " << oldsym->getName();
const Location *oldLocation = getLocation(oldsym); const Location *oldLocation = getLocation(oldsym);
s << "Duplicate symbol " << oldsym->getName() << " defined at " << oldLocation->format(); if (oldLocation != (Location *) 0x0) {
s << " defined at " << oldLocation->format();
}
const Location *location = getLocation(sym); const Location *location = getLocation(sym);
reportError(location,s.str()); reportError(location,s.str());
} }
@ -2190,13 +2193,13 @@ const Location *SleighCompile::getLocation(Constructor *ctor) const
} }
/// \param sym is the given symbol /// \param sym is the given symbol
/// \return the filename and line number /// \return the filename and line number or null if location not found
const Location *SleighCompile::getLocation(SleighSymbol *sym) const const Location *SleighCompile::getLocation(SleighSymbol *sym) const
{ {
try { try {
return &symbolLocationMap.at(sym); return &symbolLocationMap.at(sym);
} catch (const std::exception &e) { } catch (const std::out_of_range &e) {
return NULL; return NULL;
} }
} }
@ -2678,7 +2681,7 @@ void SleighCompile::attachValues(vector<SleighSymbol *> *symlist,vector<intb> *n
if (patval->maxValue() + 1 != numlist->size()) { if (patval->maxValue() + 1 != numlist->size()) {
ostringstream msg; ostringstream msg;
msg << "Attach value '" + sym->getName(); msg << "Attach value '" + sym->getName();
msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << numlist->size() << " entries"; msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << numlist->size() << " entries)";
reportError(getCurrentLocation(), msg.str()); reportError(getCurrentLocation(), msg.str());
} }
symtab.replaceSymbol(sym, new ValueMapSymbol(sym->getName(),patval,*numlist)); symtab.replaceSymbol(sym, new ValueMapSymbol(sym->getName(),patval,*numlist));

View file

@ -488,6 +488,8 @@ public class SleighCompile extends SleighBase {
} }
for (int i = 0; i < tables.size(); ++i) { for (int i = 0; i < tables.size(); ++i) {
if (tables.get(i).isError()) { if (tables.get(i).isError()) {
reportError(tables.get(i).getLocation(),
"Problem in table: '" + tables.get(i).getName());
errors += 1; errors += 1;
} }
if (tables.get(i).getPattern() == null) { if (tables.get(i).getPattern() == null) {