Mark a lot of functions static (where possible)

This commit is contained in:
Alex Beregszaszi 2017-08-21 22:05:24 +01:00
parent 2a5772cff7
commit 9897c56b2c
7 changed files with 12 additions and 12 deletions

View File

@ -159,7 +159,7 @@ AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const
return actualCopyRoutine; return actualCopyRoutine;
} }
AssemblyItems const& CodeCopyMethod::copyRoutine() const AssemblyItems const& CodeCopyMethod::copyRoutine()
{ {
AssemblyItems static copyRoutine{ AssemblyItems static copyRoutine{
u256(0), 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. // This is a tiny EVM that can only evaluate some instructions.
vector<u256> stack; vector<u256> stack;

View File

@ -121,7 +121,7 @@ public:
virtual AssemblyItems execute(Assembly& _assembly) const override; virtual AssemblyItems execute(Assembly& _assembly) const override;
protected: protected:
AssemblyItems const& copyRoutine() const; static AssemblyItems const& copyRoutine();
}; };
/** /**
@ -151,7 +151,7 @@ protected:
/// Tries to recursively find a way to compute @a _value. /// Tries to recursively find a way to compute @a _value.
AssemblyItems findRepresentation(u256 const& _value); AssemblyItems findRepresentation(u256 const& _value);
/// Recomputes the value from the calculated representation and checks for correctness. /// 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; bigint gasNeeded(AssemblyItems const& _routine) const;
/// Counter for the complexity of optimization, will stop when it reaches zero. /// Counter for the complexity of optimization, will stop when it reaches zero.

View File

@ -50,8 +50,8 @@ public:
private: private:
void finalise(CompilerState const& _cs); void finalise(CompilerState const& _cs);
template <class T> void error() const { BOOST_THROW_EXCEPTION(T() ); } template <class T> static void error() { BOOST_THROW_EXCEPTION(T() ); }
template <class T> void error(std::string const& reason) const { template <class T> static void error(std::string const& reason) {
auto err = T(); auto err = T();
err << errinfo_comment(reason); err << errinfo_comment(reason);
BOOST_THROW_EXCEPTION(err); BOOST_THROW_EXCEPTION(err);

View File

@ -119,7 +119,7 @@ private:
); );
std::string sourceLocationToString(SourceLocation const& _location) const; std::string sourceLocationToString(SourceLocation const& _location) const;
std::string namePathToString(std::vector<ASTString> const& _namePath) const; std::string namePathToString(std::vector<ASTString> 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; return _pt ? Json::Value(nodeId(*_pt)) : Json::nullValue;
} }
@ -134,12 +134,12 @@ private:
std::string literalTokenKind(Token::Value _token); std::string literalTokenKind(Token::Value _token);
std::string type(Expression const& _expression); std::string type(Expression const& _expression);
std::string type(VariableDeclaration const& _varDecl); std::string type(VariableDeclaration const& _varDecl);
int nodeId(ASTNode const& _node) const static int nodeId(ASTNode const& _node)
{ {
return _node.id(); return _node.id();
} }
template<class Container> template<class Container>
Json::Value getContainerIds(Container const& container) const static Json::Value getContainerIds(Container const& container)
{ {
Json::Value tmp(Json::arrayValue); Json::Value tmp(Json::arrayValue);
for (auto const& element: container) for (auto const& element: container)

View File

@ -1056,7 +1056,7 @@ string ABIFunctions::createFunction(string const& _name, function<string ()> con
return _name; return _name;
} }
size_t ABIFunctions::headSize(TypePointers const& _targetTypes) const size_t ABIFunctions::headSize(TypePointers const& _targetTypes)
{ {
size_t headSize = 0; size_t headSize = 0;
for (auto const& t: _targetTypes) for (auto const& t: _targetTypes)

View File

@ -162,7 +162,7 @@ private:
std::string createFunction(std::string const& _name, std::function<std::string()> const& _creator); std::string createFunction(std::string const& _name, std::function<std::string()> const& _creator);
/// @returns the size of the static part of the encoding of the given types. /// @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. /// Map from function name to code for a multi-use function.
std::map<std::string, std::string> m_requestedFunctions; std::map<std::string, std::string> m_requestedFunctions;

View File

@ -127,7 +127,7 @@ public:
} }
private: private:
LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag) const static LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag)
{ {
u256 id = _tag.data(); u256 id = _tag.data();
solAssert(id <= std::numeric_limits<LabelID>::max(), "Tag id too large."); solAssert(id <= std::numeric_limits<LabelID>::max(), "Tag id too large.");