aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerUtils.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-10-18 20:53:45 +0800
committerGitHub <noreply@github.com>2017-10-18 20:53:45 +0800
commit9cf6e910bd2b90d0c9415d9c257f85fe0c518de8 (patch)
tree6423baec5e26bbe174005c1a89d978cae15015d8 /libsolidity/codegen/CompilerUtils.cpp
parentbdeb9e52a2211510644fb53df93fb98258b40a65 (diff)
parentc85c41880ad1c996517b0ae14f98678b1e6c5613 (diff)
downloaddexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar
dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.gz
dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.bz2
dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.lz
dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.xz
dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.zst
dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.zip
Merge pull request #3099 from ethereum/develop
Merge develop into release for 0.4.18.
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 37aa1aea..f9b181ae 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -191,7 +191,7 @@ void CompilerUtils::encodeToMemory(
{
// Use the new JULIA-based encoding function
auto stackHeightBefore = m_context.stackHeight();
- abiEncode(_givenTypes, targetTypes, _encodeAsLibraryTypes);
+ abiEncodeV2(_givenTypes, targetTypes, _encodeAsLibraryTypes);
solAssert(stackHeightBefore - m_context.stackHeight() == sizeOnStack(_givenTypes), "");
return;
}
@@ -302,7 +302,7 @@ void CompilerUtils::encodeToMemory(
popStackSlots(argSize + dynPointers + 1);
}
-void CompilerUtils::abiEncode(
+void CompilerUtils::abiEncodeV2(
TypePointers const& _givenTypes,
TypePointers const& _targetTypes,
bool _encodeAsLibraryTypes
@@ -541,7 +541,7 @@ void CompilerUtils::convertType(
else
{
solAssert(targetTypeCategory == Type::Category::Integer || targetTypeCategory == Type::Category::Contract, "");
- IntegerType addressType(0, IntegerType::Modifier::Address);
+ IntegerType addressType(160, IntegerType::Modifier::Address);
IntegerType const& targetType = targetTypeCategory == Type::Category::Integer
? dynamic_cast<IntegerType const&>(_targetType) : addressType;
if (stackTypeCategory == Type::Category::RationalNumber)
@@ -596,7 +596,6 @@ void CompilerUtils::convertType(
storeInMemoryDynamic(IntegerType(256));
// stack: mempos datapos
storeStringData(data);
- break;
}
else
solAssert(
@@ -810,9 +809,8 @@ void CompilerUtils::convertType(
if (_cleanupNeeded)
m_context << Instruction::ISZERO << Instruction::ISZERO;
break;
- case Type::Category::Function:
- {
- if (targetTypeCategory == Type::Category::Integer)
+ default:
+ if (stackTypeCategory == Type::Category::Function && targetTypeCategory == Type::Category::Integer)
{
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_targetType);
solAssert(targetType.isAddress(), "Function type can only be converted to address.");
@@ -821,17 +819,16 @@ void CompilerUtils::convertType(
// stack: <address> <function_id>
m_context << Instruction::POP;
- break;
}
- }
- // fall-through
- default:
- // All other types should not be convertible to non-equal types.
- solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
- if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
+ else
+ {
+ // All other types should not be convertible to non-equal types.
+ solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
+ if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
m_context
<< ((u256(1) << (8 * _targetType.storageBytes())) - 1)
<< Instruction::AND;
+ }
break;
}