diff options
author | chriseth <chris@ethereum.org> | 2018-12-13 19:56:53 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-12-13 20:00:59 +0800 |
commit | 6101258248567b0e670a1fc9226159d7f6687eef (patch) | |
tree | fdae75b9db8cad0226392fb50e9491f3be88f45e /libyul/AsmPrinter.cpp | |
parent | 642c69f935c41d70f0dcfb0e89fcf3e626f7b38f (diff) | |
download | dexon-solidity-6101258248567b0e670a1fc9226159d7f6687eef.tar.gz dexon-solidity-6101258248567b0e670a1fc9226159d7f6687eef.tar.zst dexon-solidity-6101258248567b0e670a1fc9226159d7f6687eef.zip |
AsmPrinter functions should be const.
Diffstat (limited to 'libyul/AsmPrinter.cpp')
-rw-r--r-- | libyul/AsmPrinter.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index eaaba9f3..a5b14953 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -40,14 +40,14 @@ using namespace dev::solidity; //@TODO source locations -string AsmPrinter::operator()(yul::Instruction const& _instruction) +string AsmPrinter::operator()(yul::Instruction const& _instruction) const { solAssert(!m_yul, ""); solAssert(isValidInstruction(_instruction.instruction), "Invalid instruction"); return boost::to_lower_copy(instructionInfo(_instruction.instruction).name); } -string AsmPrinter::operator()(Literal const& _literal) +string AsmPrinter::operator()(Literal const& _literal) const { switch (_literal.kind) { @@ -90,13 +90,13 @@ string AsmPrinter::operator()(Literal const& _literal) return "\"" + out + "\"" + appendTypeName(_literal.type); } -string AsmPrinter::operator()(Identifier const& _identifier) +string AsmPrinter::operator()(Identifier const& _identifier) const { solAssert(!_identifier.name.empty(), "Invalid identifier."); return _identifier.name.str(); } -string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstruction) +string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstruction) const { solAssert(!m_yul, ""); solAssert(isValidInstruction(_functionalInstruction.instruction), "Invalid instruction"); @@ -109,26 +109,26 @@ string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstructio ")"; } -string AsmPrinter::operator()(ExpressionStatement const& _statement) +string AsmPrinter::operator()(ExpressionStatement const& _statement) const { return boost::apply_visitor(*this, _statement.expression); } -string AsmPrinter::operator()(Label const& _label) +string AsmPrinter::operator()(Label const& _label) const { solAssert(!m_yul, ""); solAssert(!_label.name.empty(), "Invalid label."); return _label.name.str() + ":"; } -string AsmPrinter::operator()(StackAssignment const& _assignment) +string AsmPrinter::operator()(StackAssignment const& _assignment) const { solAssert(!m_yul, ""); solAssert(!_assignment.variableName.name.empty(), "Invalid variable name."); return "=: " + (*this)(_assignment.variableName); } -string AsmPrinter::operator()(Assignment const& _assignment) +string AsmPrinter::operator()(Assignment const& _assignment) const { solAssert(_assignment.variableNames.size() >= 1, ""); string variables = (*this)(_assignment.variableNames.front()); @@ -137,7 +137,7 @@ string AsmPrinter::operator()(Assignment const& _assignment) return variables + " := " + boost::apply_visitor(*this, *_assignment.value); } -string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) +string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) const { string out = "let "; out += boost::algorithm::join( @@ -154,7 +154,7 @@ string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) return out; } -string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) +string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) const { solAssert(!_functionDefinition.name.empty(), "Invalid function name."); string out = "function " + _functionDefinition.name.str() + "("; @@ -179,7 +179,7 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) return out + "\n" + (*this)(_functionDefinition.body); } -string AsmPrinter::operator()(FunctionCall const& _functionCall) +string AsmPrinter::operator()(FunctionCall const& _functionCall) const { return (*this)(_functionCall.functionName) + "(" + @@ -189,13 +189,13 @@ string AsmPrinter::operator()(FunctionCall const& _functionCall) ")"; } -string AsmPrinter::operator()(If const& _if) +string AsmPrinter::operator()(If const& _if) const { solAssert(_if.condition, "Invalid if condition."); return "if " + boost::apply_visitor(*this, *_if.condition) + "\n" + (*this)(_if.body); } -string AsmPrinter::operator()(Switch const& _switch) +string AsmPrinter::operator()(Switch const& _switch) const { solAssert(_switch.expression, "Invalid expression pointer."); string out = "switch " + boost::apply_visitor(*this, *_switch.expression); @@ -210,7 +210,7 @@ string AsmPrinter::operator()(Switch const& _switch) return out; } -string AsmPrinter::operator()(ForLoop const& _forLoop) +string AsmPrinter::operator()(ForLoop const& _forLoop) const { solAssert(_forLoop.condition, "Invalid for loop condition."); string out = "for "; @@ -224,7 +224,7 @@ string AsmPrinter::operator()(ForLoop const& _forLoop) return out; } -string AsmPrinter::operator()(Block const& _block) +string AsmPrinter::operator()(Block const& _block) const { if (_block.statements.empty()) return "{\n}"; |