class Crystal::TypeGuessVisitor
inherits Crystal::SemanticVisitor
¶
Guess the type of class and instance variables from assignments to them.
Class methods¶
.new(mod, explicit_instance_vars : Hash(Type, Hash(String, TypeDeclarationWithLocation)), guessed_instance_vars : Hash(Type, Hash(String, InstanceVarTypeInfo)), initialize_infos : Hash(Type, Array(InitializeInfo)), instance_vars_outside : Hash(Type, Array(String)), errors : Hash(Type, Hash(String, Error)))
¶
(mod, explicit_instance_vars : Hash(Type, Hash(String, TypeDeclarationWithLocation)), guessed_instance_vars : Hash(Type, Hash(String, InstanceVarTypeInfo)), initialize_infos : Hash(Type, Array(InitializeInfo)), instance_vars_outside : Hash(Type, Array(String)), errors : Hash(Type, Hash(String, Error)))
Methods¶
#class_vars : Hash(Crystal::ClassVarContainer, Hash(String, Crystal::TypeGuessVisitor::TypeInfo))
¶
: Hash(Crystal::ClassVarContainer, Hash(String, Crystal::TypeGuessVisitor::TypeInfo))
#current_type
¶
At every point there's a current type.
In the beginning this is the Program
(top-level), but when
a class definition is visited this changes to that type, and so on.
#guess_type_call_pointer_malloc_two_args(node)
¶
(node)
If it's Pointer.malloc(size, value), infer element type from value to T and then infer to Pointer(T)
#guess_type_call_with_type_annotation(node)
¶
(node)
Guess type from T.method, where T is a Path and method solves to a method with a type annotation (use the type annotation)
#initialize_infos : Hash(Crystal::Type, Array(Crystal::TypeDeclarationProcessor::InitializeInfo))
¶
: Hash(Crystal::Type, Array(Crystal::TypeDeclarationProcessor::InitializeInfo))