aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r--ExpressionCompiler.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 461dfef1..94f65b93 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -530,20 +530,21 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
m_context << enumType->getMemberValue(_memberAccess.getMemberName());
break;
}
- case Type::Category::ByteArray:
+ case Type::Category::Array:
{
- solAssert(member == "length", "Illegal bytearray member.");
- auto const& type = dynamic_cast<ByteArrayType const&>(*_memberAccess.getExpression().getType());
+ solAssert(member == "length", "Illegal array member.");
+ auto const& type = dynamic_cast<ArrayType const&>(*_memberAccess.getExpression().getType());
+ solAssert(type.isByteArray(), "Non byte arrays not yet implemented here.");
switch (type.getLocation())
{
- case ByteArrayType::Location::CallData:
+ case ArrayType::Location::CallData:
m_context << eth::Instruction::SWAP1 << eth::Instruction::POP;
break;
- case ByteArrayType::Location::Storage:
+ case ArrayType::Location::Storage:
m_context << eth::Instruction::SLOAD;
break;
default:
- solAssert(false, "Unsupported byte array location.");
+ solAssert(false, "Unsupported array location.");
break;
}
break;
@@ -561,7 +562,8 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
solAssert(baseType.getCategory() == Type::Category::Mapping, "");
Type const& keyType = *dynamic_cast<MappingType const&>(baseType).getKeyType();
m_context << u256(0);
- appendExpressionCopyToMemory(keyType, _indexAccess.getIndexExpression());
+ solAssert(_indexAccess.getIndexExpression(), "Index expression expected.");
+ appendExpressionCopyToMemory(keyType, *_indexAccess.getIndexExpression());
solAssert(baseType.getSizeOnStack() == 1,
"Unexpected: Not exactly one stack slot taken by subscriptable expression.");
m_context << eth::Instruction::SWAP1;
@@ -1135,11 +1137,11 @@ void ExpressionCompiler::LValue::storeValue(Type const& _sourceType, Location co
else
{
solAssert(_sourceType.getCategory() == m_dataType->getCategory(), "Wrong type conversation for assignment.");
- if (m_dataType->getCategory() == Type::Category::ByteArray)
+ if (m_dataType->getCategory() == Type::Category::Array)
{
CompilerUtils(*m_context).copyByteArrayToStorage(
- dynamic_cast<ByteArrayType const&>(*m_dataType),
- dynamic_cast<ByteArrayType const&>(_sourceType));
+ dynamic_cast<ArrayType const&>(*m_dataType),
+ dynamic_cast<ArrayType const&>(_sourceType));
if (_move)
*m_context << eth::Instruction::POP;
}
@@ -1210,8 +1212,8 @@ void ExpressionCompiler::LValue::setToZero(Location const& _location) const
break;
}
case LValueType::Storage:
- if (m_dataType->getCategory() == Type::Category::ByteArray)
- CompilerUtils(*m_context).clearByteArray(dynamic_cast<ByteArrayType const&>(*m_dataType));
+ if (m_dataType->getCategory() == Type::Category::Array)
+ CompilerUtils(*m_context).clearByteArray(dynamic_cast<ArrayType const&>(*m_dataType));
else if (m_dataType->getCategory() == Type::Category::Struct)
{
// stack layout: ref