diff options
author | chriseth <chris@ethereum.org> | 2017-04-28 03:58:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-28 03:58:45 +0800 |
commit | 6776be33a83cf1326a372b14afb718da226125f7 (patch) | |
tree | bf6c6c958c8be9db3791df890c3ab15620a32c01 /libsolidity | |
parent | 3926e8704af00062c33e392fcaef70510df7012e (diff) | |
parent | 8b79517d4784fee08a1f2bb0f834fd3133e4fb17 (diff) | |
download | dexon-solidity-6776be33a83cf1326a372b14afb718da226125f7.tar.gz dexon-solidity-6776be33a83cf1326a372b14afb718da226125f7.tar.zst dexon-solidity-6776be33a83cf1326a372b14afb718da226125f7.zip |
Merge pull request #2189 from ethereum/julia-instructions
Do not disallow EVM instructions as identifiers in Julia
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 10 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmParser.h | 5 |
2 files changed, 10 insertions, 5 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 9513cf77..848e488d 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -24,6 +24,7 @@ #include <ctype.h> #include <algorithm> #include <libsolidity/parsing/Scanner.h> +#include <libsolidity/interface/Exceptions.h> using namespace std; using namespace dev; @@ -73,7 +74,7 @@ assembly::Statement Parser::parseStatement() expectToken(Token::Colon); assignment.variableName.location = location(); assignment.variableName.name = m_scanner->currentLiteral(); - if (instructions().count(assignment.variableName.name)) + if (!m_julia && instructions().count(assignment.variableName.name)) fatalParserError("Identifier expected, got instruction name."); assignment.location.end = endPosition(); expectToken(Token::Identifier); @@ -105,7 +106,7 @@ assembly::Statement Parser::parseStatement() { // functional assignment FunctionalAssignment funAss = createWithLocation<FunctionalAssignment>(identifier.location); - if (instructions().count(identifier.name)) + if (!m_julia && instructions().count(identifier.name)) fatalParserError("Cannot use instruction names for identifier names."); m_scanner->next(); funAss.variableName = identifier; @@ -180,7 +181,7 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher) else literal = m_scanner->currentLiteral(); // first search the set of instructions. - if (instructions().count(literal)) + if (!m_julia && instructions().count(literal)) { dev::solidity::Instruction const& instr = instructions().at(literal); if (_onlySinglePusher) @@ -259,6 +260,7 @@ assembly::Statement Parser::parseFunctionalInstruction(assembly::Statement&& _in { if (_instruction.type() == typeid(Instruction)) { + solAssert(!m_julia, "Instructions are invalid in JULIA"); FunctionalInstruction ret; ret.instruction = std::move(boost::get<Instruction>(_instruction)); ret.location = ret.instruction.location; @@ -321,7 +323,7 @@ assembly::Statement Parser::parseFunctionalInstruction(assembly::Statement&& _in string Parser::expectAsmIdentifier() { string name = m_scanner->currentLiteral(); - if (instructions().count(name)) + if (!m_julia && instructions().count(name)) fatalParserError("Cannot use instruction names for identifier names."); expectToken(Token::Identifier); return name; diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h index 4b4a24ae..c55fd2ac 100644 --- a/libsolidity/inlineasm/AsmParser.h +++ b/libsolidity/inlineasm/AsmParser.h @@ -37,7 +37,7 @@ namespace assembly class Parser: public ParserBase { public: - Parser(ErrorList& _errors): ParserBase(_errors) {} + explicit Parser(ErrorList& _errors, bool _julia = false): ParserBase(_errors), m_julia(_julia) {} /// Parses an inline assembly block starting with `{` and ending with `}`. /// @returns an empty shared pointer on error. @@ -70,6 +70,9 @@ protected: FunctionDefinition parseFunctionDefinition(); Statement parseFunctionalInstruction(Statement&& _instruction); std::string expectAsmIdentifier(); + +private: + bool m_julia = false; }; } |