aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-14 20:13:37 +0800
committerchriseth <c@ethdev.com>2016-11-16 21:37:19 +0800
commitec31d08775021de0f3279dbeb115b3e688c5997e (patch)
tree32f8d14735ffd15f7fb2c7ca5b8498cc1bab8748 /libsolidity/codegen
parenta8e7ed37a10f9dd43bfc57db7733412503c1a24e (diff)
downloaddexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.tar
dexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.tar.gz
dexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.tar.bz2
dexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.tar.lz
dexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.tar.xz
dexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.tar.zst
dexon-solidity-ec31d08775021de0f3279dbeb115b3e688c5997e.zip
Change encoding to address-funid and add "function" as ABI type.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp31
-rw-r--r--libsolidity/codegen/CompilerUtils.h2
2 files changed, 19 insertions, 14 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 1e21c020..1e819ed4 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -317,27 +317,32 @@ void CompilerUtils::memoryCopy()
void CompilerUtils::splitExternalFunctionType(bool _leftAligned)
{
- // We have to split the left-aligned <function identifier><address> into two stack slots:
+ // We have to split the left-aligned <address><function identifier> into two stack slots:
// address (right aligned), function identifier (right aligned)
if (_leftAligned)
- m_context << (u256(1) << 64) << Instruction::SWAP1 << Instruction::DIV;
- m_context << Instruction::DUP1 << ((u256(1) << 160) - 1) << Instruction::AND << Instruction::SWAP1;
- m_context << (u256(1) << 160) << Instruction::SWAP1 << Instruction::DIV;
- if (!_leftAligned)
- m_context << u256(0xffffffffUL) << Instruction::AND;
+ {
+ m_context << Instruction::DUP1 << (u256(1) << (64 + 32)) << Instruction::SWAP1 << Instruction::DIV;
+ // <input> <address>
+ m_context << Instruction::SWAP1 << (u256(1) << 64) << Instruction::SWAP1 << Instruction::DIV;
+ }
+ else
+ {
+ m_context << Instruction::DUP1 << (u256(1) << 32) << Instruction::SWAP1 << Instruction::DIV;
+ m_context << ((u256(1) << 160) - 1) << Instruction::AND << Instruction::SWAP1;
+ }
+ m_context << u256(0xffffffffUL) << Instruction::AND;
}
void CompilerUtils::combineExternalFunctionType(bool _leftAligned)
{
- if (_leftAligned)
- m_context << (u256(1) << 224);
- else
- m_context << u256(0xffffffffUL) << Instruction::AND << (u256(1) << 160);
- m_context << Instruction::MUL << Instruction::SWAP1;
- m_context << ((u256(1) << 160) - 1) << Instruction::AND;
+ // <address> <function_id>
+ m_context << u256(0xffffffffUL) << Instruction::AND << Instruction::SWAP1;
+ if (!_leftAligned)
+ m_context << ((u256(1) << 160) - 1) << Instruction::AND;
+ m_context << (u256(1) << 32) << Instruction::MUL;
+ m_context << Instruction::OR;
if (_leftAligned)
m_context << (u256(1) << 64) << Instruction::MUL;
- m_context << Instruction::OR;
}
void CompilerUtils::pushCombinedFunctionEntryLabel(Declaration const& _function)
diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h
index 2ebec81a..8e4033d6 100644
--- a/libsolidity/codegen/CompilerUtils.h
+++ b/libsolidity/codegen/CompilerUtils.h
@@ -115,7 +115,7 @@ public:
void memoryCopy();
/// Converts the combined and left-aligned (right-aligned if @a _rightAligned is true)
- /// external function type <function identifier><address> into two stack slots:
+ /// external function type <address><function identifier> into two stack slots:
/// address (right aligned), function identifier (right aligned)
void splitExternalFunctionType(bool _rightAligned);
/// Performs the opposite operation of splitExternalFunctionType(_rightAligned)