aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ExpressionCompiler.cpp22
-rw-r--r--LValue.cpp13
2 files changed, 20 insertions, 15 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 7ddcc031..59907b14 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -679,10 +679,24 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
case Type::Category::Struct:
{
StructType const& type = dynamic_cast<StructType const&>(*_memberAccess.getExpression().getType());
- m_context << eth::Instruction::POP; // structs always align to new slot
- pair<u256, unsigned> const& offsets = type.getStorageOffsetsOfMember(member);
- m_context << offsets.first << eth::Instruction::ADD << u256(offsets.second);
- setLValueToStorageItem(_memberAccess);
+ switch (type.location())
+ {
+ case DataLocation::Storage:
+ {
+ m_context << eth::Instruction::POP; // structs always align to new slot
+ pair<u256, unsigned> const& offsets = type.getStorageOffsetsOfMember(member);
+ m_context << offsets.first << eth::Instruction::ADD << u256(offsets.second);
+ setLValueToStorageItem(_memberAccess);
+ break;
+ }
+ case DataLocation::Memory:
+ {
+ solAssert(false, "Member access for memory structs not yet implemented.");
+ break;
+ }
+ default:
+ solAssert(false, "Illegal data location for struct.");
+ }
break;
}
case Type::Category::Enum:
diff --git a/LValue.cpp b/LValue.cpp
index cf640e91..7eec478b 100644
--- a/LValue.cpp
+++ b/LValue.cpp
@@ -69,17 +69,8 @@ void StackVariable::storeValue(Type const&, SourceLocation const& _location, boo
void StackVariable::setToZero(SourceLocation const& _location, bool) const
{
- unsigned stackDiff = m_context.baseToCurrentStackOffset(m_baseStackOffset);
- if (stackDiff > 16)
- BOOST_THROW_EXCEPTION(
- CompilerError() <<
- errinfo_sourceLocation(_location) <<
- errinfo_comment("Stack too deep, try removing local variables.")
- );
- solAssert(stackDiff >= m_size - 1, "");
- for (unsigned i = 0; i < m_size; ++i)
- m_context << u256(0) << eth::swapInstruction(stackDiff + 1 - i)
- << eth::Instruction::POP;
+ CompilerUtils(m_context).pushZeroValue(m_dataType);
+ storeValue(m_dataType, _location, true);
}
MemoryItem::MemoryItem(CompilerContext& _compilerContext, Type const& _type, bool _padded):