class TypedRb::Model::TmWhile
Attributes
body_expr[R]
condition_expr[R]
Public Class Methods
new(condition_expr, body_expr, node)
click to toggle source
Calls superclass method
TypedRb::Model::Expr::new
# File lib/typed/model/tm_while.rb, line 7 def initialize(condition_expr, body_expr, node) super(node) @condition_expr = condition_expr @body_expr = body_expr end
Public Instance Methods
check_type(context)
click to toggle source
# File lib/typed/model/tm_while.rb, line 13 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
Private Instance Methods
process_either_type(either_type, context)
click to toggle source
# File lib/typed/model/tm_while.rb, line 28 def process_either_type(either_type, context) return_type = either_type[:return] final_type = either_type.check_type(context, [:normal, :next, :break]) if return_type.nil? final_type else new_either_type = Types::TyEither.new(node) new_either_type[:return] = return_type new_either_type[:normal] = final_type new_either_type end end