From 54b6739962ef45319777ce2aebafdf4b91412d84 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 8 Dec 2017 14:01:22 +0100 Subject: Separate expression and statement. --- libsolidity/inlineasm/AsmParser.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libsolidity/inlineasm/AsmParser.h') diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h index e46d1732..44889a13 100644 --- a/libsolidity/inlineasm/AsmParser.h +++ b/libsolidity/inlineasm/AsmParser.h @@ -44,6 +44,8 @@ public: std::shared_ptr parse(std::shared_ptr const& _scanner); protected: + using ElementaryOperation = boost::variant; + /// Creates an inline assembly node with the given source location. template T createWithLocation(SourceLocation const& _loc = SourceLocation()) const { @@ -65,13 +67,13 @@ protected: Case parseCase(); ForLoop parseForLoop(); /// Parses a functional expression that has to push exactly one stack element - Statement parseExpression(); + assembly::Expression parseExpression(); static std::map const& instructions(); static std::map const& instructionNames(); - Statement parseElementaryOperation(bool _onlySinglePusher = false); + ElementaryOperation parseElementaryOperation(bool _onlySinglePusher = false); VariableDeclaration parseVariableDeclaration(); FunctionDefinition parseFunctionDefinition(); - Statement parseCall(Statement&& _instruction); + assembly::Expression parseCall(ElementaryOperation&& _initialOp); TypedName parseTypedName(); std::string expectAsmIdentifier(); -- cgit v1.2.3 From fcbdaa32b90cd7da8729411481d587151f484fa1 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sat, 6 Jan 2018 00:09:08 +0000 Subject: Simplify parseElementaryOperation in regards to special instructions --- libsolidity/inlineasm/AsmParser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libsolidity/inlineasm/AsmParser.h') diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h index 44889a13..bd90bb43 100644 --- a/libsolidity/inlineasm/AsmParser.h +++ b/libsolidity/inlineasm/AsmParser.h @@ -70,7 +70,7 @@ protected: assembly::Expression parseExpression(); static std::map const& instructions(); static std::map const& instructionNames(); - ElementaryOperation parseElementaryOperation(bool _onlySinglePusher = false); + ElementaryOperation parseElementaryOperation(); VariableDeclaration parseVariableDeclaration(); FunctionDefinition parseFunctionDefinition(); assembly::Expression parseCall(ElementaryOperation&& _initialOp); -- cgit v1.2.3 From 124190336b0a70ea32d5f8ca0c4b364f1fc774d0 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 13 Dec 2017 14:40:54 +0100 Subject: Split inline assembly into loose and strict flavours. --- libsolidity/inlineasm/AsmParser.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libsolidity/inlineasm/AsmParser.h') diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h index bd90bb43..015aeef3 100644 --- a/libsolidity/inlineasm/AsmParser.h +++ b/libsolidity/inlineasm/AsmParser.h @@ -37,7 +37,8 @@ namespace assembly class Parser: public ParserBase { public: - explicit Parser(ErrorReporter& _errorReporter, bool _julia = false): ParserBase(_errorReporter), m_julia(_julia) {} + explicit Parser(ErrorReporter& _errorReporter, AsmFlavour _flavour = AsmFlavour::Loose): + ParserBase(_errorReporter), m_flavour(_flavour) {} /// Parses an inline assembly block starting with `{` and ending with `}`. /// @returns an empty shared pointer on error. @@ -70,6 +71,9 @@ protected: assembly::Expression parseExpression(); static std::map const& instructions(); static std::map const& instructionNames(); + /// Parses an elementary operation, i.e. a literal, identifier or instruction. + /// This will parse instructions even in strict mode as part of the full parser + /// for FunctionalInstruction. ElementaryOperation parseElementaryOperation(); VariableDeclaration parseVariableDeclaration(); FunctionDefinition parseFunctionDefinition(); @@ -80,7 +84,7 @@ protected: static bool isValidNumberLiteral(std::string const& _literal); private: - bool m_julia = false; + AsmFlavour m_flavour = AsmFlavour::Loose; }; } -- cgit v1.2.3