aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-01-09 00:18:31 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-01-09 00:18:31 +0800
commit184ddca5a108c5f3d026aa372a2af2f63b2694f9 (patch)
tree13dfa78ad1dbaa6fa83e83bf82d5fbdb78288de4 /ExpressionCompiler.cpp
parent68b94275354e5715cea37ccbca18eb2a4b42704e (diff)
downloaddexon-solidity-184ddca5a108c5f3d026aa372a2af2f63b2694f9.tar.gz
dexon-solidity-184ddca5a108c5f3d026aa372a2af2f63b2694f9.tar.zst
dexon-solidity-184ddca5a108c5f3d026aa372a2af2f63b2694f9.zip
Compiler EVM generation now takes into account for the new function hash
identifier - Changed tests to comply with the new function hash identifier - Changed the function index offset to 4, and made it a constant for easy adjustment in the future
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r--ExpressionCompiler.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 6bf14f55..5fefd528 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -335,7 +335,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
case Type::Category::CONTRACT:
{
ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.getExpression().getType());
- m_context << type.getFunctionIndex(member);
+ m_context << type.getFunctionIdentifier(member);
break;
}
case Type::Category::MAGIC:
@@ -590,7 +590,11 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio
{
solAssert(_arguments.size() == _functionType.getParameterTypes().size(), "");
- unsigned dataOffset = _options.bare ? 0 : 1; // reserve one byte for the function index
+ _options.obtainAddress();
+ if (!_options.bare)
+ CompilerUtils(m_context).storeInMemory(0, g_functionIdentifierOffset);
+
+ unsigned dataOffset = _options.bare ? 0 : g_functionIdentifierOffset; // reserve 4 bytes for the function's hash identifier
for (unsigned i = 0; i < _arguments.size(); ++i)
{
_arguments[i]->accept(*this);
@@ -617,12 +621,13 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio
_options.obtainValue();
else
m_context << u256(0);
- _options.obtainAddress();
- if (!_options.bare)
- m_context << u256(0) << eth::Instruction::MSTORE8;
+ m_context << eth::dupInstruction(6); //copy contract address
+
m_context << u256(25) << eth::Instruction::GAS << eth::Instruction::SUB
<< eth::Instruction::CALL
- << eth::Instruction::POP; // @todo do not ignore failure indicator
+ << eth::Instruction::POP // @todo do not ignore failure indicator
+ << eth::Instruction::POP; // pop contract address
+
if (retSize > 0)
{
bool const leftAligned = firstType->getCategory() == Type::Category::STRING;