From 98e343b3fc11f3e94297b016c3f625e3b319b09b Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 1 Feb 2017 21:40:50 +0100 Subject: Parsing of labels with stack info. --- libsolidity/inlineasm/AsmCodeGen.cpp | 1 + libsolidity/inlineasm/AsmData.h | 4 ++-- libsolidity/inlineasm/AsmParser.cpp | 32 ++++++++++++++++++++++++++++++++ libsolidity/inlineasm/AsmPrinter.cpp | 6 +++++- 4 files changed, 40 insertions(+), 3 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp index faa7dabd..abc0ca01 100644 --- a/libsolidity/inlineasm/AsmCodeGen.cpp +++ b/libsolidity/inlineasm/AsmCodeGen.cpp @@ -91,6 +91,7 @@ public: void operator()(T const& /*_item*/) { } void operator()(Label const& _item) { + solAssert(_item.stackInfo.empty(), "Labels with stack info not yet supported."); if (m_state.labels.count(_item.name)) //@TODO secondary location m_state.addError( diff --git a/libsolidity/inlineasm/AsmData.h b/libsolidity/inlineasm/AsmData.h index d61b5803..5969bf96 100644 --- a/libsolidity/inlineasm/AsmData.h +++ b/libsolidity/inlineasm/AsmData.h @@ -42,8 +42,8 @@ struct Literal { SourceLocation location; bool isNumber; std::string value; }; /// External / internal identifier or label reference struct Identifier { SourceLocation location; std::string name; }; struct FunctionalInstruction; -/// Jump label ("name:") -struct Label { SourceLocation location; std::string name; }; +/// Jump label ("name:" or "name [x, y, z]:" or "name [-3]:") +struct Label { SourceLocation location; std::string name; std::vector stackInfo; }; /// Assignemnt (":= x", moves stack top into x, potentially multiple slots) struct Assignment { SourceLocation location; Identifier variableName; }; struct FunctionalAssignment; diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 0fc0a34f..5d439b2f 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -121,6 +121,38 @@ assembly::Statement Parser::parseStatement() return label; } } + case Token::LBrack: + { + if (statement.type() != typeid(assembly::Identifier)) + fatalParserError("Label name must precede \"[\"."); + assembly::Identifier const& identifier = boost::get(statement); + Label label = createWithLocation