diff options
author | chriseth <chris@ethereum.org> | 2018-03-27 21:28:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-27 21:28:08 +0800 |
commit | 59538e9a04da1761f3a71f2181c1812fc23a5cb8 (patch) | |
tree | 659c3c710f551fbb02085711514332b3923e831f /libsolidity/codegen/ExpressionCompiler.cpp | |
parent | af26228159d6fbf3240291d356878505ba42e33a (diff) | |
parent | fab527c4146f08971938c63074c8c92e6ff241bc (diff) | |
download | dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.tar dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.tar.gz dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.tar.bz2 dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.tar.lz dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.tar.xz dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.tar.zst dexon-solidity-59538e9a04da1761f3a71f2181c1812fc23a5cb8.zip |
Merge pull request #3686 from ethereum/doNotIncludeItnernal
Do not include internal functions only used by constructor
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 37069c3e..9e2d30d5 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -518,7 +518,23 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) arguments[i]->accept(*this); utils().convertType(*arguments[i]->annotation().type, *function.parameterTypes()[i]); } - _functionCall.expression().accept(*this); + + { + bool shortcutTaken = false; + if (auto identifier = dynamic_cast<Identifier const*>(&_functionCall.expression())) + if (auto functionDef = dynamic_cast<FunctionDefinition const*>(identifier->annotation().referencedDeclaration)) + { + // Do not directly visit the identifier, because this way, we can avoid + // the runtime entry label to be created at the creation time context. + CompilerContext::LocationSetter locationSetter2(m_context, *identifier); + utils().pushCombinedFunctionEntryLabel(m_context.resolveVirtualFunction(*functionDef), false); + shortcutTaken = true; + } + + if (!shortcutTaken) + _functionCall.expression().accept(*this); + } + unsigned parameterSize = CompilerUtils::sizeOnStack(function.parameterTypes()); if (function.bound()) { @@ -1359,6 +1375,10 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) } } else if (FunctionDefinition const* functionDef = dynamic_cast<FunctionDefinition const*>(declaration)) + // If the identifier is called right away, this code is executed in visit(FunctionCall...), because + // we want to avoid having a reference to the runtime function entry point in the + // constructor context, since this would force the compiler to include unreferenced + // internal functions in the runtime contex. utils().pushCombinedFunctionEntryLabel(m_context.resolveVirtualFunction(*functionDef)); else if (auto variable = dynamic_cast<VariableDeclaration const*>(declaration)) appendVariable(*variable, static_cast<Expression const&>(_identifier)); |