Skip to content

class Crystal::Def
inherits Crystal::ASTNode

A method definition.

'def' [ receiver '.' ] name
  body
'end'

| 'def' [ receiver '.' ] name '(' [ arg [ ',' arg ]* ] ')' body 'end'

Included modules

Crystal::Annotatable Crystal::HookExpansionsContainer

Direct known subclasses

Crystal::External

Class methods

.argless_initialize

View source

.argless_new(instance_type)

View source

.new(name, args = [] of Arg, body = nil, receiver = nil, block_arg = nil, return_type = nil, macro_def = false, yields = nil, abstract __arg24 = false, splat_index = nil, double_splat = nil, free_vars = nil)

View source

Methods

#==(other : self)

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

#abi_info=(abi_info)

View source

#abi_info? : Bool

View source

#abstract=(abstract __arg0 : Bool)

View source

#abstract? : Bool

View source

#accept_children(visitor)

View source

#add_special_var(name)

View source

#always_inline=(always_inline)

true if this def has the @[AlwaysInline] annotation

View source

#always_inline? : Bool

true if this def has the @[AlwaysInline] annotation

View source

#args : Array(Arg)

View source

#args=(args : Array(Arg))

View source

#assigns_special_var=(assigns_special_var)

View source

#assigns_special_var? : Bool

View source

#block_arg : Arg?

View source

#block_arg=(block_arg : Arg?)

View source

#block_nest : Int32

View source

#block_nest=(block_nest)

View source

#body=(body : ASTNode)

View source

#c_calling_convention : Bool?

View source

#c_calling_convention=(c_calling_convention)

View source

#c_calling_convention?

Returns self as an External if this Def is an External that must respect the C calling convention.

View source

#call_convention

View source

#calls_initialize=(calls_initialize)

View source

#calls_initialize? : Bool

View source

#calls_previous_def=(calls_previous_def)

View source

#calls_previous_def? : Bool

View source

#calls_super=(calls_super)

View source

#calls_super? : Bool

View source

#captured_block=(captured_block)

View source

#captured_block? : Bool

View source

#clone_without_location

View source

#closure=(closure)

View source

#closure? : Bool

View source

#doc : String?

Returns the doc comment attached to this node. Not every node supports having doc comments, so by default this returns nil.

View source

#doc=(doc : String?)

View source

#double_splat : Arg?

View source

#double_splat=(double_splat : Arg?)

View source

#expand_default_arguments(program, args_size, named_args = nil)

View source

#expand_new_default_arguments(instance_type, args_size, named_args)

View source

#expand_new_from_initialize(instance_type)

View source

#expand_new_signature_from_initialize(instance_type)

View source

#fill_body_from_initialize(instance_type)

View source

#free_var?(node : Path)

View source

#free_var?(any)

View source

#free_vars : Array(String)?

View source

#free_vars=(free_vars : Array(String)?)

View source

#hash(hasher)

#interpret(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode)?, block : Crystal::Block?, interpreter : Crystal::MacroInterpreter, name_loc : Location?)

View source

#macro_def=(macro_def : Bool)

View source

#macro_def? : Bool

View source

#macro_owner

View source

#macro_owner=(macro_owner)

View source

#macro_owner? : Crystal::Type?

View source

#mangled_name(program, self_type)

View source

#map_type(type)

View source

#match

Yields arg, arg_index, object, object_index corresponding to arguments matching the given objects, taking into account this def's splat index.

View source

#min_max_args_sizes

Returns the minimum and maximum number of arguments that must be passed to this method.

View source

#naked=(naked)

true if this def has the @[Naked] annotation

View source

#naked? : Bool

true if this def has the @[Naked] annotation

View source

#name=(name : String)

View source

#name_location : Location?

View source

#name_location=(name_location : Location?)

View source

#name_size

View source

#new=(new)

Is this a new method that was expanded from an initialize?

View source

#new? : Bool

Is this a new method that was expanded from an initialize?

View source

#next : Def?

View source

#next=(next __arg0 : Def?)

View source

#no_inline=(no_inline)

true if this def has the @[NoInline] annotation

View source

#no_inline? : Bool

true if this def has the @[NoInline] annotation

View source

#original_owner : Type

#original_owner=(original_owner : Type)

View source

#original_owner? : Type?

#owner : Type

#owner=(owner : Type)

View source

#owner? : Type?

#previous=(previous : DefWithMetadata?)

View source

#proc_c_calling_convention?

View source

#raises=(value)

View source

#raises? : Bool

View source

#receiver : ASTNode?

View source

#receiver=(receiver : ASTNode?)

View source

#return_type : ASTNode?

View source

#return_type=(return_type : ASTNode?)

View source

#returns_twice=(returns_twice)

true if this def has the @[ReturnsTwice] annotation

View source

#returns_twice? : Bool

true if this def has the @[ReturnsTwice] annotation

View source

#self_closured=(self_closured)

View source

#self_closured? : Bool

View source

#short_reference

View source

#special_vars : Set(String)?

View source

#splat_index : Int32?

View source

#splat_index=(splat_index : Int32?)

View source

#to_json(builder : JSON::Builder)

View source

#uses_block_arg=(uses_block_arg)

View source

#uses_block_arg? : Bool

View source

#varargs?

View source

#vars=(vars : MetaVars?)

View source

#visibility=(visibility)

View source

#yield_vars : Array(Var)?

View source

#yield_vars=(yield_vars : Array(Var)?)

View source

#yields : Int32?

View source

#yields=(yields : Int32?)

View source