aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-01-27 23:55:06 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-01-29 04:46:16 +0800
commit2947e038d28d3d732b1db352f71c8c9669df8eef (patch)
treed7ce1854e21c124b8af1ebcc300e04bda39890e1 /ExpressionCompiler.cpp
parentff91ab96ea843bd8ab9a7c57fd799add2ebc9873 (diff)
downloaddexon-solidity-2947e038d28d3d732b1db352f71c8c9669df8eef.tar.gz
dexon-solidity-2947e038d28d3d732b1db352f71c8c9669df8eef.tar.zst
dexon-solidity-2947e038d28d3d732b1db352f71c8c9669df8eef.zip
EVM Code for simple accessor function is properly generated
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r--ExpressionCompiler.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 450cc2fe..66e2c68c 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -48,6 +48,12 @@ void ExpressionCompiler::appendTypeConversion(CompilerContext& _context, Type co
compiler.appendTypeConversion(_typeOnStack, _targetType, _cleanupNeeded);
}
+void ExpressionCompiler::appendStateVariableAccessor(CompilerContext& _context, VariableDeclaration const* _varDecl, bool _optimize)
+{
+ ExpressionCompiler compiler(_context, _optimize);
+ compiler.appendStateVariableAccessor(_varDecl);
+}
+
bool ExpressionCompiler::visit(Assignment const& _assignment)
{
_assignment.getRightHandSide().accept(*this);
@@ -792,8 +798,7 @@ unsigned ExpressionCompiler::appendArgumentCopyToMemory(TypePointers const& _typ
void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const* _varDecl)
{
m_currentLValue.fromStateVariable(*_varDecl, _varDecl->getType());
- // TODO
- // m_currentLValue.retrieveValueFromStorage();
+ m_currentLValue.retrieveValueFromStorage(_varDecl->getType(), true);
}
ExpressionCompiler::LValue::LValue(CompilerContext& _compilerContext, LValueType _type, Type const& _dataType,
@@ -823,7 +828,7 @@ void ExpressionCompiler::LValue::retrieveValue(Expression const& _expression, bo
break;
}
case STORAGE:
- retrieveValueFromStorage(_expression, _remove);
+ retrieveValueFromStorage(_expression.getType(), _remove);
break;
case MEMORY:
if (!_expression.getType()->isValueType())
@@ -838,9 +843,9 @@ void ExpressionCompiler::LValue::retrieveValue(Expression const& _expression, bo
}
}
-void ExpressionCompiler::LValue::retrieveValueFromStorage(Expression const& _expression, bool _remove) const
+void ExpressionCompiler::LValue::retrieveValueFromStorage(std::shared_ptr<Type const> const& _type, bool _remove) const
{
- if (!_expression.getType()->isValueType())
+ if (!_type->isValueType())
return; // no distinction between value and reference for non-value types
if (!_remove)
*m_context << eth::Instruction::DUP1;