diff options
author | chriseth <c@ethdev.com> | 2015-10-10 02:44:56 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-13 18:16:23 +0800 |
commit | deebc7e8601185006b74a5ee78b83c50bdf37abc (patch) | |
tree | fcd4f68acc0ca65e10e16eba170bc89180ea9468 /libsolidity/Compiler.cpp | |
parent | a5d12b876180088904a026c472da23201a35d59c (diff) | |
download | dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.gz dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.bz2 dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.lz dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.xz dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.tar.zst dexon-solidity-deebc7e8601185006b74a5ee78b83c50bdf37abc.zip |
Multi-variable declarations.
Diffstat (limited to 'libsolidity/Compiler.cpp')
-rw-r--r-- | libsolidity/Compiler.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libsolidity/Compiler.cpp b/libsolidity/Compiler.cpp index 64a67a4f..7c6c7831 100644 --- a/libsolidity/Compiler.cpp +++ b/libsolidity/Compiler.cpp @@ -623,13 +623,29 @@ bool Compiler::visit(VariableDeclarationStatement const& _variableDeclarationSta { StackHeightChecker checker(m_context); CompilerContext::LocationSetter locationSetter(m_context, _variableDeclarationStatement); - solAssert(_variableDeclarationStatement.declarations().size() == 1, "To be implemented."); - solAssert(!!_variableDeclarationStatement.declarations().front(), ""); - VariableDeclaration const& varDecl = *_variableDeclarationStatement.declarations().front(); if (Expression const* expression = _variableDeclarationStatement.initialValue()) { - compileExpression(*expression, varDecl.annotation().type); - CompilerUtils(m_context).moveToStackVariable(varDecl); + CompilerUtils utils(m_context); + compileExpression(*expression); + TypePointers valueTypes; + if (auto tupleType = dynamic_cast<TupleType const*>(expression->annotation().type.get())) + valueTypes = tupleType->components(); + else + valueTypes = TypePointers{expression->annotation().type}; + auto const& assignments = _variableDeclarationStatement.annotation().assignments; + solAssert(assignments.size() == valueTypes.size(), ""); + for (size_t i = 0; i < assignments.size(); ++i) + { + size_t j = assignments.size() - i - 1; + VariableDeclaration const* varDecl = assignments[j]; + if (!varDecl) + utils.popStackElement(*valueTypes[j]); + else + { + utils.convertType(*valueTypes[j], *varDecl->annotation().type); + utils.moveToStackVariable(*varDecl); + } + } } checker.check(); return false; |