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

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

Constructor Details

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

Returns a new instance of CVarReadBox.



915
916
917
918
919
920
921
922
923
# File 'lib/typeprof/core/graph/box.rb', line 915

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.



925
926
927
# File 'lib/typeprof/core/graph/box.rb', line 925

def const_read
  @const_read
end

#nodeObject (readonly)

Returns the value of attribute node.



925
926
927
# File 'lib/typeprof/core/graph/box.rb', line 925

def node
  @node
end

#retObject (readonly)

Returns the value of attribute ret.



925
926
927
# File 'lib/typeprof/core/graph/box.rb', line 925

def ret
  @ret
end

Instance Method Details

#destroy(genv) ⇒ Object



927
928
929
930
# File 'lib/typeprof/core/graph/box.rb', line 927

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

#run0(genv, changes) ⇒ Object



932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/typeprof/core/graph/box.rb', line 932

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