mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
style fixes
This commit is contained in:
parent
43ca0f0947
commit
f7cbddb7d5
@ -307,8 +307,8 @@ namespace TokenTraits
|
||||
constexpr bool isElementaryTypeName(Token tok)
|
||||
{
|
||||
return (Token::Int <= tok && tok < Token::TypesEnd) ||
|
||||
tok == Token::Word || tok == Token::Void || tok == Token::Integer ||
|
||||
tok == Token::Pair || tok == Token::Unit || tok == Token::Fun;
|
||||
tok == Token::Word || tok == Token::Void || tok == Token::Integer ||
|
||||
tok == Token::Pair || tok == Token::Unit || tok == Token::Fun;
|
||||
}
|
||||
constexpr bool isAssignmentOp(Token tok) { return Token::Assign <= tok && tok <= Token::AssignMod; }
|
||||
constexpr bool isBinaryOp(Token op) { return Token::Comma <= op && op <= Token::Exp; }
|
||||
@ -344,7 +344,7 @@ namespace TokenTraits
|
||||
constexpr bool isBuiltinTypeClassName(Token tok)
|
||||
{
|
||||
return tok == Token::Integer || (isBinaryOp(tok) && tok != Token::Comma) ||
|
||||
isCompareOp(tok) || isUnaryOp(tok) || (isAssignmentOp(tok) && tok != Token::Assign);
|
||||
isCompareOp(tok) || isUnaryOp(tok) || (isAssignmentOp(tok) && tok != Token::Assign);
|
||||
}
|
||||
constexpr bool isExperimentalSolidityKeyword(Token tok)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -2511,11 +2511,11 @@ public:
|
||||
ASTPointer<TypeClassName> _class,
|
||||
std::vector<ASTPointer<ASTNode>> _subNodes
|
||||
):
|
||||
ASTNode(_id, _location),
|
||||
m_typeConstructor(std::move(_typeConstructor)),
|
||||
m_argumentSorts(std::move(_argumentSorts)),
|
||||
m_class(std::move(_class)),
|
||||
m_subNodes(std::move(_subNodes))
|
||||
ASTNode(_id, _location),
|
||||
m_typeConstructor(std::move(_typeConstructor)),
|
||||
m_argumentSorts(std::move(_argumentSorts)),
|
||||
m_class(std::move(_class)),
|
||||
m_subNodes(std::move(_subNodes))
|
||||
{}
|
||||
|
||||
void accept(ASTVisitor& _visitor) override;
|
||||
|
@ -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);
|
||||
|
@ -128,20 +128,20 @@ bool Analysis::check(std::vector<std::shared_ptr<SourceUnit const>> const& _sour
|
||||
return ([&](auto&& _step) {
|
||||
for (auto source: _sourceUnits)
|
||||
if (!_step.analyze(*source))
|
||||
return false;
|
||||
return false;
|
||||
return true;
|
||||
}(std::tuple_element_t<decltype(_indexTuple)::value, AnalysisSteps>{*this}) && ...);
|
||||
}, makeIndexTuple(std::make_index_sequence<std::tuple_size_v<AnalysisSteps>>{}));
|
||||
|
||||
/*
|
||||
{
|
||||
{
|
||||
SyntaxRestrictor syntaxRestrictor{*this};
|
||||
for (auto source: _sourceUnits)
|
||||
if (!syntaxRestrictor.analyze(*source))
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
TypeRegistration typeRegistration{*this};
|
||||
for (auto source: _sourceUnits)
|
||||
if (!typeRegistration.analyze(*source))
|
||||
|
@ -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());
|
||||
@ -820,22 +818,22 @@ bool TypeInference::visit(TypeDefinition const& _typeDefinition)
|
||||
TypeSystemHelpers helper{m_typeSystem};
|
||||
auto& typeDefinitionAnnotation = annotation(_typeDefinition);
|
||||
if (typeDefinitionAnnotation.type)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if (_typeDefinition.arguments())
|
||||
_typeDefinition.arguments()->accept(*this);
|
||||
_typeDefinition.arguments()->accept(*this);
|
||||
|
||||
std::optional<Type> underlyingType;
|
||||
if (_typeDefinition.typeExpression())
|
||||
{
|
||||
ScopedSaveAndRestore expressionContext{m_expressionContext, ExpressionContext::Type};
|
||||
_typeDefinition.typeExpression()->accept(*this);
|
||||
underlyingType = annotation(*_typeDefinition.typeExpression()).type;
|
||||
ScopedSaveAndRestore expressionContext{m_expressionContext, ExpressionContext::Type};
|
||||
_typeDefinition.typeExpression()->accept(*this);
|
||||
underlyingType = annotation(*_typeDefinition.typeExpression()).type;
|
||||
}
|
||||
|
||||
std::vector<Type> arguments;
|
||||
if (_typeDefinition.arguments())
|
||||
for (size_t i = 0; i < _typeDefinition.arguments()->parameters().size(); ++i)
|
||||
for (size_t i = 0; i < _typeDefinition.arguments()->parameters().size(); ++i)
|
||||
arguments.emplace_back(m_typeSystem.freshTypeVariable({}));
|
||||
|
||||
Type definedType = type(&_typeDefinition, arguments);
|
||||
@ -865,43 +863,43 @@ 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)
|
||||
{
|
||||
case ExpressionContext::Term:
|
||||
case ExpressionContext::Type:
|
||||
switch (m_expressionContext)
|
||||
{
|
||||
case ExpressionContext::Term:
|
||||
case ExpressionContext::Type:
|
||||
argTypes.emplace_back(getType(*arg));
|
||||
break;
|
||||
case ExpressionContext::Sort:
|
||||
case ExpressionContext::Sort:
|
||||
m_errorReporter.typeError(0000_error, _functionCall.location(), "Function call in sort context.");
|
||||
functionCallAnnotation.type = m_typeSystem.freshTypeVariable({});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch(m_expressionContext)
|
||||
switch (m_expressionContext)
|
||||
{
|
||||
case ExpressionContext::Term:
|
||||
{
|
||||
Type argTuple = helper.tupleType(argTypes);
|
||||
Type resultType = m_typeSystem.freshTypeVariable({});
|
||||
Type genericFunctionType = helper.functionType(argTuple, resultType);
|
||||
unify(functionType, genericFunctionType, _functionCall.location());
|
||||
functionCallAnnotation.type = resultType;
|
||||
break;
|
||||
Type argTuple = helper.tupleType(argTypes);
|
||||
Type resultType = m_typeSystem.freshTypeVariable({});
|
||||
Type genericFunctionType = helper.functionType(argTuple, resultType);
|
||||
unify(functionType, genericFunctionType, _functionCall.location());
|
||||
functionCallAnnotation.type = resultType;
|
||||
break;
|
||||
}
|
||||
case ExpressionContext::Type:
|
||||
{
|
||||
Type argTuple = helper.tupleType(argTypes);
|
||||
Type resultType = m_typeSystem.freshTypeVariable({});
|
||||
Type genericFunctionType = helper.typeFunctionType(argTuple, resultType);
|
||||
unify(functionType, genericFunctionType, _functionCall.location());
|
||||
functionCallAnnotation.type = resultType;
|
||||
break;
|
||||
Type argTuple = helper.tupleType(argTypes);
|
||||
Type resultType = m_typeSystem.freshTypeVariable({});
|
||||
Type genericFunctionType = helper.typeFunctionType(argTuple, resultType);
|
||||
unify(functionType, genericFunctionType, _functionCall.location());
|
||||
functionCallAnnotation.type = resultType;
|
||||
break;
|
||||
}
|
||||
case ExpressionContext::Sort:
|
||||
solAssert(false);
|
||||
solAssert(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -914,10 +912,10 @@ std::optional<rational> parseRational(std::string const& _value)
|
||||
rational value;
|
||||
try
|
||||
{
|
||||
auto radixPoint = find(_value.begin(), _value.end(), '.');
|
||||
auto radixPoint = find(_value.begin(), _value.end(), '.');
|
||||
|
||||
if (radixPoint != _value.end())
|
||||
{
|
||||
if (radixPoint != _value.end())
|
||||
{
|
||||
if (
|
||||
!all_of(radixPoint + 1, _value.end(), util::isDigit) ||
|
||||
!all_of(_value.begin(), radixPoint, util::isDigit)
|
||||
@ -941,14 +939,14 @@ std::optional<rational> parseRational(std::string const& _value)
|
||||
);
|
||||
numerator = bigint(std::string(_value.begin(), radixPoint));
|
||||
value = numerator + denominator;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
value = bigint(_value);
|
||||
return value;
|
||||
return value;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return std::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -964,19 +962,19 @@ std::optional<rational> rationalValue(Literal const& _literal)
|
||||
rational value;
|
||||
try
|
||||
{
|
||||
ASTString valueString = _literal.valueWithoutUnderscores();
|
||||
ASTString valueString = _literal.valueWithoutUnderscores();
|
||||
|
||||
auto expPoint = find(valueString.begin(), valueString.end(), 'e');
|
||||
if (expPoint == valueString.end())
|
||||
auto expPoint = find(valueString.begin(), valueString.end(), 'e');
|
||||
if (expPoint == valueString.end())
|
||||
expPoint = find(valueString.begin(), valueString.end(), 'E');
|
||||
|
||||
if (boost::starts_with(valueString, "0x"))
|
||||
{
|
||||
if (boost::starts_with(valueString, "0x"))
|
||||
{
|
||||
// process as hex
|
||||
value = bigint(valueString);
|
||||
}
|
||||
else if (expPoint != valueString.end())
|
||||
{
|
||||
}
|
||||
else if (expPoint != valueString.end())
|
||||
{
|
||||
// Parse mantissa and exponent. Checks numeric limit.
|
||||
std::optional<rational> mantissa = parseRational(std::string(valueString.begin(), expPoint));
|
||||
|
||||
@ -1013,47 +1011,47 @@ std::optional<rational> rationalValue(Literal const& _literal)
|
||||
expAbs
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
// parse as rational number
|
||||
std::optional<rational> tmp = parseRational(valueString);
|
||||
if (!tmp)
|
||||
return std::nullopt;
|
||||
value = *tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return std::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
switch (_literal.subDenomination())
|
||||
{
|
||||
case Literal::SubDenomination::None:
|
||||
case Literal::SubDenomination::Wei:
|
||||
case Literal::SubDenomination::Second:
|
||||
break;
|
||||
break;
|
||||
case Literal::SubDenomination::Gwei:
|
||||
value *= bigint("1000000000");
|
||||
break;
|
||||
value *= bigint("1000000000");
|
||||
break;
|
||||
case Literal::SubDenomination::Ether:
|
||||
value *= bigint("1000000000000000000");
|
||||
break;
|
||||
value *= bigint("1000000000000000000");
|
||||
break;
|
||||
case Literal::SubDenomination::Minute:
|
||||
value *= bigint("60");
|
||||
break;
|
||||
value *= bigint("60");
|
||||
break;
|
||||
case Literal::SubDenomination::Hour:
|
||||
value *= bigint("3600");
|
||||
break;
|
||||
value *= bigint("3600");
|
||||
break;
|
||||
case Literal::SubDenomination::Day:
|
||||
value *= bigint("86400");
|
||||
break;
|
||||
value *= bigint("86400");
|
||||
break;
|
||||
case Literal::SubDenomination::Week:
|
||||
value *= bigint("604800");
|
||||
break;
|
||||
value *= bigint("604800");
|
||||
break;
|
||||
case Literal::SubDenomination::Year:
|
||||
value *= bigint("31536000");
|
||||
break;
|
||||
value *= bigint("31536000");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -1065,19 +1063,19 @@ bool TypeInference::visit(Literal const& _literal)
|
||||
auto& literalAnnotation = annotation(_literal);
|
||||
if (_literal.token() != Token::Number)
|
||||
{
|
||||
m_errorReporter.typeError(0000_error, _literal.location(), "Only number literals are supported.");
|
||||
return false;
|
||||
m_errorReporter.typeError(0000_error, _literal.location(), "Only number literals are supported.");
|
||||
return false;
|
||||
}
|
||||
std::optional<rational> value = rationalValue(_literal);
|
||||
if (!value)
|
||||
{
|
||||
m_errorReporter.typeError(0000_error, _literal.location(), "Invalid number literals.");
|
||||
return false;
|
||||
m_errorReporter.typeError(0000_error, _literal.location(), "Invalid number literals.");
|
||||
return false;
|
||||
}
|
||||
if (value->denominator() != 1)
|
||||
{
|
||||
m_errorReporter.typeError(0000_error, _literal.location(), "Only integers are supported.");
|
||||
return false;
|
||||
m_errorReporter.typeError(0000_error, _literal.location(), "Only integers are supported.");
|
||||
return false;
|
||||
}
|
||||
literalAnnotation.type = m_typeSystem.freshTypeVariable(Sort{{annotation().builtinClasses.at(BuiltinClass::Integer)}});
|
||||
return false;
|
||||
@ -1091,7 +1089,7 @@ TypeRegistration::TypeClassInstantiations const& typeClassInstantiations(Analysi
|
||||
{
|
||||
auto const* typeClassDeclaration = _analysis.typeSystem().typeClassDeclaration(_class);
|
||||
if (typeClassDeclaration)
|
||||
return _analysis.annotation<TypeRegistration>(*typeClassDeclaration).instantiations;
|
||||
return _analysis.annotation<TypeRegistration>(*typeClassDeclaration).instantiations;
|
||||
// TODO: better mechanism than fetching by name.
|
||||
auto& annotation = _analysis.annotation<TypeRegistration>();
|
||||
auto& inferenceAnnotation = _analysis.annotation<TypeInference>();
|
||||
|
@ -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);
|
||||
|
@ -72,12 +72,12 @@ std::vector<TypeEnvironment::UnificationFailure> TypeEnvironment::unify(Type _a,
|
||||
failures += instantiate(_var, _a);
|
||||
},
|
||||
[&](TypeConstant _left, TypeConstant _right) {
|
||||
if(_left.constructor != _right.constructor)
|
||||
return unificationFailure();
|
||||
if (_left.arguments.size() != _right.arguments.size())
|
||||
return unificationFailure();
|
||||
for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments))
|
||||
failures += unify(left, right);
|
||||
if (_left.constructor != _right.constructor)
|
||||
return unificationFailure();
|
||||
if (_left.arguments.size() != _right.arguments.size())
|
||||
return unificationFailure();
|
||||
for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments))
|
||||
failures += unify(left, right);
|
||||
},
|
||||
[&](auto, auto) {
|
||||
unificationFailure();
|
||||
@ -98,14 +98,14 @@ bool TypeEnvironment::typeEquals(Type _lhs, Type _rhs) const
|
||||
return false;
|
||||
},
|
||||
[&](TypeConstant _left, TypeConstant _right) {
|
||||
if(_left.constructor != _right.constructor)
|
||||
return false;
|
||||
if (_left.arguments.size() != _right.arguments.size())
|
||||
return false;
|
||||
for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments))
|
||||
if (!typeEquals(left, right))
|
||||
return false;
|
||||
return true;
|
||||
if (_left.constructor != _right.constructor)
|
||||
return false;
|
||||
if (_left.arguments.size() != _right.arguments.size())
|
||||
return false;
|
||||
for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments))
|
||||
if (!typeEquals(left, right))
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
[&](auto, auto) {
|
||||
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
|
||||
|
@ -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;
|
||||
@ -338,22 +338,22 @@ std::string TypeEnvironmentHelpers::typeToString(Type const& _type) const
|
||||
{
|
||||
std::map<TypeConstructor, std::function<std::string(std::vector<Type>)>> formatters{
|
||||
{env.typeSystem().constructor(PrimitiveType::Function), [&](auto const& _args) {
|
||||
solAssert(_args.size() == 2);
|
||||
return fmt::format("{} -> {}", typeToString(_args.front()), typeToString(_args.back()));
|
||||
}},
|
||||
solAssert(_args.size() == 2);
|
||||
return fmt::format("{} -> {}", typeToString(_args.front()), typeToString(_args.back()));
|
||||
}},
|
||||
{env.typeSystem().constructor(PrimitiveType::Unit), [&](auto const& _args) {
|
||||
solAssert(_args.size() == 0);
|
||||
return "()";
|
||||
}},
|
||||
solAssert(_args.size() == 0);
|
||||
return "()";
|
||||
}},
|
||||
{env.typeSystem().constructor(PrimitiveType::Pair), [&](auto const& _arguments) {
|
||||
auto tupleTypes = TypeSystemHelpers{env.typeSystem()}.destTupleType(_arguments.back());
|
||||
std::string result = "(";
|
||||
result += typeToString(_arguments.front());
|
||||
for (auto type: tupleTypes)
|
||||
result += ", " + typeToString(type);
|
||||
result += ")";
|
||||
return result;
|
||||
}},
|
||||
auto tupleTypes = TypeSystemHelpers{env.typeSystem()}.destTupleType(_arguments.back());
|
||||
std::string result = "(";
|
||||
result += typeToString(_arguments.front());
|
||||
for (auto type: tupleTypes)
|
||||
result += ", " + typeToString(type);
|
||||
result += ")";
|
||||
return result;
|
||||
}},
|
||||
};
|
||||
return std::visit(util::GenericVisitor{
|
||||
[&](TypeConstant const& _type) {
|
||||
|
@ -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:
|
||||
|
@ -486,7 +486,7 @@ bool CompilerStack::analyze()
|
||||
for (Source const* source: m_sourceOrder)
|
||||
if (source->ast && !docStringTagParser.parseDocStrings(*source->ast))
|
||||
noErrors = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Requires DocStringTagParser
|
||||
for (Source const* source: m_sourceOrder)
|
||||
|
@ -2076,7 +2076,7 @@ int Parser::tokenPrecedence(Token _token) const
|
||||
{
|
||||
if (m_experimentalSolidityEnabledInCurrentSourceUnit)
|
||||
{
|
||||
switch(_token)
|
||||
switch (_token)
|
||||
{
|
||||
case Token::Colon:
|
||||
return 1000;
|
||||
|
Loading…
Reference in New Issue
Block a user