abstract class Crystal::ASTNode
inherits Reference
¶
Base class for nodes in the grammar.
Direct known subclasses
Crystal::Alias
Crystal::Annotation
Crystal::AnnotationDef
Crystal::Arg
Crystal::ArrayLiteral
Crystal::Asm
Crystal::AsmOperand
Crystal::Assign
Crystal::AssignWithRestriction
Crystal::BinaryOp
Crystal::Block
Crystal::BoolLiteral
Crystal::Call
Crystal::Case
Crystal::Cast
Crystal::CharLiteral
Crystal::ClassDef
Crystal::ClassVar
Crystal::ControlExpression
Crystal::CStructOrUnionDef
Crystal::Def
Crystal::EnumDef
Crystal::ExceptionHandler
Crystal::Expressions
Crystal::Extend
Crystal::ExternalVar
Crystal::FileNode
Crystal::FunDef
Crystal::Generic
Crystal::Global
Crystal::HashLiteral
Crystal::If
Crystal::ImplicitObj
Crystal::Include
Crystal::InstanceVar
Crystal::IsA
Crystal::LibDef
Crystal::Macro
Crystal::MacroExpression
Crystal::MacroFor
Crystal::MacroId
Crystal::MacroIf
Crystal::MacroLiteral
Crystal::MacroVar
Crystal::MagicConstant
Crystal::Metaclass
Crystal::MetaMacroVar
Crystal::MetaVar
Crystal::ModuleDef
Crystal::MultiAssign
Crystal::NamedArgument
Crystal::NamedTupleLiteral
Crystal::NilableCast
Crystal::NilLiteral
Crystal::Nop
Crystal::NumberLiteral
Crystal::OffsetOf
Crystal::OpAssign
Crystal::Path
Crystal::Primitive
Crystal::ProcLiteral
Crystal::ProcNotation
Crystal::ProcPointer
Crystal::RangeLiteral
Crystal::ReadInstanceVar
Crystal::RegexLiteral
Crystal::Require
Crystal::Rescue
Crystal::RespondsTo
Crystal::Select
Crystal::Self
Crystal::StringInterpolation
Crystal::StringLiteral
Crystal::SymbolLiteral
Crystal::TupleLiteral
Crystal::TypeDeclaration
Crystal::TypeDef
Crystal::TypeFilteredNode
Crystal::TypeNode
Crystal::TypeOf
Crystal::UnaryExpression
Crystal::Underscore
Crystal::UninitializedVar
Crystal::Union
Crystal::Unless
Crystal::Unreachable
Crystal::Until
Crystal::Var
Crystal::VisibilityModifier
Crystal::When
Crystal::While
Crystal::Yield
Crystal::YieldBlockBinder
Methods¶
#at(node : ASTNode)
¶
(node : ASTNode)
Sets this node's location and end location to those
of node
, and returns self
#at_end(node : ASTNode)
¶
(node : ASTNode)
Sets this node's end location to those of node
and
returns self
#clone
¶
Returns a deep copy of this node. Copied nodes retain the location and end location of the original nodes.
#doc
¶
Returns the doc comment attached to this node. Not every node
supports having doc comments, so by default this returns nil
.
#doc=(doc)
¶
(doc)
Attaches a doc comment to this node. Not every node supports having doc comments, so by default this does nothing and some subclasses implement this.
#end_location : Location?
¶
: Location?
The location where this node ends, or nil
if the location is not known.
#end_location=(end_location : Location?)
¶
(end_location : Location?)
The location where this node ends, or nil
if the location is not known.
#inspect(io : IO) : Nil
¶
(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>
#interpret(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode)?, block : Crystal::Block?, interpreter : Crystal::MacroInterpreter, name_loc : Location?)
¶
(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode)?, block : Crystal::Block?, interpreter : Crystal::MacroInterpreter, name_loc : Location?)
#location : Location?
¶
: Location?
The location where this node starts, or nil
if the location is not known.
#location=(location : Location?)
¶
(location : Location?)
The location where this node starts, or nil
if the location is not known.
#restrict_type_to_freeze_type(freeze_type, type)
¶
(freeze_type, type)
Computes the type resulting from assigning type to freeze_type, in the case where freeze_type is not nil.
Special cases are listed inside the method body.
#single_expression
¶
It yields itself for any node, but Expressions
yields first node
if it holds only a node.
#single_expression?
¶
It yields nil
always.
(It is overridden by Expressions
to implement #single_expression
.)
#to_s(io : IO, macro_expansion_pragmas = nil, emit_doc = false) : Nil
¶
(io : IO, macro_expansion_pragmas = nil, emit_doc = false) : Nil
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>