Class: TypedRb::Model::TmIfElse
- Defined in:
- lib/typed/model/tm_if_else.rb
Instance Attribute Summary collapse
-
#condition_expr ⇒ Object
readonly
Returns the value of attribute condition_expr.
-
#else_expr ⇒ Object
Returns the value of attribute else_expr.
-
#then_expr ⇒ Object
readonly
Returns the value of attribute then_expr.
Attributes inherited from Expr
Instance Method Summary collapse
- #check_type(context) ⇒ Object
-
#initialize(node, condition_expr, then_expr, else_expr) ⇒ TmIfElse
constructor
A new instance of TmIfElse.
Constructor Details
#initialize(node, condition_expr, then_expr, else_expr) ⇒ TmIfElse
Returns a new instance of TmIfElse.
9 10 11 12 13 14 |
# File 'lib/typed/model/tm_if_else.rb', line 9 def initialize(node, condition_expr, then_expr, else_expr) super(node, nil) @condition_expr = condition_expr @then_expr = then_expr || Types::TyUnit.new @else_expr = else_expr || Types::TyUnit.new end |
Instance Attribute Details
#condition_expr ⇒ Object (readonly)
Returns the value of attribute condition_expr.
7 8 9 |
# File 'lib/typed/model/tm_if_else.rb', line 7 def condition_expr @condition_expr end |
#else_expr ⇒ Object
Returns the value of attribute else_expr.
8 9 10 |
# File 'lib/typed/model/tm_if_else.rb', line 8 def else_expr @else_expr end |
#then_expr ⇒ Object (readonly)
Returns the value of attribute then_expr.
7 8 9 |
# File 'lib/typed/model/tm_if_else.rb', line 7 def then_expr @then_expr end |
Instance Method Details
#check_type(context) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/typed/model/tm_if_else.rb', line 16 def check_type(context) either_type = Types::TyEither.new(node) either_type.compatible_either?(then_expr.check_type(context)) either_type.compatible_either?(else_expr.check_type(context)) either_type.has_jump? ? either_type : either_type[:normal] end |