0
@@ -4,13 +4,13 @@ class Pyasm
0
attr_accessor :argc, :nlocals, :stacksize, :flags, :consts, :bytecode,
0
- :filename, :lineno, :name, :symbols, :stacknow, :varsyms, :jumps, :labels
0
- def initialize(fname, name = "<module>")
0
+ :filename, :lineno, :name, :symbols, :stacknow, :varsyms, :jumps, :labels, :lines
0
+ def initialize(fname, name = "<module>", lineno = 0)
0
@argc, @nlocals, @stacksize, @flags, @filename, @lineno, @name, @stack, @nopop =
0
- 0, 0, 1, 0x40, fname, 1, name, [], 0
0
+ 0, 0, 1, 0x40, fname, lineno, name, [], 0
0
- @bytecode, @varsyms, @labels, @jumps = [], [], {}, {}
0
+ @bytecode, @varsyms, @labels, @lines, @jumps = [], [], {}, [], {}
0
@@ -43,6 +43,11 @@ class Pyasm
0
def pop_top; bc 0x01; dump_stack end
0
def ret_val; bc 0x53 end
0
def build_class; bc 0x59 end
0
@@ -86,6 +91,7 @@ class Pyasm
0
stack_push Object.new, bc(0x7c, n, 0x0)
0
@@ -95,6 +101,9 @@ class Pyasm
0
+ @lines << [n, @bytecode.flatten.length]
0
@nopop -= 1 if @nopop > 0
0
@@ -156,6 +165,9 @@ class Pyasm
0
@@ -227,7 +239,7 @@ class Pyasm
0
bytes = @bytecode.slice! idx..-1
0
bytes.shift unless receiver
0
- asm = Pyasm.new(@filename, id.to_s)
0
+ asm = Pyasm.new(@filename, id.to_s, @lines.last[0])
0
@@ -268,9 +280,9 @@ class Pyasm
0
iseq.last.each do |inst|
0
inst[0] = :message if inst[0] == :send
0
@@ -336,7 +348,14 @@ class Pyasm
0
f << @filename.to_pickle
0
+ lastn, lastpos = @lines[0]
0
+ @lines[1..-1].each do |n, pos|
0
+ lnotab << [pos - lastpos, n - lastn].pack("cc")
0
+ lastn, lastpos = n, pos
Comments
No one has commented yet.