Class: TypeProf::Core::TypeReadBox
- Defined in:
- lib/typeprof/core/graph/box.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#rbs_type ⇒ Object
readonly
Returns the value of attribute rbs_type.
-
#ret ⇒ Object
readonly
Returns the value of attribute ret.
Attributes inherited from Box
Instance Method Summary collapse
-
#initialize(node, genv, rbs_type) ⇒ TypeReadBox
constructor
A new instance of TypeReadBox.
- #run0(genv, changes) ⇒ Object
Methods inherited from Box
#add_symbol_proc_call_box, #destroy, #destroy_symbol_proc_call_boxes, #on_type_added, #on_type_removed, #reuse, #run, #to_s
Constructor Details
#initialize(node, genv, rbs_type) ⇒ TypeReadBox
Returns a new instance of TypeReadBox.
93 94 95 96 97 98 |
# File 'lib/typeprof/core/graph/box.rb', line 93 def initialize(node, genv, rbs_type) super(node) @rbs_type = rbs_type @ret = Vertex.new(node) genv.add_run(self) end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
100 101 102 |
# File 'lib/typeprof/core/graph/box.rb', line 100 def node @node end |
#rbs_type ⇒ Object (readonly)
Returns the value of attribute rbs_type.
100 101 102 |
# File 'lib/typeprof/core/graph/box.rb', line 100 def rbs_type @rbs_type end |
#ret ⇒ Object (readonly)
Returns the value of attribute ret.
100 101 102 |
# File 'lib/typeprof/core/graph/box.rb', line 100 def ret @ret end |
Instance Method Details
#run0(genv, changes) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/typeprof/core/graph/box.rb', line 102 def run0(genv, changes) # Create substitution map for type parameters if we're in a SigInstanceVariableNode within a generic class subst = {} if @node.is_a?(AST::SigInstanceVariableNode) && @node.cpath mod = genv.resolve_cpath(@node.cpath) if mod.type_params && !mod.type_params.empty? # Create a substitution map where each type parameter maps to a type variable vertex subst = mod.type_params.to_h do |param, _default_ty| type_var_vtx = Vertex.new(@node) [param, type_var_vtx] end end end vtx = @rbs_type.covariant_vertex(genv, changes, subst) changes.add_edge(genv, vtx, @ret) end |