Class: TypedRb::Model::TmReturn

Inherits:
Expr show all
Defined in:
lib/typed/model/tm_return.rb

Instance Attribute Summary collapse

Attributes inherited from Expr

#col, #line, #node, #type

Instance Method Summary collapse

Constructor Details

#initialize(elements, node) ⇒ TmReturn

Returns a new instance of TmReturn.



7
8
9
10
# File 'lib/typed/model/tm_return.rb', line 7

def initialize(elements, node)
  super(node)
  @elements = elements
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



6
7
8
# File 'lib/typed/model/tm_return.rb', line 6

def elements
  @elements
end

Instance Method Details

#check_type(context) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/typed/model/tm_return.rb', line 12

def check_type(context)
  returned_type = if elements.size == 0
                    Types::TyUnit.new(node)
                  elsif elements.size == 1
                    elements.first.check_type(context)
                  else
                    TmArrayLiteral.new(elements, node).check_type(context)
                  end
  Types::TyStackJump.return(returned_type, node)
end