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/parsing | |
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/parsing')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 20 | ||||
-rw-r--r-- | libsolidity/parsing/Parser.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 7bda3610..29377380 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -20,11 +20,13 @@ * Solidity parser. */ +#include <ctype.h> #include <vector> #include <libdevcore/Log.h> #include <libevmasm/SourceLocation.h> #include <libsolidity/parsing/Parser.h> #include <libsolidity/parsing/Scanner.h> +#include <libsolidity/inlineasm/AsmParser.h> #include <libsolidity/interface/Exceptions.h> #include <libsolidity/interface/InterfaceHandler.h> @@ -712,6 +714,8 @@ ASTPointer<Statement> Parser::parseStatement() m_scanner->next(); break; } + case Token::Assembly: + return parseInlineAssembly(docString); case Token::Identifier: if (m_insideModifier && m_scanner->currentLiteral() == "_") { @@ -727,6 +731,22 @@ ASTPointer<Statement> Parser::parseStatement() return statement; } +ASTPointer<InlineAssembly> Parser::parseInlineAssembly(ASTPointer<ASTString> const& _docString) +{ + ASTNodeFactory nodeFactory(*this); + expectToken(Token::Assembly); + if (m_scanner->currentToken() != Token::StringLiteral) + fatalParserError("Expected assembly name."); + if (m_scanner->currentLiteral() != "evmasm") + fatalParserError("Only \"evmasm\" supported."); + m_scanner->next(); + + InlineAssemblyParser parser(m_errors); + shared_ptr<InlineAssemblyBlock> operations = parser.parse(m_scanner); + nodeFactory.markEndPosition(); + return nodeFactory.createNode<InlineAssembly>(_docString, operations); +} + ASTPointer<IfStatement> Parser::parseIfStatement(ASTPointer<ASTString> const& _docString) { ASTNodeFactory nodeFactory(*this); diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index a093cc5b..d776c3fd 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -81,6 +81,7 @@ private: ); ASTPointer<Block> parseBlock(ASTPointer<ASTString> const& _docString = {}); ASTPointer<Statement> parseStatement(); + ASTPointer<InlineAssembly> parseInlineAssembly(ASTPointer<ASTString> const& _docString = {}); ASTPointer<IfStatement> parseIfStatement(ASTPointer<ASTString> const& _docString); ASTPointer<WhileStatement> parseWhileStatement(ASTPointer<ASTString> const& _docString); ASTPointer<ForStatement> parseForStatement(ASTPointer<ASTString> const& _docString); |