diff options
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index b0e92b59..040217da 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -219,25 +219,46 @@ bool ExpressionCompiler::visit(Assignment const& _assignment) bool ExpressionCompiler::visit(TupleExpression const& _tuple) { - vector<unique_ptr<LValue>> lvalues; - for (auto const& component: _tuple.components()) - if (component) + if (_tuple.isInlineArray()) + { + ArrayType const& arrayType = dynamic_cast<ArrayType const&>(*_tuple.annotation().type); + + solAssert(!arrayType.isDynamicallySized(), "Cannot create dynamically sized inline array."); + m_context << max(u256(32u), arrayType.memorySize()); + utils().allocateMemory(); + m_context << eth::Instruction::DUP1; + + for (auto const& component: _tuple.components()) { component->accept(*this); - if (_tuple.annotation().lValueRequested) + utils().convertType(*component->annotation().type, *arrayType.baseType(), true); + utils().storeInMemoryDynamic(*arrayType.baseType(), true); + } + + m_context << eth::Instruction::POP; + } + else + { + vector<unique_ptr<LValue>> lvalues; + for (auto const& component: _tuple.components()) + if (component) { - solAssert(!!m_currentLValue, ""); - lvalues.push_back(move(m_currentLValue)); + component->accept(*this); + if (_tuple.annotation().lValueRequested) + { + solAssert(!!m_currentLValue, ""); + lvalues.push_back(move(m_currentLValue)); + } } + else if (_tuple.annotation().lValueRequested) + lvalues.push_back(unique_ptr<LValue>()); + if (_tuple.annotation().lValueRequested) + { + if (_tuple.components().size() == 1) + m_currentLValue = move(lvalues[0]); + else + m_currentLValue.reset(new TupleObject(m_context, move(lvalues))); } - else if (_tuple.annotation().lValueRequested) - lvalues.push_back(unique_ptr<LValue>()); - if (_tuple.annotation().lValueRequested) - { - if (_tuple.components().size() == 1) - m_currentLValue = move(lvalues[0]); - else - m_currentLValue.reset(new TupleObject(m_context, move(lvalues))); } return false; } @@ -774,7 +795,6 @@ bool ExpressionCompiler::visit(NewExpression const&) void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) { CompilerContext::LocationSetter locationSetter(m_context, _memberAccess); - // Check whether the member is a bound function. ASTString const& member = _memberAccess.memberName(); if (auto funType = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get())) @@ -787,7 +807,6 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) ); auto contract = dynamic_cast<ContractDefinition const*>(funType->declaration().scope()); solAssert(contract && contract->isLibrary(), ""); - //@TODO library name might not be unique m_context.appendLibraryAddress(contract->name()); m_context << funType->externalIdentifier(); utils().moveIntoStack(funType->selfType()->sizeOnStack(), 2); @@ -1098,7 +1117,6 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) else if (auto contract = dynamic_cast<ContractDefinition const*>(declaration)) { if (contract->isLibrary()) - //@todo name should be unique, change once we have module management m_context.appendLibraryAddress(contract->name()); } else if (dynamic_cast<EventDefinition const*>(declaration)) @@ -1123,6 +1141,7 @@ void ExpressionCompiler::endVisit(Literal const& _literal) { CompilerContext::LocationSetter locationSetter(m_context, _literal); TypePointer type = _literal.annotation().type; + switch (type->category()) { case Type::Category::IntegerConstant: |