From 9897c56b2cacf162f8fd41d60e91b7f71863f8d5 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 21 Aug 2017 22:05:24 +0100 Subject: Mark a lot of functions static (where possible) --- libevmasm/ConstantOptimiser.cpp | 4 ++-- libevmasm/ConstantOptimiser.h | 4 ++-- liblll/CodeFragment.h | 4 ++-- libsolidity/ast/ASTJsonConverter.h | 6 +++--- libsolidity/codegen/ABIFunctions.cpp | 2 +- libsolidity/codegen/ABIFunctions.h | 2 +- libsolidity/inlineasm/AsmCodeGen.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index a7a87c35..2efd2dc9 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -159,7 +159,7 @@ AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const return actualCopyRoutine; } -AssemblyItems const& CodeCopyMethod::copyRoutine() const +AssemblyItems const& CodeCopyMethod::copyRoutine() { AssemblyItems static copyRoutine{ u256(0), @@ -234,7 +234,7 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value) } } -bool ComputeMethod::checkRepresentation(u256 const& _value, AssemblyItems const& _routine) const +bool ComputeMethod::checkRepresentation(u256 const& _value, AssemblyItems const& _routine) { // This is a tiny EVM that can only evaluate some instructions. vector stack; diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index 19f14f7a..82982e25 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -121,7 +121,7 @@ public: virtual AssemblyItems execute(Assembly& _assembly) const override; protected: - AssemblyItems const& copyRoutine() const; + static AssemblyItems const& copyRoutine(); }; /** @@ -151,7 +151,7 @@ protected: /// Tries to recursively find a way to compute @a _value. AssemblyItems findRepresentation(u256 const& _value); /// Recomputes the value from the calculated representation and checks for correctness. - bool checkRepresentation(u256 const& _value, AssemblyItems const& _routine) const; + static bool checkRepresentation(u256 const& _value, AssemblyItems const& _routine); bigint gasNeeded(AssemblyItems const& _routine) const; /// Counter for the complexity of optimization, will stop when it reaches zero. diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h index 6622de3e..95d21563 100644 --- a/liblll/CodeFragment.h +++ b/liblll/CodeFragment.h @@ -50,8 +50,8 @@ public: private: void finalise(CompilerState const& _cs); - template void error() const { BOOST_THROW_EXCEPTION(T() ); } - template void error(std::string const& reason) const { + template static void error() { BOOST_THROW_EXCEPTION(T() ); } + template static void error(std::string const& reason) { auto err = T(); err << errinfo_comment(reason); BOOST_THROW_EXCEPTION(err); diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index cc589d4a..186607ce 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -119,7 +119,7 @@ private: ); std::string sourceLocationToString(SourceLocation const& _location) const; std::string namePathToString(std::vector const& _namePath) const; - Json::Value idOrNull(ASTNode const* _pt) const + static Json::Value idOrNull(ASTNode const* _pt) { return _pt ? Json::Value(nodeId(*_pt)) : Json::nullValue; } @@ -134,12 +134,12 @@ private: std::string literalTokenKind(Token::Value _token); std::string type(Expression const& _expression); std::string type(VariableDeclaration const& _varDecl); - int nodeId(ASTNode const& _node) const + static int nodeId(ASTNode const& _node) { return _node.id(); } template - Json::Value getContainerIds(Container const& container) const + static Json::Value getContainerIds(Container const& container) { Json::Value tmp(Json::arrayValue); for (auto const& element: container) diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 2313473f..a2938ed7 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -1056,7 +1056,7 @@ string ABIFunctions::createFunction(string const& _name, function con return _name; } -size_t ABIFunctions::headSize(TypePointers const& _targetTypes) const +size_t ABIFunctions::headSize(TypePointers const& _targetTypes) { size_t headSize = 0; for (auto const& t: _targetTypes) diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h index 103df5ae..e43e2323 100644 --- a/libsolidity/codegen/ABIFunctions.h +++ b/libsolidity/codegen/ABIFunctions.h @@ -162,7 +162,7 @@ private: std::string createFunction(std::string const& _name, std::function const& _creator); /// @returns the size of the static part of the encoding of the given types. - size_t headSize(TypePointers const& _targetTypes) const; + static size_t headSize(TypePointers const& _targetTypes); /// Map from function name to code for a multi-use function. std::map m_requestedFunctions; diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp index 24aa4ba8..6d0c0255 100644 --- a/libsolidity/inlineasm/AsmCodeGen.cpp +++ b/libsolidity/inlineasm/AsmCodeGen.cpp @@ -127,7 +127,7 @@ public: } private: - LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag) const + static LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag) { u256 id = _tag.data(); solAssert(id <= std::numeric_limits::max(), "Tag id too large."); -- cgit