Support variable declarations without an assignment in EVM

This commit is contained in:
Alex Beregszaszi 2017-07-02 11:21:34 +01:00
parent cee93d946d
commit 03abf792c5

View File

@ -37,10 +37,19 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl)
{ {
solAssert(m_scope, ""); solAssert(m_scope, "");
int expectedItems = _varDecl.variables.size(); int const expectedItems = _varDecl.variables.size();
int height = m_assembly.stackHeight(); int height = m_assembly.stackHeight();
boost::apply_visitor(*this, *_varDecl.value); if (_varDecl.value)
expectDeposit(expectedItems, height); {
boost::apply_visitor(*this, *_varDecl.value);
expectDeposit(expectedItems, height);
}
else
{
int variablesLeft = expectedItems;
while (variablesLeft--)
m_assembly.appendConstant(u256(0));
}
for (auto const& variable: _varDecl.variables) for (auto const& variable: _varDecl.variables)
{ {
auto& var = boost::get<Scope::Variable>(m_scope->identifiers.at(variable.name)); auto& var = boost::get<Scope::Variable>(m_scope->identifiers.at(variable.name));