1 require 'compiler/compiler'
6 # An alternate generator that prints out bytecode for display.
21 attr_reader :text, :ip, :file, :line
22 attr_accessor :redo, :retry, :break, :next
24 def advanced_since?(old)
33 def initialize(gen, idx)
41 @gen.set_label(@index)
50 Label.new(self, @label += 1)
66 def set_line(line, file)
67 @file, @line = file, line
68 @text << "#line #{line}\n"
72 return if @other_methods.empty?
73 @other_methods.each_pair do |i,m|
74 @text << "\n:==== Method #{i} ====\n"
75 @text << m.generator.text
80 def method_missing(op, *args)
85 @text << "#{op} #{args.join(' ', :inspect)}\n"
95 @text << "push #{what}\n"
99 def send(meth, count, priv=false)
100 @text << "send #{meth} #{count}"
102 @text << " true ; allow private\n"
114 method_missing :equal
117 def push_literal(lit)
118 if lit.kind_of? MethodDescription
119 @text << "push_literal #<Method #{@@method_id}>\n"
121 @other_methods[@@method_id] = lit
125 method_missing :push_literal, lit
129 def as_primitive(name)
130 @text << "#primitive #{name}\n"
142 @gen.add_text "; exc#{@idx} start"
146 @gen.add_text "; exc#{@idx} end"