mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Eliminate using namespace std.
This commit is contained in:
committed by
Nikola Matic
parent
45f00dda3b
commit
43ca0f0947
@@ -24,7 +24,6 @@
|
||||
|
||||
#include <libyul/AsmPrinter.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
using namespace solidity::util;
|
||||
@@ -33,42 +32,42 @@ using namespace solidity::yul;
|
||||
namespace solidity::frontend::experimental
|
||||
{
|
||||
|
||||
string IRNames::function(TypeEnvironment const& _env, FunctionDefinition const& _function, Type _type)
|
||||
std::string IRNames::function(TypeEnvironment const& _env, FunctionDefinition const& _function, Type _type)
|
||||
{
|
||||
if (_function.isConstructor())
|
||||
return constructor(*_function.annotation().contract);
|
||||
|
||||
return "fun_" + _function.name() + "_" + to_string(_function.id()) + "$" + TypeEnvironmentHelpers{_env}.canonicalTypeName(_type) + "$";
|
||||
return "fun_" + _function.name() + "_" + std::to_string(_function.id()) + "$" + TypeEnvironmentHelpers{_env}.canonicalTypeName(_type) + "$";
|
||||
}
|
||||
|
||||
string IRNames::function(VariableDeclaration const& _varDecl)
|
||||
std::string IRNames::function(VariableDeclaration const& _varDecl)
|
||||
{
|
||||
return "getter_fun_" + _varDecl.name() + "_" + to_string(_varDecl.id());
|
||||
return "getter_fun_" + _varDecl.name() + "_" + std::to_string(_varDecl.id());
|
||||
}
|
||||
|
||||
string IRNames::creationObject(ContractDefinition const& _contract)
|
||||
std::string IRNames::creationObject(ContractDefinition const& _contract)
|
||||
{
|
||||
return _contract.name() + "_" + toString(_contract.id());
|
||||
}
|
||||
|
||||
string IRNames::deployedObject(ContractDefinition const& _contract)
|
||||
std::string IRNames::deployedObject(ContractDefinition const& _contract)
|
||||
{
|
||||
return _contract.name() + "_" + toString(_contract.id()) + "_deployed";
|
||||
}
|
||||
|
||||
string IRNames::constructor(ContractDefinition const& _contract)
|
||||
std::string IRNames::constructor(ContractDefinition const& _contract)
|
||||
{
|
||||
return "constructor_" + _contract.name() + "_" + to_string(_contract.id());
|
||||
return "constructor_" + _contract.name() + "_" + std::to_string(_contract.id());
|
||||
}
|
||||
|
||||
string IRNames::localVariable(VariableDeclaration const& _declaration)
|
||||
std::string IRNames::localVariable(VariableDeclaration const& _declaration)
|
||||
{
|
||||
return "var_" + _declaration.name() + '_' + std::to_string(_declaration.id());
|
||||
}
|
||||
|
||||
string IRNames::localVariable(Expression const& _expression)
|
||||
std::string IRNames::localVariable(Expression const& _expression)
|
||||
{
|
||||
return "expr_" + to_string(_expression.id());
|
||||
return "expr_" + std::to_string(_expression.id());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
|
||||
#include <variant>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
using namespace solidity::frontend::experimental;
|
||||
using namespace solidity::langutil;
|
||||
@@ -64,10 +63,10 @@ m_context{_analysis, &m_env, {}, {}}
|
||||
{
|
||||
}
|
||||
|
||||
string IRGenerator::run(
|
||||
std::string IRGenerator::run(
|
||||
ContractDefinition const& _contract,
|
||||
bytes const& /*_cborMetadata*/,
|
||||
map<ContractDefinition const*, string_view const> const& /*_otherYulSources*/
|
||||
std::map<ContractDefinition const*, std::string_view const> const& /*_otherYulSources*/
|
||||
)
|
||||
{
|
||||
|
||||
@@ -91,7 +90,7 @@ string IRGenerator::run(
|
||||
return t.render();
|
||||
}
|
||||
|
||||
string IRGenerator::generate(ContractDefinition const& _contract)
|
||||
std::string IRGenerator::generate(ContractDefinition const& _contract)
|
||||
{
|
||||
std::stringstream code;
|
||||
code << "{\n";
|
||||
@@ -110,7 +109,7 @@ string IRGenerator::generate(ContractDefinition const& _contract)
|
||||
{
|
||||
auto queueEntry = m_context.functionQueue.front();
|
||||
m_context.functionQueue.pop_front();
|
||||
auto& generatedTypes = m_context.generatedFunctions.insert(std::make_pair(queueEntry.function, vector<Type>{})).first->second;
|
||||
auto& generatedTypes = m_context.generatedFunctions.insert(std::make_pair(queueEntry.function, std::vector<Type>{})).first->second;
|
||||
if (!util::contains_if(generatedTypes, [&](auto const& _generatedType) { return m_context.env->typeEquals(_generatedType, queueEntry.type); }))
|
||||
{
|
||||
generatedTypes.emplace_back(queueEntry.type);
|
||||
@@ -121,7 +120,7 @@ string IRGenerator::generate(ContractDefinition const& _contract)
|
||||
return code.str();
|
||||
}
|
||||
|
||||
string IRGenerator::generate(FunctionDefinition const& _function, Type _type)
|
||||
std::string IRGenerator::generate(FunctionDefinition const& _function, Type _type)
|
||||
{
|
||||
TypeEnvironment newEnv = m_context.env->clone();
|
||||
ScopedSaveAndRestore envRestore{m_context.env, &newEnv};
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include <range/v3/view/drop_last.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
using namespace solidity::util;
|
||||
using namespace solidity::frontend;
|
||||
@@ -54,7 +53,7 @@ struct CopyTranslate: public yul::ASTCopier
|
||||
CopyTranslate(
|
||||
IRGenerationContext const& _context,
|
||||
yul::Dialect const& _dialect,
|
||||
map<yul::Identifier const*, InlineAssemblyAnnotation::ExternalIdentifierInfo> _references
|
||||
std::map<yul::Identifier const*, InlineAssemblyAnnotation::ExternalIdentifierInfo> _references
|
||||
): m_context(_context), m_dialect(_dialect), m_references(std::move(_references)) {}
|
||||
|
||||
using ASTCopier::operator();
|
||||
@@ -83,8 +82,8 @@ struct CopyTranslate: public yul::ASTCopier
|
||||
return ASTCopier::translate(_identifier);
|
||||
|
||||
yul::Expression translated = translateReference(_identifier);
|
||||
solAssert(holds_alternative<yul::Identifier>(translated));
|
||||
return get<yul::Identifier>(std::move(translated));
|
||||
solAssert(std::holds_alternative<yul::Identifier>(translated));
|
||||
return std::get<yul::Identifier>(std::move(translated));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -100,20 +99,20 @@ private:
|
||||
auto type = m_context.analysis.annotation<TypeInference>(*varDecl).type;
|
||||
solAssert(type);
|
||||
solAssert(m_context.env->typeEquals(*type, m_context.analysis.typeSystem().type(PrimitiveType::Word, {})));
|
||||
string value = IRNames::localVariable(*varDecl);
|
||||
std::string value = IRNames::localVariable(*varDecl);
|
||||
return yul::Identifier{_identifier.debugData, yul::YulString{value}};
|
||||
}
|
||||
|
||||
IRGenerationContext const& m_context;
|
||||
yul::Dialect const& m_dialect;
|
||||
map<yul::Identifier const*, InlineAssemblyAnnotation::ExternalIdentifierInfo> m_references;
|
||||
std::map<yul::Identifier const*, InlineAssemblyAnnotation::ExternalIdentifierInfo> m_references;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
bool IRGeneratorForStatements::visit(TupleExpression const& _tupleExpression)
|
||||
{
|
||||
std::vector<string> components;
|
||||
std::vector<std::string> components;
|
||||
for (auto const& component: _tupleExpression.components())
|
||||
{
|
||||
solUnimplementedAssert(component);
|
||||
@@ -130,7 +129,7 @@ bool IRGeneratorForStatements::visit(InlineAssembly const& _assembly)
|
||||
{
|
||||
CopyTranslate bodyCopier{m_context, _assembly.dialect(), _assembly.annotation().externalReferences};
|
||||
yul::Statement modified = bodyCopier(_assembly.operations());
|
||||
solAssert(holds_alternative<yul::Block>(modified));
|
||||
solAssert(std::holds_alternative<yul::Block>(modified));
|
||||
m_code << yul::AsmPrinter()(std::get<yul::Block>(modified)) << "\n";
|
||||
return false;
|
||||
}
|
||||
@@ -223,7 +222,7 @@ TypeRegistration::TypeClassInstantiations const& typeClassInstantiations(IRGener
|
||||
}
|
||||
}
|
||||
|
||||
FunctionDefinition const& IRGeneratorForStatements::resolveTypeClassFunction(TypeClass _class, string _name, Type _type)
|
||||
FunctionDefinition const& IRGeneratorForStatements::resolveTypeClassFunction(TypeClass _class, std::string _name, Type _type)
|
||||
{
|
||||
TypeSystemHelpers helper{m_context.analysis.typeSystem()};
|
||||
|
||||
@@ -232,7 +231,7 @@ FunctionDefinition const& IRGeneratorForStatements::resolveTypeClassFunction(Typ
|
||||
auto typeVars = TypeEnvironmentHelpers{env}.typeVars(genericFunctionType);
|
||||
solAssert(typeVars.size() == 1);
|
||||
solAssert(env.unify(genericFunctionType, _type).empty());
|
||||
auto typeClassInstantiation = get<0>(helper.destTypeConstant(env.resolve(typeVars.front())));
|
||||
auto typeClassInstantiation = std::get<0>(helper.destTypeConstant(env.resolve(typeVars.front())));
|
||||
|
||||
auto const& instantiations = typeClassInstantiations(m_context, _class);
|
||||
TypeClassInstantiation const* instantiation = instantiations.at(typeClassInstantiation);
|
||||
@@ -271,7 +270,7 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
|
||||
solAssert(declaration);
|
||||
if (auto const* typeClassDefinition = dynamic_cast<TypeClassDefinition const*>(declaration))
|
||||
{
|
||||
optional<TypeClass> typeClass = m_context.analysis.annotation<TypeInference>(*typeClassDefinition).typeClass;
|
||||
std::optional<TypeClass> typeClass = m_context.analysis.annotation<TypeInference>(*typeClassDefinition).typeClass;
|
||||
solAssert(typeClass);
|
||||
solAssert(m_expressionDeclaration.emplace(
|
||||
&_memberAccess,
|
||||
@@ -299,7 +298,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
|
||||
{
|
||||
Type functionType = type(_functionCall.expression());
|
||||
auto declaration = m_expressionDeclaration.at(&_functionCall.expression());
|
||||
if (auto builtin = get_if<Builtins>(&declaration))
|
||||
if (auto builtin = std::get_if<Builtins>(&declaration))
|
||||
{
|
||||
switch(*builtin)
|
||||
{
|
||||
@@ -315,7 +314,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
|
||||
}
|
||||
solAssert(false);
|
||||
}
|
||||
FunctionDefinition const* functionDefinition = dynamic_cast<FunctionDefinition const*>(get<Declaration const*>(declaration));
|
||||
FunctionDefinition const* functionDefinition = dynamic_cast<FunctionDefinition const*>(std::get<Declaration const*>(declaration));
|
||||
solAssert(functionDefinition);
|
||||
// TODO: get around resolveRecursive by passing the environment further down?
|
||||
functionType = m_context.env->resolveRecursive(functionType);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <libsolidity/ast/AST.h>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
using namespace solidity::frontend::experimental;
|
||||
using namespace solidity::util;
|
||||
|
||||
Reference in New Issue
Block a user