aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-17 00:33:13 +0800
committerChristian <c@ethdev.com>2015-02-17 02:35:53 +0800
commita33fa270f689168f84c0db6aa673658ae92fb495 (patch)
tree7a7916674b8dd8deef8276887f98e8a1d4dc6a03 /ExpressionCompiler.cpp
parent971cc9b5b9242f36c1fa288615e2bf2d762fbd52 (diff)
downloaddexon-solidity-a33fa270f689168f84c0db6aa673658ae92fb495.tar.gz
dexon-solidity-a33fa270f689168f84c0db6aa673658ae92fb495.tar.zst
dexon-solidity-a33fa270f689168f84c0db6aa673658ae92fb495.zip
Calldata byte arrays stored on the stack.
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r--ExpressionCompiler.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 7128459a..3bf1c8c9 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -475,9 +475,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
else if (member == "gasprice")
m_context << eth::Instruction::GASPRICE;
else if (member == "data")
- {
- // nothing to store on the stack
- }
+ m_context << u256(0) << eth::Instruction::CALLDATASIZE;
else
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown magic member."));
break;
@@ -510,6 +508,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
m_context << m_context.getFunctionEntryLabel(*function).pushTag();
return;
}
+ solAssert(false, "Function not found in member access.");
}
else if (auto enumType = dynamic_cast<EnumType const*>(type.getActualType().get()))
m_context << enumType->getMemberValue(_memberAccess.getMemberName());
@@ -518,7 +517,19 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
case Type::Category::ByteArray:
{
solAssert(member == "length", "Illegal bytearray member.");
- m_context << eth::Instruction::SLOAD;
+ auto const& type = dynamic_cast<ByteArrayType const&>(*_memberAccess.getExpression().getType());
+ switch (type.getLocation())
+ {
+ case ByteArrayType::Location::CallData:
+ m_context << eth::Instruction::SWAP1 << eth::Instruction::POP;
+ break;
+ case ByteArrayType::Location::Storage:
+ m_context << eth::Instruction::SLOAD;
+ break;
+ default:
+ solAssert(false, "Unsupported byte array location.");
+ break;
+ }
break;
}
default: