mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! Type inference draft.
This commit is contained in:
parent
319a6c4999
commit
761f5b342f
@ -2500,6 +2500,7 @@ private:
|
|||||||
ASTPointer<VariableDeclaration> m_typeVariable;
|
ASTPointer<VariableDeclaration> m_typeVariable;
|
||||||
std::vector<ASTPointer<ASTNode>> m_subNodes;
|
std::vector<ASTPointer<ASTNode>> m_subNodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TypeClassInstantiation: public ASTNode, public ScopeOpener
|
class TypeClassInstantiation: public ASTNode, public ScopeOpener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -2590,6 +2591,7 @@ public:
|
|||||||
bool experimentalSolidityOnly() const override { return true; }
|
bool experimentalSolidityOnly() const override { return true; }
|
||||||
|
|
||||||
std::variant<Token, ASTPointer<IdentifierPath>> name() const { return m_name; }
|
std::variant<Token, ASTPointer<IdentifierPath>> name() const { return m_name; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::variant<Token, ASTPointer<IdentifierPath>> m_name;
|
std::variant<Token, ASTPointer<IdentifierPath>> m_name;
|
||||||
};
|
};
|
||||||
|
@ -63,6 +63,7 @@ class Analysis
|
|||||||
{
|
{
|
||||||
struct AnnotationContainer;
|
struct AnnotationContainer;
|
||||||
struct GlobalAnnotationContainer;
|
struct GlobalAnnotationContainer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Analysis(langutil::ErrorReporter& _errorReporter, uint64_t _maxAstId);
|
Analysis(langutil::ErrorReporter& _errorReporter, uint64_t _maxAstId);
|
||||||
Analysis(Analysis const&) = delete;
|
Analysis(Analysis const&) = delete;
|
||||||
@ -73,30 +74,36 @@ public:
|
|||||||
uint64_t maxAstId() const { return m_maxAstId; }
|
uint64_t maxAstId() const { return m_maxAstId; }
|
||||||
TypeSystem& typeSystem() { return m_typeSystem; }
|
TypeSystem& typeSystem() { return m_typeSystem; }
|
||||||
TypeSystem const& typeSystem() const { return m_typeSystem; }
|
TypeSystem const& typeSystem() const { return m_typeSystem; }
|
||||||
|
|
||||||
template<typename Step>
|
template<typename Step>
|
||||||
typename Step::Annotation& annotation(ASTNode const& _node)
|
typename Step::Annotation& annotation(ASTNode const& _node)
|
||||||
{
|
{
|
||||||
return detail::AnnotationFetcher<Step>{*this}.get(_node);
|
return detail::AnnotationFetcher<Step>{*this}.get(_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Step>
|
template<typename Step>
|
||||||
typename Step::Annotation const& annotation(ASTNode const& _node) const
|
typename Step::Annotation const& annotation(ASTNode const& _node) const
|
||||||
{
|
{
|
||||||
return detail::ConstAnnotationFetcher<Step>{*this}.get(_node);
|
return detail::ConstAnnotationFetcher<Step>{*this}.get(_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Step>
|
template<typename Step>
|
||||||
typename Step::GlobalAnnotation& annotation()
|
typename Step::GlobalAnnotation& annotation()
|
||||||
{
|
{
|
||||||
return detail::AnnotationFetcher<Step>{*this}.get();
|
return detail::AnnotationFetcher<Step>{*this}.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Step>
|
template<typename Step>
|
||||||
typename Step::GlobalAnnotation const& annotation() const
|
typename Step::GlobalAnnotation const& annotation() const
|
||||||
{
|
{
|
||||||
return detail::ConstAnnotationFetcher<Step>{*this}.get();
|
return detail::ConstAnnotationFetcher<Step>{*this}.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotationContainer& annotationContainer(ASTNode const& _node);
|
AnnotationContainer& annotationContainer(ASTNode const& _node);
|
||||||
AnnotationContainer const& annotationContainer(ASTNode const& _node) const;
|
AnnotationContainer const& annotationContainer(ASTNode const& _node) const;
|
||||||
GlobalAnnotationContainer& annotationContainer() { return *m_globalAnnotation; }
|
GlobalAnnotationContainer& annotationContainer() { return *m_globalAnnotation; }
|
||||||
GlobalAnnotationContainer const& annotationContainer() const { return *m_globalAnnotation; }
|
GlobalAnnotationContainer const& annotationContainer() const { return *m_globalAnnotation; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
langutil::ErrorReporter& m_errorReporter;
|
langutil::ErrorReporter& m_errorReporter;
|
||||||
TypeSystem m_typeSystem;
|
TypeSystem m_typeSystem;
|
||||||
|
@ -39,9 +39,9 @@ using namespace solidity::frontend::experimental;
|
|||||||
using namespace solidity::langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
TypeInference::TypeInference(Analysis& _analysis):
|
TypeInference::TypeInference(Analysis& _analysis):
|
||||||
m_analysis(_analysis),
|
m_analysis(_analysis),
|
||||||
m_errorReporter(_analysis.errorReporter()),
|
m_errorReporter(_analysis.errorReporter()),
|
||||||
m_typeSystem(_analysis.typeSystem())
|
m_typeSystem(_analysis.typeSystem())
|
||||||
{
|
{
|
||||||
auto declareBuiltinClass = [&](std::string _name, BuiltinClass _class, auto _memberCreator, Sort _sort = {}) -> TypeClass {
|
auto declareBuiltinClass = [&](std::string _name, BuiltinClass _class, auto _memberCreator, Sort _sort = {}) -> TypeClass {
|
||||||
Type type = m_typeSystem.freshTypeVariable(std::move(_sort));
|
Type type = m_typeSystem.freshTypeVariable(std::move(_sort));
|
||||||
@ -195,6 +195,7 @@ bool TypeInference::visit(TypeClassDefinition const& _typeClassDefinition)
|
|||||||
auto& typeClassAnnotation = annotation(_typeClassDefinition);
|
auto& typeClassAnnotation = annotation(_typeClassDefinition);
|
||||||
if (typeClassAnnotation.type)
|
if (typeClassAnnotation.type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
typeClassAnnotation.type = type(&_typeClassDefinition, {});
|
typeClassAnnotation.type = type(&_typeClassDefinition, {});
|
||||||
{
|
{
|
||||||
ScopedSaveAndRestore expressionContext{m_expressionContext, ExpressionContext::Type};
|
ScopedSaveAndRestore expressionContext{m_expressionContext, ExpressionContext::Type};
|
||||||
|
@ -31,9 +31,9 @@ using namespace solidity::frontend::experimental;
|
|||||||
using namespace solidity::langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
TypeRegistration::TypeRegistration(Analysis& _analysis):
|
TypeRegistration::TypeRegistration(Analysis& _analysis):
|
||||||
m_analysis(_analysis),
|
m_analysis(_analysis),
|
||||||
m_errorReporter(_analysis.errorReporter()),
|
m_errorReporter(_analysis.errorReporter()),
|
||||||
m_typeSystem(_analysis.typeSystem())
|
m_typeSystem(_analysis.typeSystem())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user