Class: YTLJit::TypeUtil::TypeContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/ytljit/vm_type.rb

Instance Method Summary collapse

Constructor Details

#initializeTypeContainer

Returns a new instance of TypeContainer.



96
97
98
# File 'lib/ytljit/vm_type.rb', line 96

def initialize
  @types_tree = KlassTree.new
end

Instance Method Details

#add_node(key) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ytljit/vm_type.rb', line 134

def add_node(key)
  # inherit types of most similar signature 
  ival = [[], []]
  simnode = @types_tree.add(key, ival)
=begin
  simnode.value.each do |ele|
    ival.push ele
  end
=end

  simnode
end

#add_type(key, type, pos) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/ytljit/vm_type.rb', line 112

def add_type(key, type, pos)
  tvs = @types_tree.search(key)
  if tvs then
    tvsv = tvs.value[pos]
    tvsv.delete(type)
    tvsv.push type
  else
    # inherit types of most similar signature 
    ival = [[], []]
    simnode = @types_tree.add(key, ival)
=begin
    simnode.value.each do |ele|
      ival.push ele
    end
=end

    if !ival.include? type then
      ival[pos].push type
    end
  end
end

#search_types(key) ⇒ Object



104
105
106
# File 'lib/ytljit/vm_type.rb', line 104

def search_types(key)
  @types_tree.search(key)
end

#search_valid_nodeObject



108
109
110
# File 'lib/ytljit/vm_type.rb', line 108

def search_valid_node
  @types_tree.search_valid_node
end

#to_signature(context, offset = -1)) ⇒ Object



100
101
102
# File 'lib/ytljit/vm_type.rb', line 100

def to_signature(context, offset = -1)
  context.current_method_signature[offset]
end

#type_list(key) ⇒ Object



147
148
149
150
151
152
153
154
# File 'lib/ytljit/vm_type.rb', line 147

def type_list(key)
  res = search_types(key)
  if res == nil then
    res = add_node(key)
  end

  res
end