diff options
author | chriseth <c@ethdev.com> | 2017-03-14 22:41:23 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-04-25 22:49:03 +0800 |
commit | e0849f2f3bbb23ebddb37cd770f46266967e789d (patch) | |
tree | 53c454ea354e032963ef246e11210de44731155c /libsolidity/analysis/ReferencesResolver.cpp | |
parent | 5d6747eb32f56f6b8b818eff5635888d250d62e1 (diff) | |
download | dexon-solidity-e0849f2f3bbb23ebddb37cd770f46266967e789d.tar.gz dexon-solidity-e0849f2f3bbb23ebddb37cd770f46266967e789d.tar.zst dexon-solidity-e0849f2f3bbb23ebddb37cd770f46266967e789d.zip |
Split external identifier access into resolving and code generation.
Diffstat (limited to 'libsolidity/analysis/ReferencesResolver.cpp')
-rw-r--r-- | libsolidity/analysis/ReferencesResolver.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 37bcb2d9..5ff4ee2d 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -158,21 +158,22 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName) bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) { - // We need to perform a full code generation pass here as inline assembly does not distinguish - // reference resolution and code generation. // Errors created in this stage are completely ignored because we do not yet know // the type and size of external identifiers, which would result in false errors. + // The only purpose of this step is to fill the inline assembly annotation with + // external references. ErrorList errorsIgnored; assembly::CodeGenerator codeGen(_inlineAssembly.operations(), errorsIgnored); - codeGen.typeCheck([&](assembly::Identifier const& _identifier, eth::Assembly&, assembly::CodeGenerator::IdentifierContext) { + assembly::ExternalIdentifierAccess identifierAccess; + identifierAccess.resolve = [&](assembly::Identifier const& _identifier, assembly::IdentifierContext) { auto declarations = m_resolver.nameFromCurrentScope(_identifier.name); if (declarations.size() != 1) - return false; - _inlineAssembly.annotation().externalReferences[&_identifier] = declarations.front(); - // At this stage we neither know the code to generate nor the stack size of the identifier, - // so we do not modify assembly. - return true; - }); + return size_t(-1); + _inlineAssembly.annotation().externalReferences[&_identifier].declaration = declarations.front(); + // At this stage we do not yet know the stack size of the identifier, so we just return 1. + return size_t(1); + }; + codeGen.typeCheck(identifierAccess); return false; } |