Provide dialect to Parser and InlineAssembly AST nodes.

This commit is contained in:
chriseth
2019-05-23 00:24:58 +02:00
parent fb2b3bb2b9
commit 9a00729ce7
11 changed files with 58 additions and 27 deletions
+5 -3
View File
@@ -29,6 +29,7 @@
#include <liblangutil/Scanner.h>
#include <liblangutil/SemVerHandler.h>
#include <liblangutil/SourceLocation.h>
#include <libyul/backends/evm/EVMDialect.h>
#include <cctype>
#include <vector>
@@ -1039,21 +1040,22 @@ ASTPointer<InlineAssembly> Parser::parseInlineAssembly(ASTPointer<ASTString> con
SourceLocation location{position(), -1, source()};
expectToken(Token::Assembly);
yul::Dialect const& dialect = yul::EVMDialect::looseAssemblyForEVM(m_evmVersion);
if (m_scanner->currentToken() == Token::StringLiteral)
{
if (m_scanner->currentLiteral() != "evmasm")
fatalParserError("Only \"evmasm\" supported.");
// This can be used in the future to set the dialect.
m_scanner->next();
}
// Using latest EVM Version for now, it will be run again later.
yul::Parser asmParser(m_errorReporter, yul::EVMDialect::looseAssemblyForEVM(EVMVersion{}));
yul::Parser asmParser(m_errorReporter, dialect);
shared_ptr<yul::Block> block = asmParser.parse(m_scanner, true);
if (block == nullptr)
BOOST_THROW_EXCEPTION(FatalError());
location.end = block->location.end;
return make_shared<InlineAssembly>(location, _docString, block);
return make_shared<InlineAssembly>(location, _docString, dialect, block);
}
ASTPointer<IfStatement> Parser::parseIfStatement(ASTPointer<ASTString> const& _docString)