Skip to content

class Crystal::MetaVar
inherits Crystal::ASTNode

Included modules

Crystal::SpecialVar

Class methods

.new(name : String, type : Type? = nil)

View source

Methods

#==(other : self)

Returns true if this reference is the same as other. Invokes same?.

View source

#assigned_to=(assigned_to)

Is this metavar assigned a value?

View source

#assigned_to? : Bool

Is this metavar assigned a value?

View source

#belongs_to?(context)

True if this variable belongs to the given context.

View source

#clone_without_location

View source

#closure_in?(context)

True if this variable belongs to the given context but must be allocated in a closure.

View source

#closured? : Bool

A variable is closured if it's used in a ProcLiteral context where it wasn't created.

View source

#context : ASTNode | NonGenericModuleType | Nil

This is the context of the variable: who allocates it. It can either be the Program (for top level variables), a Def or a Block.

View source

#context=(context : ASTNode | NonGenericModuleType | Nil)

This is the context of the variable: who allocates it. It can either be the Program (for top level variables), a Def or a Block.

View source

#inspect(io : IO) : Nil

Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
View source

#local_vars

Local variables associated with this meta variable. Can be Var or MetaVar.

View source

#local_vars=(local_vars)

Local variables associated with this meta variable. Can be Var or MetaVar.

View source

#local_vars? : Array(Crystal::ASTNode)?

Is this metavar associated with any local vars?

View source

#mark_as_closured

Marks this variable as closured.

View source

#mutably_closured=(mutably_closured)

Is this metavar closured in a mutable way? This means it's closured and it got a value assigned to it more than once. If that's the case, when it's closured then all local variable related to it will also be bound to it.

View source

#mutably_closured? : Bool

Is this metavar closured in a mutable way? This means it's closured and it got a value assigned to it more than once. If that's the case, when it's closured then all local variable related to it will also be bound to it.

View source

#name=(name : String)

View source

#nil_if_read=(nil_if_read)

True if we need to mark this variable as nilable if this variable is read.

View source

#nil_if_read? : Bool

True if we need to mark this variable as nilable if this variable is read.

View source

#pretty_print(pp)

View source