diff options
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/AST.cpp | 7 | ||||
-rw-r--r-- | libsolidity/ast/AST.h | 21 | ||||
-rw-r--r-- | libsolidity/ast/ASTAnnotations.h | 6 |
3 files changed, 27 insertions, 7 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 6006d441..701202f9 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -56,6 +56,13 @@ Error ASTNode::createTypeError(string const& _description) const return Error(Error::Type::TypeError) << errinfo_sourceLocation(location()) << errinfo_comment(_description); } +ImportAnnotation& ImportDirective::annotation() const +{ + if (!m_annotation) + m_annotation = new ImportAnnotation(); + return static_cast<ImportAnnotation&>(*m_annotation); +} + map<FixedHash<4>, FunctionTypePointer> ContractDefinition::interfaceFunctions() const { auto exportedFunctionList = interfaceFunctionList(); diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 1217d945..1ba4f65b 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -142,6 +142,7 @@ public: virtual void accept(ASTConstVisitor& _visitor) const override; ASTString const& identifier() const { return *m_identifier; } + virtual ImportAnnotation& annotation() const override; private: ASTPointer<ASTString> m_identifier; @@ -172,8 +173,8 @@ public: /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. /// Available only after name and type resolution step. - Declaration const* scope() const { return m_scope; } - void setScope(Declaration const* _scope) { m_scope = _scope; } + ASTNode const* scope() const { return m_scope; } + void setScope(ASTNode const* _scope) { m_scope = _scope; } virtual bool isLValue() const { return false; } virtual bool isPartOfExternalInterface() const { return false; } @@ -190,7 +191,7 @@ protected: private: ASTPointer<ASTString> m_name; Visibility m_visibility; - Declaration const* m_scope; + ASTNode const* m_scope; }; /** @@ -1126,9 +1127,10 @@ private: ASTPointer<Expression> m_rightHandSide; }; + /** - * Tuple or just parenthesized expression. - * Examples: (1, 2), (x,), (x), () + * Tuple, parenthesized expression, or bracketed expression. + * Examples: (1, 2), (x,), (x), (), [1, 2], * Individual components might be empty shared pointers (as in the second example). * The respective types in lvalue context are: 2-tuple, 2-tuple (with wildcard), type of x, 0-tuple * Not in lvalue context: 2-tuple, _1_-tuple, type of x, 0-tuple. @@ -1138,16 +1140,21 @@ class TupleExpression: public Expression public: TupleExpression( SourceLocation const& _location, - std::vector<ASTPointer<Expression>> const& _components + std::vector<ASTPointer<Expression>> const& _components, + bool _isArray ): - Expression(_location), m_components(_components) {} + Expression(_location), + m_components(_components), + m_isArray(_isArray) {} virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; std::vector<ASTPointer<Expression>> const& components() const { return m_components; } + bool isInlineArray() const { return m_isArray; } private: std::vector<ASTPointer<Expression>> m_components; + bool m_isArray; }; /** diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 4e0187cf..0bc91c60 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -54,6 +54,12 @@ struct DocumentedAnnotation std::multimap<std::string, DocTag> docTags; }; +struct ImportAnnotation: ASTAnnotation +{ + /// The absolute path of the source unit to import. + std::string absolutePath; +}; + struct TypeDeclarationAnnotation: ASTAnnotation { /// The name of this type, prefixed by proper namespaces if globally accessible. |