Class: TypedRb::Model::TmWhile
Instance Attribute Summary collapse
-
#body_expr ⇒ Object
readonly
Returns the value of attribute body_expr.
-
#condition_expr ⇒ Object
readonly
Returns the value of attribute condition_expr.
Attributes inherited from Expr
Instance Method Summary collapse
- #check_type(context) ⇒ Object
-
#initialize(condition_expr, body_expr, node) ⇒ TmWhile
constructor
A new instance of TmWhile.
Constructor Details
#initialize(condition_expr, body_expr, node) ⇒ TmWhile
Returns a new instance of TmWhile.
8 9 10 11 12 |
# File 'lib/typed/model/tm_while.rb', line 8 def initialize(condition_expr, body_expr, node) super(node) @condition_expr = condition_expr @body_expr = body_expr end |
Instance Attribute Details
#body_expr ⇒ Object (readonly)
Returns the value of attribute body_expr.
7 8 9 |
# File 'lib/typed/model/tm_while.rb', line 7 def body_expr @body_expr end |
#condition_expr ⇒ Object (readonly)
Returns the value of attribute condition_expr.
7 8 9 |
# File 'lib/typed/model/tm_while.rb', line 7 def condition_expr @condition_expr end |
Instance Method Details
#check_type(context) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/typed/model/tm_while.rb', line 14 def check_type(context) condition_expr.check_type(context).compatible?(Types::TyObject.new(BasicObject, node), :lt) return Types::TyUnit.new(node) unless body_expr while_res = body_expr.check_type(context) if while_res.stack_jump? && (while_res.next? || while_res.break?) while_res.wrapped_type.check_type(context) elsif while_res.either? process_either_type(while_res, context) else while_res end end |