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

Constructor Details

#initializeYARVContext

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
# File 'lib/ytljit/vm_trans.rb', line 6

def initialize
  @the_top = TopTopNode.new(nil, Object)
  @top_nodes = [@the_top]
  @current_file_name = nil
  @current_class_node = the_top
  @current_method_node = nil

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

  @current_node = @the_top
  @vmtab = []

  @expstack = []
  @local_label_tab = {}

  @not_reached_pos = false

  @macro_method = nil
end

Instance Attribute Details

#current_class_nodeObject

Returns the value of attribute current_class_node.



33
34
35
# File 'lib/ytljit/vm_trans.rb', line 33

def current_class_node
  @current_class_node
end

#current_file_nameObject

Returns the value of attribute current_file_name.



32
33
34
# File 'lib/ytljit/vm_trans.rb', line 32

def current_file_name
  @current_file_name
end

#current_line_noObject

Returns the value of attribute current_line_no.



38
39
40
# File 'lib/ytljit/vm_trans.rb', line 38

def current_line_no
  @current_line_no
end

#current_local_labelObject

Returns the value of attribute current_local_label.



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

def current_local_label
  @current_local_label
end

#current_method_nodeObject

Returns the value of attribute current_method_node.



34
35
36
# File 'lib/ytljit/vm_trans.rb', line 34

def current_method_node
  @current_method_node
end

#current_nodeObject

Returns the value of attribute current_node.



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

def current_node
  @current_node
end

#enc_labelObject

Returns the value of attribute enc_label.



36
37
38
# File 'lib/ytljit/vm_trans.rb', line 36

def enc_label
  @enc_label
end

#enc_pos_in_sourceObject

Returns the value of attribute enc_pos_in_source.



37
38
39
# File 'lib/ytljit/vm_trans.rb', line 37

def enc_pos_in_source
  @enc_pos_in_source
end

#expstackObject (readonly)

Returns the value of attribute expstack.



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

def expstack
  @expstack
end

#local_label_tabObject (readonly)

Returns the value of attribute local_label_tab.



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

def local_label_tab
  @local_label_tab
end

#macro_methodObject

Returns the value of attribute macro_method.



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

def macro_method
  @macro_method
end

#not_reached_posObject

Returns the value of attribute not_reached_pos.



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

def not_reached_pos
  @not_reached_pos
end

#the_topObject

Returns the value of attribute the_top.



29
30
31
# File 'lib/ytljit/vm_trans.rb', line 29

def the_top
  @the_top
end

#top_nodesObject (readonly)

Returns the value of attribute top_nodes.



30
31
32
# File 'lib/ytljit/vm_trans.rb', line 30

def top_nodes
  @top_nodes
end

#vmtabObject (readonly)

Returns the value of attribute vmtab.



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

def vmtab
  @vmtab
end

Instance Method Details

#debug_infoObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ytljit/vm_trans.rb', line 60

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



51
52
53
54
55
56
57
58
# File 'lib/ytljit/vm_trans.rb', line 51

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 = LiteralNode.new(ctn, value)
  ctn.get_constant_tab[name] = valnode
end