aboutsummaryrefslogtreecommitdiffstats
path: root/CompilerUtils.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-12-09 05:18:19 +0800
committerChristian <c@ethdev.com>2014-12-09 05:26:22 +0800
commit35d5b28faeee5e19d0dbbeb3c75454249d636abd (patch)
tree227b04a23f5d66e442fc824e4cfcbba802989ccd /CompilerUtils.cpp
parentb7d856ed5fee1f0f918e30218e3a95fd8fc20dd3 (diff)
downloaddexon-solidity-35d5b28faeee5e19d0dbbeb3c75454249d636abd.tar.gz
dexon-solidity-35d5b28faeee5e19d0dbbeb3c75454249d636abd.tar.zst
dexon-solidity-35d5b28faeee5e19d0dbbeb3c75454249d636abd.zip
Variable-size stack elements for expression compiler.
Diffstat (limited to 'CompilerUtils.cpp')
-rw-r--r--CompilerUtils.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/CompilerUtils.cpp b/CompilerUtils.cpp
index b3d982c9..cbd92d2b 100644
--- a/CompilerUtils.cpp
+++ b/CompilerUtils.cpp
@@ -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;
+}
+
}
}