mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Variable-size stack elements for expression compiler.
This commit is contained in:
@@ -35,6 +35,9 @@ void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable)
|
||||
{
|
||||
unsigned const stackPosition = m_context.baseToCurrentStackOffset(m_context.getBaseStackOffsetOfVariable(_variable));
|
||||
unsigned const size = _variable.getType()->getSizeOnStack();
|
||||
if (stackPosition - size + 1 > 16)
|
||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_sourceLocation(_variable.getLocation())
|
||||
<< errinfo_comment("Stack too deep."));
|
||||
for (unsigned i = 0; i < size; ++i)
|
||||
m_context << eth::swapInstruction(stackPosition - size + 1) << eth::Instruction::POP;
|
||||
}
|
||||
@@ -46,5 +49,13 @@ void CompilerUtils::popStackElement(Type const& _type)
|
||||
m_context << eth::Instruction::POP;
|
||||
}
|
||||
|
||||
unsigned CompilerUtils::getSizeOnStack(vector<shared_ptr<Type const>> const& _variableTypes)
|
||||
{
|
||||
unsigned size = 0;
|
||||
for (shared_ptr<Type const> const& type: _variableTypes)
|
||||
size += type->getSizeOnStack();
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user