Class: TRuby::IR::TypeGuard

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

Overview

Type guard (is_a?, respond_to?)

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(expression:, type_check:, narrowed_type: nil, **opts) ⇒ TypeGuard

Returns a new instance of TypeGuard.



411
412
413
414
415
416
# File 'lib/t_ruby/ir.rb', line 411

def initialize(expression:, type_check:, narrowed_type: nil, **opts)
  super(**opts)
  @expression = expression
  @type_check = type_check
  @narrowed_type = narrowed_type
end

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



409
410
411
# File 'lib/t_ruby/ir.rb', line 409

def expression
  @expression
end

#narrowed_typeObject

Returns the value of attribute narrowed_type.



409
410
411
# File 'lib/t_ruby/ir.rb', line 409

def narrowed_type
  @narrowed_type
end

#type_checkObject

Returns the value of attribute type_check.



409
410
411
# File 'lib/t_ruby/ir.rb', line 409

def type_check
  @type_check
end

Instance Method Details

#childrenObject



418
419
420
# File 'lib/t_ruby/ir.rb', line 418

def children
  [@expression]
end