Class: TRuby::IR::MethodDef

Inherits:
Node
  • Object
show all
Defined in:
lib/t_ruby/ir.rb

Overview

Method definition

Instance Attribute Summary collapse

Attributes inherited from Node

#location, #metadata, #type_info

Instance Method Summary collapse

Methods inherited from Node

#accept, #transform

Constructor Details

#initialize(name:, params: [], return_type: nil, body: nil, visibility: :public, type_params: [], **opts) ⇒ MethodDef

Returns a new instance of MethodDef.



133
134
135
136
137
138
139
140
141
# File 'lib/t_ruby/ir.rb', line 133

def initialize(name:, params: [], return_type: nil, body: nil, visibility: :public, type_params: [], **opts)
  super(**opts)
  @name = name
  @params = params
  @return_type = return_type
  @body = body
  @visibility = visibility
  @type_params = type_params
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



131
132
133
# File 'lib/t_ruby/ir.rb', line 131

def body
  @body
end

#nameObject

Returns the value of attribute name.



131
132
133
# File 'lib/t_ruby/ir.rb', line 131

def name
  @name
end

#paramsObject

Returns the value of attribute params.



131
132
133
# File 'lib/t_ruby/ir.rb', line 131

def params
  @params
end

#return_typeObject

Returns the value of attribute return_type.



131
132
133
# File 'lib/t_ruby/ir.rb', line 131

def return_type
  @return_type
end

#type_paramsObject

Returns the value of attribute type_params.



131
132
133
# File 'lib/t_ruby/ir.rb', line 131

def type_params
  @type_params
end

#visibilityObject

Returns the value of attribute visibility.



131
132
133
# File 'lib/t_ruby/ir.rb', line 131

def visibility
  @visibility
end

Instance Method Details

#childrenObject



143
144
145
# File 'lib/t_ruby/ir.rb', line 143

def children
  [@body].compact
end