diff options
author | Christian <c@ethdev.com> | 2015-02-25 22:55:42 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-02-25 22:55:42 +0800 |
commit | 29c614ebaf551006bc6c028592917e8f0dd5cf96 (patch) | |
tree | ea47dd14cb9ba8a303434071dac8514b36c98d8d /ExpressionCompiler.h | |
parent | cc31a7ab321a974cd81de2b539ec2bf7db2b2358 (diff) | |
download | dexon-solidity-29c614ebaf551006bc6c028592917e8f0dd5cf96.tar.gz dexon-solidity-29c614ebaf551006bc6c028592917e8f0dd5cf96.tar.zst dexon-solidity-29c614ebaf551006bc6c028592917e8f0dd5cf96.zip |
Removed code duplication.
Diffstat (limited to 'ExpressionCompiler.h')
-rw-r--r-- | ExpressionCompiler.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ExpressionCompiler.h b/ExpressionCompiler.h index edb63ad9..c3ecabbd 100644 --- a/ExpressionCompiler.h +++ b/ExpressionCompiler.h @@ -120,12 +120,27 @@ private: /// to be on the stack. /// Also retrieves the value if it was not requested by @a _expression. void setLValueToStorageItem(Expression const& _expression); + /// Sets the current LValue to a new LValue constructed from the arguments. + /// Also retrieves the value if it was not requested by @a _expression. + template <class _LValueType, class... _Arguments> + void setLValue(Expression const& _expression, _Arguments const&... _arguments); bool m_optimize; CompilerContext& m_context; std::unique_ptr<LValue> m_currentLValue; }; +template <class _LValueType, class... _Arguments> +void ExpressionCompiler::setLValue(Expression const& _expression, _Arguments const&... _arguments) +{ + solAssert(!m_currentLValue, "Current LValue not reset when trying to set to new one."); + std::unique_ptr<_LValueType> lvalue(new _LValueType(m_context, _arguments...)); + if (_expression.lvalueRequested()) + m_currentLValue = move(lvalue); + else + lvalue->retrieveValue(_expression.getLocation(), true); + +} } } |