aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast/AST.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-12-15 01:01:40 +0800
committerchriseth <c@ethdev.com>2015-12-18 19:46:54 +0800
commitd3c459b5a99715c96733825f78d63cc57265ee3c (patch)
treef1add9102a402a3942caec4e0f296a69493759e7 /libsolidity/ast/AST.h
parentfe23cc82263c75f34e05795e12fedb08bc14e6a4 (diff)
downloaddexon-solidity-d3c459b5a99715c96733825f78d63cc57265ee3c.tar.gz
dexon-solidity-d3c459b5a99715c96733825f78d63cc57265ee3c.tar.zst
dexon-solidity-d3c459b5a99715c96733825f78d63cc57265ee3c.zip
Parse complex import directives.
Diffstat (limited to 'libsolidity/ast/AST.h')
-rw-r--r--libsolidity/ast/AST.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 1ba4f65b..e270afd5 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -129,23 +129,39 @@ private:
/**
* Import directive for referencing other files / source objects.
- * Example: import "abc.sol"
+ * Example: import "abc.sol" // imports all symbols of "abc.sol" into current scope
* Source objects are identified by a string which can be a file name but does not have to be.
+ * Other ways to use it:
+ * import "abc" as x; // creates symbol "x" that contains all symbols in "abc"
+ * import * as x from "abc"; // same as above
+ * import {a as b, c} from "abc"; // creates new symbols "b" and "c" referencing "a" and "c" in "abc", respectively.
*/
class ImportDirective: public ASTNode
{
public:
- ImportDirective(SourceLocation const& _location, ASTPointer<ASTString> const& _identifier):
- ASTNode(_location), m_identifier(_identifier) {}
+ ImportDirective(
+ SourceLocation const& _location,
+ ASTPointer<ASTString> const& _path,
+ ASTPointer<ASTString> const& _unitAlias,
+ std::vector<std::pair<ASTPointer<Identifier>, ASTPointer<ASTString>>>&& _symbolAliases
+ ):
+ ASTNode(_location), m_path(_path), m_unitAlias(_unitAlias), m_symbolAliases(_symbolAliases) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
- ASTString const& identifier() const { return *m_identifier; }
+ ASTString const& path() const { return *m_path; }
virtual ImportAnnotation& annotation() const override;
private:
- ASTPointer<ASTString> m_identifier;
+ ASTPointer<ASTString> m_path;
+ /// The alias for the module itself. If present, import the whole unit under that name and
+ /// ignore m_symbolAlias.
+ ASTPointer<ASTString> m_unitAlias;
+ /// The aliases for the specific symbols to import. If non-empty import the specific symbols.
+ /// If the second component is empty, import the identifier unchanged.
+ /// If both m_unitAlias and m_symbolAlias are empty, import all symbols into the current scope.
+ std::vector<std::pair<ASTPointer<Identifier>, ASTPointer<ASTString>>> m_symbolAliases;
};
/**