abstract class Crystal::SemanticVisitor

Overview

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

Defined in:

compiler/crystal/semantic/semantic_visitor.cr

Constructors

Instance Method Summary

Instance methods inherited from class Crystal::Visitor

accept(node) accept, end_visit(node) end_visit, end_visit_any(node) end_visit_any, visit_any(node) visit_any

Instance methods inherited from class Reference

==(other : self)
==(other : JSON::Any)
==(other : YAML::Any)
==(other)
==
, dup dup, hash(hasher) hash, initialize initialize, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil)
same?
, to_s(io : IO) : Nil to_s

Constructor methods inherited from class Reference

new new, unsafe_construct(address : Pointer, *args, **opts) : self unsafe_construct

Class methods inherited from class Reference

pre_initialize(address : Pointer) pre_initialize

Instance methods inherited from class Object

! : Bool !, !=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other)
===
, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash(hasher)
hash
hash
, in?(collection : Object) : Bool
in?(*values : Object) : Bool
in?
, inspect(io : IO) : Nil
inspect : String
inspect
, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil!(message)
not_nil!
not_nil!
, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO) : Nil
to_json : String
to_json
, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil
to_pretty_json
, to_s(io : IO) : Nil
to_s : String
to_s
, to_yaml(io : IO) : Nil
to_yaml : String
to_yaml
, try(&) try, unsafe_as(type : T.class) forall T unsafe_as

Class methods inherited from class Object

from_json(string_or_io : String | IO, root : String)
from_json(string_or_io : String | IO)
from_json
, from_yaml(string_or_io : String | IO) from_yaml

Macros inherited from class Object

class_getter(*names, &block) class_getter, class_getter!(*names) class_getter!, class_getter?(*names, &block) class_getter?, class_property(*names, &block) class_property, class_property!(*names) class_property!, class_property?(*names, &block) class_property?, class_setter(*names) class_setter, def_clone def_clone, def_equals(*fields) def_equals, def_equals_and_hash(*fields) def_equals_and_hash, def_hash(*fields) def_hash, delegate(*methods, to object) delegate, forward_missing_to(delegate) forward_missing_to, getter(*names, &block) getter, getter!(*names) getter!, getter?(*names, &block) getter?, property(*names, &block) property, property!(*names) property!, property?(*names, &block) property?, setter(*names) setter

Constructor Detail

def self.new(program : Crystal::Program, vars : Hash(String, Crystal::MetaVar) = MetaVars.new) #

[View source]

Instance Method Detail

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

[View source]
def check_class_var_annotations #

[View source]
def check_declare_var_type(node, declared_type, variable_kind) #

[View source]
def check_outside_exp(node, op) #

[View source]
def class_var_owner(node) #

[View source]
def 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]
def 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]
def end_visit_any(node) #

[View source]
def eval_macro(node, &) #

[View source]
def expand_inline_macro(node, mode = nil, accept = true) #

[View source]
def expand_macro(node, raise_on_missing_const = true, first_pass = false, accept = true) #

[View source]
def expand_macro(the_macro, node, mode = nil, *, visibility : Visibility, accept = true, &) #

[View source]
def expand_macro_argument(node, expansion_scope) #

[View source]
def expand_macro_arguments(call, expansion_scope) #

[View source]
def free_vars : Hash(String, TypeVar) | Nil #

Returns free variables


[View source]
def inside_exp? #

[View source]
def interpret_enum_value(node : ASTNode, target_type : IntegerType | Nil = nil) #

[View source]
def lookup_annotation(ann) #

[View source]
def lookup_type(node : ASTNode, free_vars = nil, find_root_generic_type_parameters = true) #

[View source]
def nesting_exp?(node) #

[View source]
def process_annotations(annotations, &) #

[View source]
def program : Program #

[View source]
def pushing_type(type : ModuleType, &) #

[View source]
def read_annotations #

Returns the current annotations and clears them for subsequent readers.


[View source]
def scope : Type #

[View source]
def scope=(scope : Type) #

[View source]
def scope=(scope : Crystal::Type | Nil) #

[View source]
def scope? : Type | Nil #

[View source]
def validate_annotation(annotation_type, ann) #

[View source]
def vars : MetaVars #

[View source]
def vars=(vars : MetaVars) #

[View source]
def visit(node : Require) #

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


[View source]
def visit(node : ClassDef) #

[View source]
def visit(node : ModuleDef) #

[View source]
def visit(node : AnnotationDef) #

[View source]
def visit(node : EnumDef) #

[View source]
def visit(node : LibDef) #

[View source]
def visit(node : Include) #

[View source]
def visit(node : Extend) #

[View source]
def visit(node : Alias) #

[View source]
def visit(node : Def) #

[View source]
def visit(node : Macro) #

[View source]
def visit(node : Annotation) #

[View source]
def visit(node : Call) #

[View source]
def visit(node : MacroExpression) #

[View source]
def visit(node : MacroIf) #

[View source]
def visit(node : MacroFor) #

[View source]
def visit(node : MacroVerbatim) #

[View source]
def visit(node : ExternalVar | Path | Generic | ProcNotation | Union | Metaclass | Self | TypeOf) #

[View source]
def visit(node : ASTNode) #

[View source]
def visit_any(node) #

[View source]