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.



441
442
443
444
445
446
# File 'lib/t_ruby/ir.rb', line 441

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.



439
440
441
# File 'lib/t_ruby/ir.rb', line 439

def expression
  @expression
end

#narrowed_typeObject

Returns the value of attribute narrowed_type.



439
440
441
# File 'lib/t_ruby/ir.rb', line 439

def narrowed_type
  @narrowed_type
end

#type_checkObject

Returns the value of attribute type_check.



439
440
441
# File 'lib/t_ruby/ir.rb', line 439

def type_check
  @type_check
end

Instance Method Details

#childrenObject



448
449
450
# File 'lib/t_ruby/ir.rb', line 448

def children
  [@expression]
end