Class: TRuby::IR::FunctionType

Inherits:
TypeNode show all
Defined in:
lib/t_ruby/ir.rb

Overview

Function/Proc type ((String, Integer) -> Boolean)

Instance Attribute Summary collapse

Attributes inherited from Node

#location, #metadata, #type_info

Instance Method Summary collapse

Methods inherited from Node

#accept, #children, #transform

Constructor Details

#initialize(param_types: [], return_type:, **opts) ⇒ FunctionType

Returns a new instance of FunctionType.



574
575
576
577
578
# File 'lib/t_ruby/ir.rb', line 574

def initialize(param_types: [], return_type:, **opts)
  super(**opts)
  @param_types = param_types
  @return_type = return_type
end

Instance Attribute Details

#param_typesObject

Returns the value of attribute param_types.



572
573
574
# File 'lib/t_ruby/ir.rb', line 572

def param_types
  @param_types
end

#return_typeObject

Returns the value of attribute return_type.



572
573
574
# File 'lib/t_ruby/ir.rb', line 572

def return_type
  @return_type
end

Instance Method Details

#to_rbsObject



580
581
582
583
# File 'lib/t_ruby/ir.rb', line 580

def to_rbs
  params = @param_types.map(&:to_rbs).join(", ")
  "^(#{params}) -> #{@return_type.to_rbs}"
end

#to_trbObject



585
586
587
588
# File 'lib/t_ruby/ir.rb', line 585

def to_trb
  params = @param_types.map(&:to_trb).join(", ")
  "(#{params}) -> #{@return_type.to_trb}"
end