Class: TRuby::IR::Conditional

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

Overview

Conditional (if/unless)

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(condition:, then_branch:, else_branch: nil, kind: :if, **opts) ⇒ Conditional

kind: :if, :unless, :ternary



268
269
270
271
272
273
274
# File 'lib/t_ruby/ir.rb', line 268

def initialize(condition:, then_branch:, else_branch: nil, kind: :if, **opts)
  super(**opts)
  @condition = condition
  @then_branch = then_branch
  @else_branch = else_branch
  @kind = kind
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



265
266
267
# File 'lib/t_ruby/ir.rb', line 265

def condition
  @condition
end

#else_branchObject

Returns the value of attribute else_branch.



265
266
267
# File 'lib/t_ruby/ir.rb', line 265

def else_branch
  @else_branch
end

#kindObject

Returns the value of attribute kind.



265
266
267
# File 'lib/t_ruby/ir.rb', line 265

def kind
  @kind
end

#then_branchObject

Returns the value of attribute then_branch.



265
266
267
# File 'lib/t_ruby/ir.rb', line 265

def then_branch
  @then_branch
end

Instance Method Details

#childrenObject



276
277
278
# File 'lib/t_ruby/ir.rb', line 276

def children
  [@condition, @then_branch, @else_branch].compact
end