diff --git a/libsolidity/AST.h b/libsolidity/AST.h index d2fb15a45..10616022b 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -98,19 +98,21 @@ private: /** * Import directive for referencing other files / source objects. + * Example: import "abc.sol" + * Source objects are identified by a string which can be a file name but does not have to be. */ class ImportDirective: public ASTNode { public: - ImportDirective(Location const& _location, ASTPointer const& _url): - ASTNode(_location), m_url(_url) {} + ImportDirective(Location const& _location, ASTPointer const& _identifier): + ASTNode(_location), m_identifier(_identifier) {} virtual void accept(ASTVisitor& _visitor) override; - ASTString const& getURL() const { return *m_url; } + ASTString const& getIdentifier() const { return *m_identifier; } private: - ASTPointer m_url; + ASTPointer m_identifier; }; /** diff --git a/libsolidity/ASTPrinter.cpp b/libsolidity/ASTPrinter.cpp index c62378fd3..3d09fd9af 100644 --- a/libsolidity/ASTPrinter.cpp +++ b/libsolidity/ASTPrinter.cpp @@ -45,7 +45,7 @@ void ASTPrinter::print(ostream& _stream) bool ASTPrinter::visit(ImportDirective& _node) { - writeLine("ImportDirective \"" + _node.getURL() + "\""); + writeLine("ImportDirective \"" + _node.getIdentifier() + "\""); printSourcePart(_node); return goDeeper(); } diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 621723848..20b0b3e57 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -201,12 +201,12 @@ void CompilerStack::resolveImports() for (ASTPointer const& node: _source->ast->getNodes()) if (ImportDirective const* import = dynamic_cast(node.get())) { - string const& url = import->getURL(); - if (!m_sources.count(url)) + string const& id = import->getIdentifier(); + if (!m_sources.count(id)) BOOST_THROW_EXCEPTION(ParserError() << errinfo_sourceLocation(import->getLocation()) << errinfo_comment("Source not found.")); - toposort(&m_sources[url]); + toposort(&m_sources[id]); } sourceOrder.push_back(_source); }; diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index 34178841a..bedb4cc38 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -66,7 +66,7 @@ public: /// Returns a list of the contract names in the sources. std::vector getContractNames(); - /// Compiles the source units that were prevously added and parsed. + /// Compiles the source units that were previously added and parsed. void compile(bool _optimize = false); /// Parses and compiles the given source code. /// @returns the compiled bytecode diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index 08deb66a0..3715df6ad 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/NameAndTypeResolver.cpp @@ -40,6 +40,7 @@ NameAndTypeResolver::NameAndTypeResolver(std::vector const& _globa void NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit) { + // The helper registers all declarations in m_scopes as a side-effect of its construction. DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit); }