aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/CompilerUtils.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-15 06:42:36 +0800
committerchriseth <c@ethdev.com>2015-10-15 23:38:42 +0800
commit029b8194892b6b08ce70075bd66f43f66c40e301 (patch)
tree3cce6cff28599d09ce612633c2d13d76ebe9e7da /libsolidity/CompilerUtils.cpp
parent039b2a764f3944768bb253102f4c4b788f2dca9c (diff)
downloaddexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.tar
dexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.tar.gz
dexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.tar.bz2
dexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.tar.lz
dexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.tar.xz
dexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.tar.zst
dexon-solidity-029b8194892b6b08ce70075bd66f43f66c40e301.zip
Wildcards.
Diffstat (limited to 'libsolidity/CompilerUtils.cpp')
-rw-r--r--libsolidity/CompilerUtils.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/libsolidity/CompilerUtils.cpp b/libsolidity/CompilerUtils.cpp
index 34bb08ba..f0dea708 100644
--- a/libsolidity/CompilerUtils.cpp
+++ b/libsolidity/CompilerUtils.cpp
@@ -552,29 +552,37 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
}
case Type::Category::Tuple:
{
- //@TODO wildcards
TupleType const& sourceTuple = dynamic_cast<TupleType const&>(_typeOnStack);
TupleType const& targetTuple = dynamic_cast<TupleType const&>(_targetType);
- solAssert(sourceTuple.components().size() == targetTuple.components().size(), "");
+ // fillRight: remove excess values at right side, !fillRight: remove eccess values at left side
+ bool fillRight = !targetTuple.components().empty() && (
+ !targetTuple.components().back() ||
+ targetTuple.components().front()
+ );
unsigned depth = sourceTuple.sizeOnStack();
for (size_t i = 0; i < sourceTuple.components().size(); ++i)
{
- TypePointer const& sourceType = sourceTuple.components()[i];
- TypePointer const& targetType = targetTuple.components()[i];
+ TypePointer sourceType = sourceTuple.components()[i];
+ TypePointer targetType;
+ if (fillRight && i < targetTuple.components().size())
+ targetType = targetTuple.components()[i];
+ else if (!fillRight && targetTuple.components().size() + i >= sourceTuple.components().size())
+ targetType = targetTuple.components()[targetTuple.components().size() - (sourceTuple.components().size() - i)];
if (!sourceType)
{
solAssert(!targetType, "");
continue;
}
unsigned sourceSize = sourceType->sizeOnStack();
- unsigned targetSize = targetType->sizeOnStack();
- if (*sourceType != *targetType || _cleanupNeeded)
+ unsigned targetSize = targetType ? targetType->sizeOnStack() : 0;
+ if (!targetType || *sourceType != *targetType || _cleanupNeeded)
{
- if (sourceSize > 0)
- copyToStackTop(depth, sourceSize);
-
- convertType(*sourceType, *targetType, _cleanupNeeded);
-
+ if (targetType)
+ {
+ if (sourceSize > 0)
+ copyToStackTop(depth, sourceSize);
+ convertType(*sourceType, *targetType, _cleanupNeeded);
+ }
if (sourceSize > 0 || targetSize > 0)
{
// Move it back into its place.
@@ -582,8 +590,6 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
m_context <<
eth::swapInstruction(depth + targetSize - sourceSize) <<
eth::Instruction::POP;
- if (targetSize < sourceSize)
- moveToStackTop(sourceSize - targetSize, depth );
// Value shrank
for (unsigned j = targetSize; j < sourceSize; ++j)
{