diff options
author | Christian <c@ethdev.com> | 2014-12-09 01:52:30 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-09 02:02:40 +0800 |
commit | b7d856ed5fee1f0f918e30218e3a95fd8fc20dd3 (patch) | |
tree | a0a1d0cc8dc143b14893b8d7aefa66a838a812cd /Compiler.cpp | |
parent | 9b68033efc40b11b7778fbdb43325ba4ad196f1c (diff) | |
download | dexon-solidity-b7d856ed5fee1f0f918e30218e3a95fd8fc20dd3.tar.gz dexon-solidity-b7d856ed5fee1f0f918e30218e3a95fd8fc20dd3.tar.zst dexon-solidity-b7d856ed5fee1f0f918e30218e3a95fd8fc20dd3.zip |
Changes in compiler to support variably sized stack elements.
Diffstat (limited to 'Compiler.cpp')
-rw-r--r-- | Compiler.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Compiler.cpp b/Compiler.cpp index 7e0f4ca1..e7263da6 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -26,6 +26,7 @@ #include <libsolidity/AST.h> #include <libsolidity/Compiler.h> #include <libsolidity/ExpressionCompiler.h> +#include <libsolidity/CompilerUtils.h> using namespace std; @@ -135,7 +136,7 @@ unsigned Compiler::appendCalldataUnpacker(FunctionDefinition const& _function, b for (ASTPointer<VariableDeclaration> const& var: _function.getParameters()) { unsigned const numBytes = var->getType()->getCalldataEncodedSize(); - if (numBytes == 0) + if (numBytes == 0 || numBytes > 32) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_sourceLocation(var->getLocation()) << errinfo_comment("Type " + var->getType()->toString() + " not yet supported.")); @@ -158,7 +159,7 @@ void Compiler::appendReturnValuePacker(FunctionDefinition const& _function) { Type const& paramType = *parameters[i]->getType(); unsigned numBytes = paramType.getCalldataEncodedSize(); - if (numBytes == 0) + if (numBytes == 0 || numBytes > 32) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_sourceLocation(parameters[i]->getLocation()) << errinfo_comment("Type " + paramType.toString() + " not yet supported.")); @@ -305,8 +306,7 @@ bool Compiler::visit(Return& _return) VariableDeclaration const& firstVariable = *_return.getFunctionReturnParameters().getParameters().front(); ExpressionCompiler::appendTypeConversion(m_context, *expression->getType(), *firstVariable.getType()); - unsigned stackPosition = m_context.baseToCurrentStackOffset(m_context.getBaseStackOffsetOfVariable(firstVariable)); - m_context << eth::swapInstruction(stackPosition) << eth::Instruction::POP; + CompilerUtils(m_context).moveToStackVariable(firstVariable); } m_context.appendJumpTo(m_returnTag); return false; @@ -320,9 +320,7 @@ bool Compiler::visit(VariableDefinition& _variableDefinition) ExpressionCompiler::appendTypeConversion(m_context, *expression->getType(), *_variableDefinition.getDeclaration().getType()); - unsigned baseStackOffset = m_context.getBaseStackOffsetOfVariable(_variableDefinition.getDeclaration()); - unsigned stackPosition = m_context.baseToCurrentStackOffset(baseStackOffset); - m_context << eth::swapInstruction(stackPosition) << eth::Instruction::POP; + CompilerUtils(m_context).moveToStackVariable(_variableDefinition.getDeclaration()); } return false; } @@ -331,9 +329,7 @@ bool Compiler::visit(ExpressionStatement& _expressionStatement) { Expression& expression = _expressionStatement.getExpression(); ExpressionCompiler::compileExpression(m_context, expression); -// Type::Category category = expression.getType()->getCategory(); - for (unsigned i = 0; i < expression.getType()->getSizeOnStack(); ++i) - m_context << eth::Instruction::POP; + CompilerUtils(m_context).popStackElement(*expression.getType()); return false; } |