LLL: throw exceptions on invalid symbols

This commit is contained in:
Alex Beregszaszi 2016-11-01 02:07:20 +00:00
parent 99b803cbcb
commit b1add657b7

View File

@ -91,15 +91,11 @@ CodeFragment::CodeFragment(sp::utree const& _t, CompilerState& _s, bool _allowAS
{ {
auto it = _s.vars.find(s); auto it = _s.vars.find(s);
if (it == _s.vars.end()) if (it == _s.vars.end())
{ error<InvalidName>(std::string("Symbol not found: ") + s);
bool ok;
tie(it, ok) = _s.vars.insert(make_pair(s, make_pair(_s.stackSize, 32)));
_s.stackSize += 32;
}
m_asm.append((u256)it->second.first); m_asm.append((u256)it->second.first);
} }
else else
error<BareSymbol>(); error<BareSymbol>(s);
break; break;
} }
@ -111,7 +107,9 @@ CodeFragment::CodeFragment(sp::utree const& _t, CompilerState& _s, bool _allowAS
m_asm.append((u256)i); m_asm.append((u256)i);
break; break;
} }
default: break; default:
error<CompilerException>("Unexpected fragment type");
break;
} }
} }
@ -177,11 +175,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
{ {
auto it = _s.vars.find(n); auto it = _s.vars.find(n);
if (it == _s.vars.end()) if (it == _s.vars.end())
{ error<InvalidName>(std::string("Symbol not found: ") + s);
bool ok;
tie(it, ok) = _s.vars.insert(make_pair(n, make_pair(_s.stackSize, 32)));
_s.stackSize += 32;
}
return it->second.first; return it->second.first;
}; };