Move all file specific globals to anonymous namespace

This commit is contained in:
Alex Beregszaszi 2017-08-29 01:01:47 +01:00
parent b364bd048f
commit 7fb4a64136
8 changed files with 36 additions and 5 deletions

View File

@ -35,6 +35,9 @@
using namespace std;
using namespace dev;
namespace
{
template <typename _T>
inline _T contentsGeneric(std::string const& _file)
{
@ -56,6 +59,8 @@ inline _T contentsGeneric(std::string const& _file)
return ret;
}
}
string dev::contentsString(string const& _file)
{
return contentsGeneric<string>(_file);

View File

@ -24,6 +24,8 @@
using namespace std;
using namespace dev;
namespace
{
bytes toLittleEndian(size_t _size)
{
@ -59,6 +61,8 @@ h256 swarmHashIntermediate(string const& _input, size_t _offset, size_t _length)
return swarmHashSimple(ref, _length);
}
}
h256 dev::swarmHash(string const& _input)
{
return swarmHashIntermediate(_input, 0, _input.size());

View File

@ -30,6 +30,9 @@ using namespace dev;
// TODO: Extend this to use the tools from ExpressionClasses.cpp
namespace
{
struct OptimiserState
{
AssemblyItems const& items;
@ -246,6 +249,8 @@ void applyMethods(OptimiserState& _state, Method, OtherMethods... _other)
applyMethods(_state, _other...);
}
}
bool PeepholeOptimiser::optimise()
{
OptimiserState state {m_items, 0, std::back_inserter(m_optimisedItems)};

View File

@ -304,6 +304,9 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition
return members;
}
namespace
{
bool isValidShiftAndAmountType(Token::Value _operator, Type const& _shiftAmountType)
{
// Disable >>> here.
@ -317,6 +320,8 @@ bool isValidShiftAndAmountType(Token::Value _operator, Type const& _shiftAmountT
return false;
}
}
IntegerType::IntegerType(int _bits, IntegerType::Modifier _modifier):
m_bits(_bits), m_modifier(_modifier)
{

View File

@ -39,6 +39,9 @@ using namespace std;
using namespace dev;
using namespace dev::solidity;
namespace
{
/**
* Simple helper class to ensure that the stack height is the same at certain places in the code.
*/
@ -53,6 +56,8 @@ private:
unsigned stackHeight;
};
}
void ContractCompiler::compileContract(
ContractDefinition const& _contract,
std::map<const ContractDefinition*, eth::Assembly const*> const& _contracts

View File

@ -39,7 +39,7 @@ static string const VersionString =
(string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) +
(string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO));
void help()
static void help()
{
cout
<< "Usage lllc [OPTIONS] <file>" << endl
@ -54,7 +54,7 @@ void help()
exit(0);
}
void version()
static void version()
{
cout << "LLLC, the Lovely Little Language Compiler " << endl;
cout << "Version: " << VersionString << endl;
@ -74,7 +74,7 @@ specified default locale if it is valid, and if not then it will modify the
environment the process is running in to use a sensible default. This also means
that users do not need to install language packs for their OS.
*/
void setDefaultOrCLocale()
static void setDefaultOrCLocale()
{
#if __unix__
if (!std::setlocale(LC_ALL, ""))

View File

@ -31,8 +31,8 @@ using namespace dev::test;
namespace // anonymous
{
h256 const EmptyTrie("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421");
}
h256 const EmptyTrie("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421");
string getIPCSocketPath()
{
@ -43,6 +43,8 @@ string getIPCSocketPath()
return ipcPath;
}
}
ExecutionFramework::ExecutionFramework() :
m_rpc(RPCSession::instance(getIPCSocketPath())),
m_optimize(dev::test::Options::get().optimize),

View File

@ -40,6 +40,9 @@ typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, cha
extern char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
}
namespace
{
bool quiet = false;
string contains(string const& _haystack, vector<string> const& _needles)
@ -169,6 +172,8 @@ void testCompiler()
}
}
}
int main(int argc, char** argv)
{
po::options_description options(