class TypedRb::Model::TmMassAsgn
Attributes
lhs[R]
rhs[R]
Public Class Methods
new(lhs, rhs, node)
click to toggle source
Calls superclass method
TypedRb::Model::Expr::new
# File lib/typed/model/tm_mass_asgn.rb, line 8 def initialize(lhs, rhs, node) super(node) @lhs = lhs.map { |lhs_node| lhs_node.children.first } @lhs_children = lhs @rhs = rhs end
Public Instance Methods
check_type(context)
click to toggle source
# File lib/typed/model/tm_mass_asgn.rb, line 15 def check_type(context) rhs_type = rhs.check_type(context) if rhs_type.ruby_type == Array lhs.each_with_index do |node, i| local_asgn = TmLocalVarAsgn.new(node, rhs_type.type_vars.first, @lhs_children[i]) local_asgn.check_type(context) end elsif rhs_type.ruby_type == Pair process_pair(rhs_type, context) else local_asgn = TmLocalVarAsgn.new(lhs.first, rhs_type, @lhs_children.first) local_asgn.check_type(context) lhs.drop(1).each_with_index do |node, i| local_asgn = TmLocalVarAsgn.new(node, Types::TyUnit.new, @lhs_children[i + 1]) local_asgn.check_type(context) end end rhs_type end
Protected Instance Methods
process_pair(actual_argument, context)
click to toggle source
# File lib/typed/model/tm_mass_asgn.rb, line 43 def process_pair(actual_argument, context) lhs.each_with_index do |node, i| type = case i when 0 actual_argument.type_vars[0] when 1 actual_argument.type_vars[1] else Types::TyUnit.new(node) end local_asgn = TmLocalVarAsgn.new(node, type, @lhs_children[i]) local_asgn.check_type(context) end context end