63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/ytl.rb', line 63
def self.main(options)
tr_context = VM::YARVContext.new
progs = []
import_ruby_object(tr_context)
options[:execute_before_compile].each do |fn|
rf = File.read(fn)
prog = eval(rf)
progs.push prog
is = RubyVM::InstructionSequence.compile(prog, ARGV[0],
"", 0, ISEQ_OPTS).to_a
iseq = VMLib::InstSeqTree.new(nil, is)
tr = VM::YARVTranslatorCRubyObject.new([iseq])
tr.translate(tr_context)
end
prog = File.read(ARGV[0])
is = RubyVM::InstructionSequence.compile(prog, ARGV[0],
"", 0, ISEQ_OPTS).to_a
iseq = VMLib::InstSeqTree.new(nil, is)
if options[:dump_yarv] then
pp iseq
end
tr = VM::YARVTranslatorCRubyObject.new([iseq])
tnode = tr.translate(tr_context)
ci_context = VM::CollectInfoContext.new(tnode)
tnode.collect_info(ci_context)
if fn = options[:write_node_before_ti] then
File.open(fn, "w") do |fp|
fp.print Marshal.dump(tnode)
end
end
dmylit = VM::Node::LiteralNode.new(tnode, nil)
arg = [dmylit, dmylit, dmylit]
sig = []
arg.each do |ele|
sig.push RubyType::BaseType.from_ruby_class(NilClass)
end
ti_context = VM::TypeInferenceContext.new(tnode)
begin
tnode.collect_candidate_type(ti_context, arg, sig)
end until ti_context.convergent
ti_context = tnode.collect_candidate_type(ti_context, arg, sig)
c_context = VM::CompileContext.new(tnode)
c_context.current_method_signature.push sig
c_context.options = options
c_context = tnode.compile(c_context)
tnode.make_frame_struct_tab
if fn = options[:write_node_after_ti] then
File.open(fn, "w") do |fp|
fp.print Marshal.dump(tnode)
end
end
if options[:disasm] then
tnode.code_space_tab.each do |cs|
cs.fill_disasm_cache
end
tnode.code_space.disassemble
end
tcs = tnode.code_space
STDOUT.flush
tcs.call(tcs.base_address)
end
|