Class: YTLJit::VM::YARVContext

Inherits:
Object
  • Object
show all
Includes:
Node
Defined in:
lib/ytljit/vm_trans.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#compile_compare_nonnum

Constructor Details

#initialize(oldcontext = nil) ⇒ YARVContext

Returns a new instance of YARVContext.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ytljit/vm_trans.rb', line 6

def initialize(oldcontext = nil)
  if oldcontext and false then
    @the_top = oldcontext.the_top
  else
    @the_top = TopTopNode.new(nil, Object)
  end
  @top_nodes = [@the_top]
  @current_file_name = nil
  @current_class_node = @the_top
  @current_method_node = nil
  
  @send_nodes_with_block = []

  @enc_label = ""
  @enc_pos_in_source = ""
  @current_line_no = 0
  @current_local_label = nil

  @current_node = @the_top

  @vmtab = []

  @expstack = []

  @local_label_tab = {}
  @local_label_list = []

  @exception_table = {}

  @not_reached_pos = false

  @macro_method = nil
end

Instance Attribute Details

#current_class_nodeObject

Returns the value of attribute current_class_node.



44
45
46
# File 'lib/ytljit/vm_trans.rb', line 44

def current_class_node
  @current_class_node
end

#current_file_nameObject

Returns the value of attribute current_file_name.



43
44
45
# File 'lib/ytljit/vm_trans.rb', line 43

def current_file_name
  @current_file_name
end

#current_line_noObject

Returns the value of attribute current_line_no.



51
52
53
# File 'lib/ytljit/vm_trans.rb', line 51

def current_line_no
  @current_line_no
end

#current_local_labelObject

Returns the value of attribute current_local_label.



52
53
54
# File 'lib/ytljit/vm_trans.rb', line 52

def current_local_label
  @current_local_label
end

#current_method_nodeObject

Returns the value of attribute current_method_node.



45
46
47
# File 'lib/ytljit/vm_trans.rb', line 45

def current_method_node
  @current_method_node
end

#current_nodeObject

Returns the value of attribute current_node.



54
55
56
# File 'lib/ytljit/vm_trans.rb', line 54

def current_node
  @current_node
end

#enc_labelObject

Returns the value of attribute enc_label.



49
50
51
# File 'lib/ytljit/vm_trans.rb', line 49

def enc_label
  @enc_label
end

#enc_pos_in_sourceObject

Returns the value of attribute enc_pos_in_source.



50
51
52
# File 'lib/ytljit/vm_trans.rb', line 50

def enc_pos_in_source
  @enc_pos_in_source
end

#exception_tableObject

Returns the value of attribute exception_table.



62
63
64
# File 'lib/ytljit/vm_trans.rb', line 62

def exception_table
  @exception_table
end

#expstackObject (readonly)

Returns the value of attribute expstack.



58
59
60
# File 'lib/ytljit/vm_trans.rb', line 58

def expstack
  @expstack
end

#local_label_listObject (readonly)

Returns the value of attribute local_label_list.



60
61
62
# File 'lib/ytljit/vm_trans.rb', line 60

def local_label_list
  @local_label_list
end

#local_label_tabObject (readonly)

Returns the value of attribute local_label_tab.



59
60
61
# File 'lib/ytljit/vm_trans.rb', line 59

def local_label_tab
  @local_label_tab
end

#macro_methodObject

Returns the value of attribute macro_method.



66
67
68
# File 'lib/ytljit/vm_trans.rb', line 66

def macro_method
  @macro_method
end

#not_reached_posObject

Returns the value of attribute not_reached_pos.



64
65
66
# File 'lib/ytljit/vm_trans.rb', line 64

def not_reached_pos
  @not_reached_pos
end

#send_nodes_with_blockObject (readonly)

Returns the value of attribute send_nodes_with_block.



47
48
49
# File 'lib/ytljit/vm_trans.rb', line 47

def send_nodes_with_block
  @send_nodes_with_block
end

#the_topObject

Returns the value of attribute the_top.



40
41
42
# File 'lib/ytljit/vm_trans.rb', line 40

def the_top
  @the_top
end

#top_nodesObject (readonly)

Returns the value of attribute top_nodes.



41
42
43
# File 'lib/ytljit/vm_trans.rb', line 41

def top_nodes
  @top_nodes
end

#vmtabObject (readonly)

Returns the value of attribute vmtab.



56
57
58
# File 'lib/ytljit/vm_trans.rb', line 56

def vmtab
  @vmtab
end

Instance Method Details

#current_exception_tableObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/ytljit/vm_trans.rb', line 104

def current_exception_table
  result = {}
  @exception_table.each do |kind, lst|
    lst.each do |st, ed, cnt, body|
      if @local_label_list.include?(st) and
          !@local_label_list.include?(ed) and 
          body then
        result[kind] = [st, ed, cnt, body]
        break
      end
    end
  end

  result
end

#debug_infoObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/ytljit/vm_trans.rb', line 89

def debug_info
  mname = nil
  if @current_method_node then
    mname = @current_method_node.get_constant_value
  end
  if mname then
    mname = mname[0]
  end

  [@current_file_name, 
   @current_class_node.name, 
   mname,
   @current_line_no]
end

#import_object(klass, name, value) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ytljit/vm_trans.rb', line 68

def import_object(klass, name, value)
  ctn = ClassTopNode.get_class_top_node(klass)
  if ctn == nil then
    ctn = ClassTopNode.new(@the_top, klass, klass.name)
  end

  valnode = nil
  if value.is_a?(Class) then
    valnode = ClassTopNode.get_class_top_node(value)
    if valnode == nil then
      valnode = ClassTopNode.new(@the_top, value, value.name)
      klassclass = valnode.klassclass
      valnode.type = RubyType::BaseType.from_ruby_class(klassclass)
    end
  else
    valnode = LiteralNode.new(ctn, value)
  end

  ctn.get_constant_tab[name] = valnode
end