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.



84
85
86
# File 'lib/ytljit/vm_type.rb', line 84

def initialize
  @types_tree = KlassTree.new
end

Instance Method Details

#add_node(key) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/ytljit/vm_type.rb', line 119

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) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ytljit/vm_type.rb', line 96

def add_type(key, type)
  tvs = @types_tree.search(key)
  if tvs then
    tvsv = tvs.value
    if !tvsv.include? type then
      tvsv.push type
    end
  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.push type
    end
  end
end

#search_types(key) ⇒ Object



92
93
94
# File 'lib/ytljit/vm_type.rb', line 92

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

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



88
89
90
# File 'lib/ytljit/vm_type.rb', line 88

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

#type_list(key) ⇒ Object



132
133
134
135
136
137
138
139
# File 'lib/ytljit/vm_type.rb', line 132

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