Class: TypeProf::Core::MAsgnBox

Inherits:
Box
  • Object
show all
Defined in:
lib/typeprof/core/graph/box.rb

Instance Attribute Summary collapse

Attributes inherited from Box

#changes, #destroyed

Instance Method Summary collapse

Methods inherited from Box

#diagnostics, #on_type_added, #on_type_removed, #reuse, #run, #to_s

Constructor Details

#initialize(node, genv, value, lefts, rest_elem, rights) ⇒ MAsgnBox

Returns a new instance of MAsgnBox.



958
959
960
961
962
963
964
965
# File 'lib/typeprof/core/graph/box.rb', line 958

def initialize(node, genv, value, lefts, rest_elem, rights)
  super(node)
  @value = value
  @lefts = lefts
  @rest_elem = rest_elem
  @rights = rights
  @value.add_edge(genv, self)
end

Instance Attribute Details

#leftsObject (readonly)

Returns the value of attribute lefts.



967
968
969
# File 'lib/typeprof/core/graph/box.rb', line 967

def lefts
  @lefts
end

#nodeObject (readonly)

Returns the value of attribute node.



967
968
969
# File 'lib/typeprof/core/graph/box.rb', line 967

def node
  @node
end

#rest_elemObject (readonly)

Returns the value of attribute rest_elem.



967
968
969
# File 'lib/typeprof/core/graph/box.rb', line 967

def rest_elem
  @rest_elem
end

#rightsObject (readonly)

Returns the value of attribute rights.



967
968
969
# File 'lib/typeprof/core/graph/box.rb', line 967

def rights
  @rights
end

#valueObject (readonly)

Returns the value of attribute value.



967
968
969
# File 'lib/typeprof/core/graph/box.rb', line 967

def value
  @value
end

Instance Method Details

#destroy(genv) ⇒ Object



969
970
971
972
# File 'lib/typeprof/core/graph/box.rb', line 969

def destroy(genv)
  @value.remove_edge(genv, self) # TODO: Is this really needed?
  super(genv)
end

#retObject



974
# File 'lib/typeprof/core/graph/box.rb', line 974

def ret = @rhs

#run0(genv, changes) ⇒ Object



976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# File 'lib/typeprof/core/graph/box.rb', line 976

def run0(genv, changes)
  edges = []
  @value.each_type do |ty|
    # TODO: call to_ary?
    case ty
    when Type::Array
      edges.concat(ty.splat_assign(genv, @lefts, @rest_elem, @rights))
    else
      if @lefts.size >= 1
        edges << [Source.new(ty), @lefts[0]]
      elsif @rights.size >= 1
        edges << [Source.new(ty), @rights[0]]
      else
        edges << [Source.new(ty), @rest_elem]
      end
    end
  end
  edges.each do |src, dst|
    changes.add_edge(genv, src, dst)
  end
end