Class: TypeProf::Core::CVarReadBox

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

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

Constructor Details

#initialize(node, genv, cpath, name) ⇒ CVarReadBox

Returns a new instance of CVarReadBox.



1005
1006
1007
1008
1009
1010
1011
1012
1013
# File 'lib/typeprof/core/graph/box.rb', line 1005

def initialize(node, genv, cpath, name)
  super(node)
  @cpath = cpath
  @name = name
  genv.resolve_cpath(cpath).cvar_reads << self
  @proxy = Vertex.new(node)
  @ret = Vertex.new(node)
  genv.add_run(self)
end

Instance Attribute Details

#const_readObject (readonly)

Returns the value of attribute const_read.



1015
1016
1017
# File 'lib/typeprof/core/graph/box.rb', line 1015

def const_read
  @const_read
end

#nodeObject (readonly)

Returns the value of attribute node.



1015
1016
1017
# File 'lib/typeprof/core/graph/box.rb', line 1015

def node
  @node
end

#retObject (readonly)

Returns the value of attribute ret.



1015
1016
1017
# File 'lib/typeprof/core/graph/box.rb', line 1015

def ret
  @ret
end

Instance Method Details

#destroy(genv) ⇒ Object



1017
1018
1019
1020
# File 'lib/typeprof/core/graph/box.rb', line 1017

def destroy(genv)
  genv.resolve_cpath(@cpath).cvar_reads.delete(self)
  super(genv)
end

#run0(genv, changes) ⇒ Object



1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/typeprof/core/graph/box.rb', line 1022

def run0(genv, changes)
  mod = genv.resolve_cpath(@cpath)
  cur_cve = mod.get_cvar(@name)
  target_vtx = nil
  genv.each_direct_superclass(mod, nil) do |mod, _|
    cve = mod.get_cvar(@name)
    if cve.exist?
      target_vtx = cve.vtx
    end
  end

  edges = []
  if target_vtx
    if target_vtx != cur_cve.vtx
      edges << [cur_cve.vtx, @proxy] << [@proxy, target_vtx]
    end
    edges << [target_vtx, @ret]
  end

  edges.each do |src, dst|
    changes.add_edge(genv, src, dst)
  end
end