Class: TypedRb::Model::TmReturn
- Defined in:
- lib/typed/model/tm_return.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Attributes inherited from Expr
Instance Method Summary collapse
- #check_type(context) ⇒ Object
-
#initialize(elements, node) ⇒ TmReturn
constructor
A new instance of TmReturn.
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
#elements ⇒ Object (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 |