aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-05 21:39:47 +0800
committerGitHub <noreply@github.com>2017-05-05 21:39:47 +0800
commitb0f2a5c162480ab6ecdc5e1397567242a137768a (patch)
treeef5e8ea960fd06070afccc196ddd84059f7eb63c /libsolidity
parent0582fcb93b2407379b5e4e4ce55c3f418e7ff433 (diff)
parent07176e82de05bd4490b22f070cd11e36b84f734a (diff)
downloaddexon-solidity-b0f2a5c162480ab6ecdc5e1397567242a137768a.tar.gz
dexon-solidity-b0f2a5c162480ab6ecdc5e1397567242a137768a.tar.zst
dexon-solidity-b0f2a5c162480ab6ecdc5e1397567242a137768a.zip
Merge pull request #2205 from ethereum/julia-strict-parser
Stricter parser for Julia
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp19
-rw-r--r--libsolidity/inlineasm/AsmPrinter.cpp6
-rw-r--r--libsolidity/inlineasm/AsmPrinter.h5
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;
};
}