Class: TRuby::IR::FunctionType
- Defined in:
- lib/t_ruby/ir.rb
Overview
Function/Proc type ((String, Integer) -> Boolean)
Instance Attribute Summary collapse
-
#param_types ⇒ Object
Returns the value of attribute param_types.
-
#return_type ⇒ Object
Returns the value of attribute return_type.
Attributes inherited from Node
#location, #metadata, #type_info
Instance Method Summary collapse
-
#initialize(param_types: [], return_type:, **opts) ⇒ FunctionType
constructor
A new instance of FunctionType.
- #to_rbs ⇒ Object
- #to_trb ⇒ Object
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_types ⇒ Object
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_type ⇒ Object
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_rbs ⇒ Object
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_trb ⇒ Object
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 |