Skip to content

abstract class Crystal::SemanticVisitor
inherits Crystal::Visitor

Base visitor for semantic analysis. It traverses the whole ASTNode tree, keeping a current_type in context, which corresponds to the type being visited according to class/module/lib definitions.

Direct known subclasses

Crystal::ClassVarsInitializerVisitor Crystal::InstanceVarsInitializerVisitor Crystal::MainVisitor Crystal::TopLevelVisitor Crystal::TypeDeclarationVisitor Crystal::TypeGuessVisitor

Class methods

.new(program, vars = MetaVars.new)

View source

Methods

#check_allowed_in_lib(node, type = node.type.instance_type)

View source

#check_class_var_annotations

View source

#check_declare_var_type(node, declared_type, variable_kind)

View source

#check_outside_exp(node, op)

View source

#class_var_owner(node)

View source

#current_type : ModuleType

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.

View source

#current_type=(current_type : ModuleType)

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.

View source

#end_visit_any(node)

View source

#eval_macro

View source

#expand_inline_macro(node, mode = nil, accept = true)

View source

#expand_macro(the_macro, node, mode = nil, *, visibility : Visibility, accept = true

View source

#expand_macro(node, raise_on_missing_const = true, first_pass = false, accept = true)

View source

#expand_macro_arguments(node, expansion_scope)

View source

#free_vars : Hash(String, TypeVar)?

Returns free variables

View source

#inside_exp?

View source

#interpret_enum_value(node : ASTNode, target_type : IntegerType? = nil)

View source

#lookup_annotation(ann)

View source

#lookup_type(node : ASTNode, free_vars = nil, find_root_generic_type_parameters = true)

View source

#nesting_exp?(node)

View source

#process_annotations

View source

#program : Program

View source

#pushing_type(type : ModuleType

View source

#read_annotations

Returns the current annotations and clears them for subsequent readers.

View source

#scope : Type

#scope=(scope : Type)

View source

#scope=(scope)

View source

#scope? : Type?

#validate_annotation(annotation_type, ann)

View source

#visit(node : MacroVerbatim)

View source

#visit(node : Require)

Transform require to its source code. The source code can be a Nop if the file was already required.

View source

#visit(node : ClassDef)

View source

#visit(node : ModuleDef)

View source

#visit(node : AnnotationDef)

View source

#visit(node : EnumDef)

View source

#visit(node : LibDef)

View source

#visit(node : Include)

View source

#visit(node : Extend)

View source

#visit(node : Alias)

View source

#visit(node : Def)

View source

#visit(node : Macro)

View source

#visit(node : Annotation)

View source

#visit(node : Call)

View source

#visit(node : MacroExpression)

View source

#visit(node : MacroIf)

View source

#visit(node : ASTNode)

View source

#visit(node : MacroFor)

View source

#visit_any(node)

View source