mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
tmp
This commit is contained in:
parent
4a84818669
commit
60e1e53f20
@ -37,10 +37,10 @@ m_analysis(_analysis),
|
|||||||
m_errorReporter(_analysis.errorReporter()),
|
m_errorReporter(_analysis.errorReporter()),
|
||||||
m_typeSystem(_analysis.typeSystem())
|
m_typeSystem(_analysis.typeSystem())
|
||||||
{
|
{
|
||||||
m_voidType = m_typeSystem.builtinType(BuiltinType::Void, {});
|
m_voidType = m_typeSystem.type(BuiltinType::Void, {});
|
||||||
m_wordType = m_typeSystem.builtinType(BuiltinType::Word, {});
|
m_wordType = m_typeSystem.type(BuiltinType::Word, {});
|
||||||
m_integerType = m_typeSystem.builtinType(BuiltinType::Integer, {});
|
m_integerType = m_typeSystem.type(BuiltinType::Integer, {});
|
||||||
m_unitType = m_typeSystem.builtinType(BuiltinType::Unit, {});
|
m_unitType = m_typeSystem.type(BuiltinType::Unit, {});
|
||||||
m_env = &m_typeSystem.env();
|
m_env = &m_typeSystem.env();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ bool TypeInference::visit(FunctionDefinition const& _functionDefinition)
|
|||||||
|
|
||||||
auto typeFromParameterList = [&](ParameterList const* _list) {
|
auto typeFromParameterList = [&](ParameterList const* _list) {
|
||||||
if (!_list)
|
if (!_list)
|
||||||
return m_typeSystem.builtinType(BuiltinType::Unit, {});
|
return m_unitType;
|
||||||
auto& listAnnotation = annotation(*_list);
|
auto& listAnnotation = annotation(*_list);
|
||||||
solAssert(listAnnotation.type);
|
solAssert(listAnnotation.type);
|
||||||
return *listAnnotation.type;
|
return *listAnnotation.type;
|
||||||
|
@ -355,11 +355,6 @@ void TypeSystem::declareTypeConstructor(TypeExpression::Constructor _typeConstru
|
|||||||
solAssert(newlyInserted, "Type constructor already declared.");
|
solAssert(newlyInserted, "Type constructor already declared.");
|
||||||
}
|
}
|
||||||
|
|
||||||
experimental::Type TypeSystem::builtinType(BuiltinType _builtinType, std::vector<Type> _arguments) const
|
|
||||||
{
|
|
||||||
return type(_builtinType, std::move(_arguments));
|
|
||||||
}
|
|
||||||
|
|
||||||
experimental::Type TypeSystem::type(TypeExpression::Constructor _constructor, std::vector<Type> _arguments) const
|
experimental::Type TypeSystem::type(TypeExpression::Constructor _constructor, std::vector<Type> _arguments) const
|
||||||
{
|
{
|
||||||
// TODO: proper error handling
|
// TODO: proper error handling
|
||||||
@ -413,12 +408,12 @@ void TypeSystem::instantiateClass(TypeExpression::Constructor _typeConstructor,
|
|||||||
experimental::Type TypeSystemHelpers::tupleType(vector<Type> _elements) const
|
experimental::Type TypeSystemHelpers::tupleType(vector<Type> _elements) const
|
||||||
{
|
{
|
||||||
if (_elements.empty())
|
if (_elements.empty())
|
||||||
return typeSystem.builtinType(BuiltinType::Unit, {});
|
return typeSystem.type(BuiltinType::Unit, {});
|
||||||
if (_elements.size() == 1)
|
if (_elements.size() == 1)
|
||||||
return _elements.front();
|
return _elements.front();
|
||||||
Type result = _elements.back();
|
Type result = _elements.back();
|
||||||
for (Type type: _elements | ranges::views::reverse | ranges::views::drop_exactly(1))
|
for (Type type: _elements | ranges::views::reverse | ranges::views::drop_exactly(1))
|
||||||
result = typeSystem.builtinType(BuiltinType::Pair, {type, result});
|
result = typeSystem.type(BuiltinType::Pair, {type, result});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,7 +454,7 @@ vector<experimental::Type> TypeSystemHelpers::destTupleType(Type _tupleType) con
|
|||||||
|
|
||||||
experimental::Type TypeSystemHelpers::functionType(experimental::Type _argType, experimental::Type _resultType) const
|
experimental::Type TypeSystemHelpers::functionType(experimental::Type _argType, experimental::Type _resultType) const
|
||||||
{
|
{
|
||||||
return typeSystem.builtinType(BuiltinType::Function, {_argType, _resultType});
|
return typeSystem.type(BuiltinType::Function, {_argType, _resultType});
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple<TypeExpression::Constructor, vector<experimental::Type>> TypeSystemHelpers::destTypeExpression(Type _type) const
|
tuple<TypeExpression::Constructor, vector<experimental::Type>> TypeSystemHelpers::destTypeExpression(Type _type) const
|
||||||
|
@ -148,7 +148,6 @@ public:
|
|||||||
TypeSystem() {}
|
TypeSystem() {}
|
||||||
TypeSystem(TypeSystem const&) = delete;
|
TypeSystem(TypeSystem const&) = delete;
|
||||||
TypeSystem const& operator=(TypeSystem const&) = delete;
|
TypeSystem const& operator=(TypeSystem const&) = delete;
|
||||||
Type builtinType(BuiltinType _builtinType, std::vector<Type> _arguments) const;
|
|
||||||
Type type(TypeExpression::Constructor _typeConstructor, std::vector<Type> _arguments) const;
|
Type type(TypeExpression::Constructor _typeConstructor, std::vector<Type> _arguments) const;
|
||||||
std::string typeName(TypeExpression::Constructor _typeConstructor) const
|
std::string typeName(TypeExpression::Constructor _typeConstructor) const
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ private:
|
|||||||
auto type = m_context.analysis.annotation<TypeInference>(*varDecl).type;
|
auto type = m_context.analysis.annotation<TypeInference>(*varDecl).type;
|
||||||
solAssert(type);
|
solAssert(type);
|
||||||
type = m_context.env->resolve(*type);
|
type = m_context.env->resolve(*type);
|
||||||
solAssert(*type == m_context.analysis.typeSystem().builtinType(BuiltinType::Word, {}));
|
solAssert(*type == m_context.analysis.typeSystem().type(BuiltinType::Word, {}));
|
||||||
string value = IRNames::localVariable(*varDecl);
|
string value = IRNames::localVariable(*varDecl);
|
||||||
return yul::Identifier{_identifier.debugData, yul::YulString{value}};
|
return yul::Identifier{_identifier.debugData, yul::YulString{value}};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user