Class: TypedRb::Model::TmLocalVarAsgn
- Defined in:
- lib/typed/model/tm_local_var_asgn.rb
Instance Attribute Summary collapse
-
#lhs ⇒ Object
Returns the value of attribute lhs.
-
#rhs ⇒ Object
Returns the value of attribute rhs.
Attributes inherited from Expr
Instance Method Summary collapse
- #check_type(context) ⇒ Object
-
#initialize(lhs, rhs, node) ⇒ TmLocalVarAsgn
constructor
ts ‘#initialize / String -> Node -> Node -> unit’.
Constructor Details
#initialize(lhs, rhs, node) ⇒ TmLocalVarAsgn
ts ‘#initialize / String -> Node -> Node -> unit’
9 10 11 12 13 |
# File 'lib/typed/model/tm_local_var_asgn.rb', line 9 def initialize(lhs, rhs, node) super(node) @lhs = lhs @rhs = rhs end |
Instance Attribute Details
#lhs ⇒ Object
Returns the value of attribute lhs.
7 8 9 |
# File 'lib/typed/model/tm_local_var_asgn.rb', line 7 def lhs @lhs end |
#rhs ⇒ Object
Returns the value of attribute rhs.
7 8 9 |
# File 'lib/typed/model/tm_local_var_asgn.rb', line 7 def rhs @rhs end |
Instance Method Details
#check_type(context) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/typed/model/tm_local_var_asgn.rb', line 15 def check_type(context) binding_type = rhs.check_type(context) maybe_binding = context.get_type_for(lhs) if maybe_binding begin if maybe_binding.compatible?(binding_type, :gt) maybe_binding else fail Types::UncomparableTypes.new(maybe_binding, binding_type, node) end rescue Types::UncomparableTypes raise Types::UncomparableTypes.new(maybe_binding, binding_type, node) end else context.add_binding!(lhs, binding_type) binding_type end end |