|
|
@ -109,8 +109,8 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract) |
|
|
|
callDataUnpackerEntryPoints.push_back(m_context.newTag()); |
|
|
|
m_context << eth::dupInstruction(2) << eth::dupInstruction(2) << eth::Instruction::EQ; |
|
|
|
m_context.appendConditionalJumpTo(callDataUnpackerEntryPoints.back()); |
|
|
|
m_context << eth::dupInstruction(4) << eth::Instruction::ADD; |
|
|
|
//@todo avoid the last ADD (or remove it in the optimizer)
|
|
|
|
if (funid < interfaceFunctions.size() - 1) |
|
|
|
m_context << eth::dupInstruction(4) << eth::Instruction::ADD; |
|
|
|
} |
|
|
|
m_context << eth::Instruction::STOP; // function not found
|
|
|
|
|
|
|
@ -241,7 +241,7 @@ bool Compiler::visit(FunctionDefinition const& _function) |
|
|
|
|
|
|
|
bool Compiler::visit(IfStatement const& _ifStatement) |
|
|
|
{ |
|
|
|
ExpressionCompiler::compileExpression(m_context, _ifStatement.getCondition()); |
|
|
|
compileExpression(_ifStatement.getCondition()); |
|
|
|
eth::AssemblyItem trueTag = m_context.appendConditionalJump(); |
|
|
|
if (_ifStatement.getFalseStatement()) |
|
|
|
_ifStatement.getFalseStatement()->accept(*this); |
|
|
@ -260,7 +260,7 @@ bool Compiler::visit(WhileStatement const& _whileStatement) |
|
|
|
m_breakTags.push_back(loopEnd); |
|
|
|
|
|
|
|
m_context << loopStart; |
|
|
|
ExpressionCompiler::compileExpression(m_context, _whileStatement.getCondition()); |
|
|
|
compileExpression(_whileStatement.getCondition()); |
|
|
|
m_context << eth::Instruction::ISZERO; |
|
|
|
m_context.appendConditionalJumpTo(loopEnd); |
|
|
|
|
|
|
@ -293,7 +293,7 @@ bool Compiler::visit(Return const& _return) |
|
|
|
//@todo modifications are needed to make this work with functions returning multiple values
|
|
|
|
if (Expression const* expression = _return.getExpression()) |
|
|
|
{ |
|
|
|
ExpressionCompiler::compileExpression(m_context, *expression); |
|
|
|
compileExpression(*expression); |
|
|
|
VariableDeclaration const& firstVariable = *_return.getFunctionReturnParameters().getParameters().front(); |
|
|
|
ExpressionCompiler::appendTypeConversion(m_context, *expression->getType(), *firstVariable.getType()); |
|
|
|
|
|
|
@ -307,7 +307,7 @@ bool Compiler::visit(VariableDefinition const& _variableDefinition) |
|
|
|
{ |
|
|
|
if (Expression const* expression = _variableDefinition.getExpression()) |
|
|
|
{ |
|
|
|
ExpressionCompiler::compileExpression(m_context, *expression); |
|
|
|
compileExpression(*expression); |
|
|
|
ExpressionCompiler::appendTypeConversion(m_context, |
|
|
|
*expression->getType(), |
|
|
|
*_variableDefinition.getDeclaration().getType()); |
|
|
@ -319,10 +319,15 @@ bool Compiler::visit(VariableDefinition const& _variableDefinition) |
|
|
|
bool Compiler::visit(ExpressionStatement const& _expressionStatement) |
|
|
|
{ |
|
|
|
Expression const& expression = _expressionStatement.getExpression(); |
|
|
|
ExpressionCompiler::compileExpression(m_context, expression); |
|
|
|
compileExpression(expression); |
|
|
|
CompilerUtils(m_context).popStackElement(*expression.getType()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
void Compiler::compileExpression(Expression const& _expression) |
|
|
|
{ |
|
|
|
ExpressionCompiler::compileExpression(m_context, _expression, m_optimize); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|