Browse Source

Renamed url to identifier and added some comments.

cl-refactor
Christian 10 years ago
parent
commit
dcce76392b
  1. 10
      libsolidity/AST.h
  2. 2
      libsolidity/ASTPrinter.cpp
  3. 6
      libsolidity/CompilerStack.cpp
  4. 2
      libsolidity/CompilerStack.h
  5. 1
      libsolidity/NameAndTypeResolver.cpp

10
libsolidity/AST.h

@ -98,19 +98,21 @@ private:
/** /**
* Import directive for referencing other files / source objects. * 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 class ImportDirective: public ASTNode
{ {
public: public:
ImportDirective(Location const& _location, ASTPointer<ASTString> const& _url): ImportDirective(Location const& _location, ASTPointer<ASTString> const& _identifier):
ASTNode(_location), m_url(_url) {} ASTNode(_location), m_identifier(_identifier) {}
virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTVisitor& _visitor) override;
ASTString const& getURL() const { return *m_url; } ASTString const& getIdentifier() const { return *m_identifier; }
private: private:
ASTPointer<ASTString> m_url; ASTPointer<ASTString> m_identifier;
}; };
/** /**

2
libsolidity/ASTPrinter.cpp

@ -45,7 +45,7 @@ void ASTPrinter::print(ostream& _stream)
bool ASTPrinter::visit(ImportDirective& _node) bool ASTPrinter::visit(ImportDirective& _node)
{ {
writeLine("ImportDirective \"" + _node.getURL() + "\""); writeLine("ImportDirective \"" + _node.getIdentifier() + "\"");
printSourcePart(_node); printSourcePart(_node);
return goDeeper(); return goDeeper();
} }

6
libsolidity/CompilerStack.cpp

@ -201,12 +201,12 @@ void CompilerStack::resolveImports()
for (ASTPointer<ASTNode> const& node: _source->ast->getNodes()) for (ASTPointer<ASTNode> const& node: _source->ast->getNodes())
if (ImportDirective const* import = dynamic_cast<ImportDirective*>(node.get())) if (ImportDirective const* import = dynamic_cast<ImportDirective*>(node.get()))
{ {
string const& url = import->getURL(); string const& id = import->getIdentifier();
if (!m_sources.count(url)) if (!m_sources.count(id))
BOOST_THROW_EXCEPTION(ParserError() BOOST_THROW_EXCEPTION(ParserError()
<< errinfo_sourceLocation(import->getLocation()) << errinfo_sourceLocation(import->getLocation())
<< errinfo_comment("Source not found.")); << errinfo_comment("Source not found."));
toposort(&m_sources[url]); toposort(&m_sources[id]);
} }
sourceOrder.push_back(_source); sourceOrder.push_back(_source);
}; };

2
libsolidity/CompilerStack.h

@ -66,7 +66,7 @@ public:
/// Returns a list of the contract names in the sources. /// Returns a list of the contract names in the sources.
std::vector<std::string> getContractNames(); std::vector<std::string> 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); void compile(bool _optimize = false);
/// Parses and compiles the given source code. /// Parses and compiles the given source code.
/// @returns the compiled bytecode /// @returns the compiled bytecode

1
libsolidity/NameAndTypeResolver.cpp

@ -40,6 +40,7 @@ NameAndTypeResolver::NameAndTypeResolver(std::vector<Declaration*> const& _globa
void NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit) 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); DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit);
} }

Loading…
Cancel
Save