diff options
author | chriseth <c@ethdev.com> | 2016-02-22 09:13:41 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-03-30 08:37:00 +0800 |
commit | 949b00ed591303c531ed8fa73087b710b7a554de (patch) | |
tree | 182664f2545e6211d7994ef90a1e7746d5482981 /libsolidity/ast | |
parent | 8236732e9a5d2535afd3a3573a70d5aab3da3efe (diff) | |
download | dexon-solidity-949b00ed591303c531ed8fa73087b710b7a554de.tar.gz dexon-solidity-949b00ed591303c531ed8fa73087b710b7a554de.tar.zst dexon-solidity-949b00ed591303c531ed8fa73087b710b7a554de.zip |
Parsing for inline assembly.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/AST.h | 25 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 10 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.h | 2 | ||||
-rw-r--r-- | libsolidity/ast/ASTPrinter.cpp | 12 | ||||
-rw-r--r-- | libsolidity/ast/ASTPrinter.h | 2 | ||||
-rw-r--r-- | libsolidity/ast/ASTVisitor.h | 4 | ||||
-rw-r--r-- | libsolidity/ast/AST_accept.h | 12 |
7 files changed, 67 insertions, 0 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index d32d76a4..f53c78f2 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -28,6 +28,7 @@ #include <memory> #include <boost/noncopyable.hpp> #include <libevmasm/SourceLocation.h> +#include <libevmcore/Instruction.h> #include <libsolidity/interface/Utils.h> #include <libsolidity/ast/ASTForward.h> #include <libsolidity/parsing/Token.h> @@ -854,6 +855,30 @@ public: virtual StatementAnnotation& annotation() const override; }; +// Forward-declaration to InlineAssembly.h +class AsmData; + +/** + * Inline assembly. + */ +class InlineAssembly: public Statement +{ +public: + InlineAssembly( + SourceLocation const& _location, + ASTPointer<ASTString> const& _docString, + std::shared_ptr<AsmData> const& _operations + ): + Statement(_location, _docString), m_operations(_operations) {} + virtual void accept(ASTVisitor& _visitor) override; + virtual void accept(ASTConstVisitor& _visitor) const override; + + AsmData const& operations() const { return *m_operations; } + +private: + std::shared_ptr<AsmData> m_operations; +}; + /** * Brace-enclosed block containing zero or more statements. */ diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 163e22f4..89d0bf35 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -157,6 +157,12 @@ bool ASTJsonConverter::visit(Mapping const&) return true; } +bool ASTJsonConverter::visit(InlineAssembly const&) +{ + addJsonNode("InlineAssembly", {}, true); + return true; +} + bool ASTJsonConverter::visit(Block const&) { addJsonNode("Block", {}, true); @@ -355,6 +361,10 @@ void ASTJsonConverter::endVisit(Mapping const&) { } +void ASTJsonConverter::endVisit(InlineAssembly const&) +{ +} + void ASTJsonConverter::endVisit(Block const&) { goUp(); diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index b7fc84e9..91ee72e1 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -57,6 +57,7 @@ public: bool visit(ElementaryTypeName const& _node) override; bool visit(UserDefinedTypeName const& _node) override; bool visit(Mapping const& _node) override; + bool visit(InlineAssembly const& _node) override; bool visit(Block const& _node) override; bool visit(IfStatement const& _node) override; bool visit(WhileStatement const& _node) override; @@ -90,6 +91,7 @@ public: void endVisit(ElementaryTypeName const&) override; void endVisit(UserDefinedTypeName const&) override; void endVisit(Mapping const&) override; + void endVisit(InlineAssembly const&) override; void endVisit(Block const&) override; void endVisit(IfStatement const&) override; void endVisit(WhileStatement const&) override; diff --git a/libsolidity/ast/ASTPrinter.cpp b/libsolidity/ast/ASTPrinter.cpp index 283bc8f9..9ed9c6d5 100644 --- a/libsolidity/ast/ASTPrinter.cpp +++ b/libsolidity/ast/ASTPrinter.cpp @@ -171,6 +171,13 @@ bool ASTPrinter::visit(ArrayTypeName const& _node) return goDeeper(); } +bool ASTPrinter::visit(InlineAssembly const& _node) +{ + writeLine("InlineAssembly"); + printSourcePart(_node); + return goDeeper(); +} + bool ASTPrinter::visit(Block const& _node) { writeLine("Block"); @@ -433,6 +440,11 @@ void ASTPrinter::endVisit(ArrayTypeName const&) m_indentation--; } +void ASTPrinter::endVisit(InlineAssembly const&) +{ + m_indentation--; +} + void ASTPrinter::endVisit(Block const&) { m_indentation--; diff --git a/libsolidity/ast/ASTPrinter.h b/libsolidity/ast/ASTPrinter.h index 334fefc7..a2546935 100644 --- a/libsolidity/ast/ASTPrinter.h +++ b/libsolidity/ast/ASTPrinter.h @@ -64,6 +64,7 @@ public: bool visit(UserDefinedTypeName const& _node) override; bool visit(Mapping const& _node) override; bool visit(ArrayTypeName const& _node) override; + bool visit(InlineAssembly const& _node) override; bool visit(Block const& _node) override; bool visit(PlaceholderStatement const& _node) override; bool visit(IfStatement const& _node) override; @@ -105,6 +106,7 @@ public: void endVisit(UserDefinedTypeName const&) override; void endVisit(Mapping const&) override; void endVisit(ArrayTypeName const&) override; + void endVisit(InlineAssembly const&) override; void endVisit(Block const&) override; void endVisit(PlaceholderStatement const&) override; void endVisit(IfStatement const&) override; diff --git a/libsolidity/ast/ASTVisitor.h b/libsolidity/ast/ASTVisitor.h index 625f395d..5aac2066 100644 --- a/libsolidity/ast/ASTVisitor.h +++ b/libsolidity/ast/ASTVisitor.h @@ -62,6 +62,7 @@ public: virtual bool visit(UserDefinedTypeName& _node) { return visitNode(_node); } virtual bool visit(Mapping& _node) { return visitNode(_node); } virtual bool visit(ArrayTypeName& _node) { return visitNode(_node); } + virtual bool visit(InlineAssembly& _node) { return visitNode(_node); } virtual bool visit(Block& _node) { return visitNode(_node); } virtual bool visit(PlaceholderStatement& _node) { return visitNode(_node); } virtual bool visit(IfStatement& _node) { return visitNode(_node); } @@ -105,6 +106,7 @@ public: virtual void endVisit(UserDefinedTypeName& _node) { endVisitNode(_node); } virtual void endVisit(Mapping& _node) { endVisitNode(_node); } virtual void endVisit(ArrayTypeName& _node) { endVisitNode(_node); } + virtual void endVisit(InlineAssembly& _node) { endVisitNode(_node); } virtual void endVisit(Block& _node) { endVisitNode(_node); } virtual void endVisit(PlaceholderStatement& _node) { endVisitNode(_node); } virtual void endVisit(IfStatement& _node) { endVisitNode(_node); } @@ -166,6 +168,7 @@ public: virtual bool visit(WhileStatement const& _node) { return visitNode(_node); } virtual bool visit(ForStatement const& _node) { return visitNode(_node); } virtual bool visit(Continue const& _node) { return visitNode(_node); } + virtual bool visit(InlineAssembly const& _node) { return visitNode(_node); } virtual bool visit(Break const& _node) { return visitNode(_node); } virtual bool visit(Return const& _node) { return visitNode(_node); } virtual bool visit(Throw const& _node) { return visitNode(_node); } @@ -209,6 +212,7 @@ public: virtual void endVisit(WhileStatement const& _node) { endVisitNode(_node); } virtual void endVisit(ForStatement const& _node) { endVisitNode(_node); } virtual void endVisit(Continue const& _node) { endVisitNode(_node); } + virtual void endVisit(InlineAssembly const& _node) { endVisitNode(_node); } virtual void endVisit(Break const& _node) { endVisitNode(_node); } virtual void endVisit(Return const& _node) { endVisitNode(_node); } virtual void endVisit(Throw const& _node) { endVisitNode(_node); } diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h index dee9d5b1..dd2a7d60 100644 --- a/libsolidity/ast/AST_accept.h +++ b/libsolidity/ast/AST_accept.h @@ -357,6 +357,18 @@ void ArrayTypeName::accept(ASTConstVisitor& _visitor) const _visitor.endVisit(*this); } +void InlineAssembly::accept(ASTVisitor& _visitor) +{ + _visitor.visit(*this); + _visitor.endVisit(*this); +} + +void InlineAssembly::accept(ASTConstVisitor& _visitor) const +{ + _visitor.visit(*this); + _visitor.endVisit(*this); +} + void Block::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) |