diff options
Diffstat (limited to 'libsolidity/inlineasm')
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 19 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmPrinter.cpp | 6 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmPrinter.h | 5 |
3 files changed, 26 insertions, 4 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index d7f78958..d9b0b3e0 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -84,6 +84,7 @@ assembly::Statement Parser::parseStatement() } case Token::Return: // opcode case Token::Byte: // opcode + case Token::Address: // opcode default: break; } @@ -91,7 +92,7 @@ assembly::Statement Parser::parseStatement() // Simple instruction (might turn into functional), // literal, // identifier (might turn into label or functional assignment) - Statement statement(parseElementaryOperation()); + Statement statement(parseElementaryOperation(false)); switch (m_scanner->currentToken()) { case Token::LParen: @@ -119,12 +120,16 @@ assembly::Statement Parser::parseStatement() else { // label + if (m_julia) + fatalParserError("Labels are not supported."); Label label = createWithLocation<Label>(identifier.location); label.name = identifier.name; return label; } } default: + if (m_julia) + fatalParserError("Call or assignment expected."); break; } return statement; @@ -209,7 +214,11 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher) break; } default: - fatalParserError("Expected elementary inline assembly operation."); + fatalParserError( + m_julia ? + "Literal or identifier expected." : + "Expected elementary inline assembly operation." + ); } m_scanner->next(); return ret; @@ -317,7 +326,11 @@ assembly::Statement Parser::parseFunctionalInstruction(assembly::Statement&& _in return ret; } else - fatalParserError("Assembly instruction or function name required in front of \"(\")"); + fatalParserError( + m_julia ? + "Function name expected." : + "Assembly instruction or function name required in front of \"(\")" + ); return {}; } diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp index 252e91f9..4a6f975d 100644 --- a/libsolidity/inlineasm/AsmPrinter.cpp +++ b/libsolidity/inlineasm/AsmPrinter.cpp @@ -21,8 +21,8 @@ */ #include <libsolidity/inlineasm/AsmPrinter.h> - #include <libsolidity/inlineasm/AsmData.h> +#include <libsolidity/interface/Utils.h> #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/replace.hpp> @@ -40,6 +40,7 @@ using namespace dev::solidity::assembly; string AsmPrinter::operator()(assembly::Instruction const& _instruction) { + solAssert(!m_julia, ""); return boost::to_lower_copy(instructionInfo(_instruction.instruction).name); } @@ -83,6 +84,7 @@ string AsmPrinter::operator()(assembly::Identifier const& _identifier) string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functionalInstruction) { + solAssert(!m_julia, ""); return (*this)(_functionalInstruction.instruction) + "(" + @@ -94,11 +96,13 @@ string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functional string AsmPrinter::operator()(assembly::Label const& _label) { + solAssert(!m_julia, ""); return _label.name + ":"; } string AsmPrinter::operator()(assembly::Assignment const& _assignment) { + solAssert(!m_julia, ""); return "=: " + (*this)(_assignment.variableName); } diff --git a/libsolidity/inlineasm/AsmPrinter.h b/libsolidity/inlineasm/AsmPrinter.h index a7a1de0a..038c6d85 100644 --- a/libsolidity/inlineasm/AsmPrinter.h +++ b/libsolidity/inlineasm/AsmPrinter.h @@ -45,6 +45,8 @@ struct Block; class AsmPrinter: public boost::static_visitor<std::string> { public: + explicit AsmPrinter(bool _julia = false): m_julia(_julia) {} + std::string operator()(assembly::Instruction const& _instruction); std::string operator()(assembly::Literal const& _literal); std::string operator()(assembly::Identifier const& _identifier); @@ -56,6 +58,9 @@ public: std::string operator()(assembly::FunctionDefinition const& _functionDefinition); std::string operator()(assembly::FunctionCall const& _functionCall); std::string operator()(assembly::Block const& _block); + +private: + bool m_julia = false; }; } |