Class: TypedRb::Model::TmFor

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

Instance Attribute Summary collapse

Attributes inherited from Expr

#col, #line, #node, #type

Instance Method Summary collapse

Constructor Details

#initialize(condition, body, node) ⇒ TmFor

Returns a new instance of TmFor.



8
9
10
11
12
# File 'lib/typed/model/tm_for.rb', line 8

def initialize(condition, body, node)
  super(node)
  @condition = condition
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#conditionObject (readonly)

Returns the value of attribute condition.



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

def condition
  @condition
end

Instance Method Details

#check_type(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/typed/model/tm_for.rb', line 14

def check_type(context)
  condition.check_type(context)
  result_type = body.check_type(context)
  if result_type.stack_jump? && (result_type.next? || result_type.break?)
    result_type.wrapped_type.check_type(context)
  elsif result_type.either?
    process_either_type(result_type, context)
  else
    result_type
  end
end