style fixes

This commit is contained in:
Daniel Kirchner 2023-08-22 17:56:26 +02:00 committed by Nikola Matic
parent 43ca0f0947
commit f7cbddb7d5
12 changed files with 126 additions and 127 deletions

View File

@ -304,7 +304,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
}
std::string name = splitName.front();
auto declarations = m_resolver.nameFromCurrentScope(name);
switch(declarations.size())
switch (declarations.size())
{
case 0:
if (splitName.size() > 1)

View File

@ -1063,7 +1063,7 @@ void TypeClassInstantiation::accept(ASTVisitor& _visitor)
if (_visitor.visit(*this))
{
m_typeConstructor->accept(_visitor);
if(m_argumentSorts)
if (m_argumentSorts)
m_argumentSorts->accept(_visitor);
m_class->accept(_visitor);
listAccept(m_subNodes, _visitor);
@ -1076,7 +1076,7 @@ void TypeClassInstantiation::accept(ASTConstVisitor& _visitor) const
if (_visitor.visit(*this))
{
m_typeConstructor->accept(_visitor);
if(m_argumentSorts)
if (m_argumentSorts)
m_argumentSorts->accept(_visitor);
m_class->accept(_visitor);
listAccept(m_subNodes, _visitor);

View File

@ -216,7 +216,7 @@ bool TypeInference::visit(TypeClassDefinition const& _typeClassDefinition)
if (!functionTypes.emplace(functionDefinition->name(), functionType).second)
m_errorReporter.fatalTypeError(0000_error, functionDefinition->location(), "Function in type class declared multiple times.");
auto typeVars = TypeEnvironmentHelpers{*m_env}.typeVars(functionType);
if(typeVars.size() != 1)
if (typeVars.size() != 1)
m_errorReporter.fatalTypeError(0000_error, functionDefinition->location(), "Function in type class may only depend on the type class variable.");
unify(typeVars.front(), typeVar, functionDefinition->location());
typeMembers[functionDefinition->name()] = TypeMember{functionType};
@ -499,7 +499,7 @@ void TypeInference::endVisit(Assignment const& _assignment)
experimental::Type TypeInference::handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration)
{
switch(m_expressionContext)
switch (m_expressionContext)
{
case ExpressionContext::Term:
{
@ -601,7 +601,7 @@ bool TypeInference::visit(Identifier const& _identifier)
return false;
}
switch(m_expressionContext)
switch (m_expressionContext)
{
case ExpressionContext::Term:
// TODO: error handling
@ -791,9 +791,7 @@ experimental::Type TypeInference::memberType(Type _type, std::string _memberName
{
auto constructor = std::get<0>(helper.destTypeConstant(type));
if (auto* typeMember = util::valueOrNullptr(annotation().members.at(constructor), _memberName))
{
return polymorphicInstance(typeMember->type);
}
else
{
m_errorReporter.typeError(0000_error, _location, fmt::format("Member {} not found in type {}.", _memberName, TypeEnvironmentHelpers{*m_env}.typeToString(_type)));
@ -809,7 +807,7 @@ experimental::Type TypeInference::memberType(Type _type, std::string _memberName
void TypeInference::endVisit(MemberAccess const& _memberAccess)
{
auto &memberAccessAnnotation = annotation(_memberAccess);
auto& memberAccessAnnotation = annotation(_memberAccess);
solAssert(!memberAccessAnnotation.type);
Type expressionType = getType(_memberAccess.expression());
memberAccessAnnotation.type = memberType(expressionType, _memberAccess.memberName(), _memberAccess.location());
@ -865,9 +863,9 @@ void TypeInference::endVisit(FunctionCall const& _functionCall)
TypeSystemHelpers helper{m_typeSystem};
std::vector<Type> argTypes;
for(auto arg: _functionCall.arguments())
for (auto arg: _functionCall.arguments())
{
switch(m_expressionContext)
switch (m_expressionContext)
{
case ExpressionContext::Term:
case ExpressionContext::Type:
@ -880,7 +878,7 @@ void TypeInference::endVisit(FunctionCall const& _functionCall)
}
}
switch(m_expressionContext)
switch (m_expressionContext)
{
case ExpressionContext::Term:
{

View File

@ -61,7 +61,7 @@ bool TypeRegistration::visit(ElementaryTypeName const& _typeName)
if (annotation(_typeName).typeConstructor)
return false;
annotation(_typeName).typeConstructor = [&]() -> std::optional<TypeConstructor> {
switch(_typeName.typeName().token())
switch (_typeName.typeName().token())
{
case Token::Void:
return m_typeSystem.constructor(PrimitiveType::Void);

View File

@ -72,7 +72,7 @@ std::vector<TypeEnvironment::UnificationFailure> TypeEnvironment::unify(Type _a,
failures += instantiate(_var, _a);
},
[&](TypeConstant _left, TypeConstant _right) {
if(_left.constructor != _right.constructor)
if (_left.constructor != _right.constructor)
return unificationFailure();
if (_left.arguments.size() != _right.arguments.size())
return unificationFailure();
@ -98,7 +98,7 @@ bool TypeEnvironment::typeEquals(Type _lhs, Type _rhs) const
return false;
},
[&](TypeConstant _left, TypeConstant _right) {
if(_left.constructor != _right.constructor)
if (_left.constructor != _right.constructor)
return false;
if (_left.arguments.size() != _right.arguments.size())
return false;
@ -133,7 +133,7 @@ TypeSystem::TypeSystem()
m_primitiveTypeClasses.emplace(PrimitiveClass::Type, declarePrimitiveClass("type"));
for (auto [type, name, arity]: std::initializer_list<std::tuple<PrimitiveType, const char*, uint64_t>> {
for (auto [type, name, arity]: std::initializer_list<std::tuple<PrimitiveType, char const*, uint64_t>>{
{PrimitiveType::TypeFunction, "tfun", 2},
{PrimitiveType::Function, "fun", 2},
{PrimitiveType::Function, "itself", 1},
@ -184,7 +184,7 @@ std::vector<TypeEnvironment::UnificationFailure> TypeEnvironment::instantiate(Ty
experimental::Type TypeEnvironment::resolve(Type _type) const
{
Type result = _type;
while(auto const* var = std::get_if<TypeVariable>(&result))
while (auto const* var = std::get_if<TypeVariable>(&result))
if (Type const* resolvedType = util::valueOrNullptr(m_typeVariables, var->index()))
result = *resolvedType;
else

View File

@ -54,7 +54,7 @@ using namespace solidity::frontend::experimental;
std::optional<TypeConstructor> experimental::typeConstructorFromToken(Analysis const& _analysis, langutil::Token _token)
{
TypeSystem const& typeSystem = _analysis.typeSystem();
switch(_token)
switch (_token)
{
case Token::Void:
return typeSystem.builtinConstructor(BuiltinType::Void);
@ -142,7 +142,7 @@ std::vector<experimental::Type> TypeSystemHelpers::destTupleType(Type _tupleType
std::vector<Type> result;
result.emplace_back(arguments.front());
Type tail = arguments.back();
while(true)
while (true)
{
if (!isTypeConstant(tail))
break;
@ -184,7 +184,7 @@ std::vector<experimental::Type> TypeSystemHelpers::destSumType(Type _tupleType)
std::vector<Type> result;
result.emplace_back(arguments.front());
Type tail = arguments.back();
while(true)
while (true)
{
if (!isTypeConstant(tail))
break;

View File

@ -46,7 +46,8 @@ std::string IRGeneratorForStatements::generate(ASTNode const& _node)
}
namespace {
namespace
{
struct CopyTranslate: public yul::ASTCopier
{
@ -300,7 +301,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
auto declaration = m_expressionDeclaration.at(&_functionCall.expression());
if (auto builtin = std::get_if<Builtins>(&declaration))
{
switch(*builtin)
switch (*builtin)
{
case Builtins::FromBool:
case Builtins::Identity:

View File

@ -2076,7 +2076,7 @@ int Parser::tokenPrecedence(Token _token) const
{
if (m_experimentalSolidityEnabledInCurrentSourceUnit)
{
switch(_token)
switch (_token)
{
case Token::Colon:
return 1000;