Class: SyntaxTree::YARV::VM::STDOUTEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/vm.rb

Overview

This is a simple implementation of tracing that prints to STDOUT.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSTDOUTEvents

Returns a new instance of STDOUTEvents.



140
141
142
# File 'lib/syntax_tree/yarv/vm.rb', line 140

def initialize
  @disassembler = Disassembler.new
end

Instance Attribute Details

#disassemblerObject (readonly)

Returns the value of attribute disassembler.



138
139
140
# File 'lib/syntax_tree/yarv/vm.rb', line 138

def disassembler
  @disassembler
end

Instance Method Details

#publish_frame_change(frame) ⇒ Object



144
145
146
# File 'lib/syntax_tree/yarv/vm.rb', line 144

def publish_frame_change(frame)
  puts "%-16s %s" % ["frame-change", "#{frame.iseq.file}@#{frame.line}"]
end

#publish_instruction(iseq, insn) ⇒ Object



148
149
150
151
# File 'lib/syntax_tree/yarv/vm.rb', line 148

def publish_instruction(iseq, insn)
  disassembler.current_iseq = iseq
  puts "%-16s %s" % ["instruction", insn.disasm(disassembler)]
end

#publish_stack_change(stack) ⇒ Object



153
154
155
# File 'lib/syntax_tree/yarv/vm.rb', line 153

def publish_stack_change(stack)
  puts "%-16s %s" % ["stack-change", stack.values.inspect]
end

#publish_tracepoint(event) ⇒ Object



157
158
159
# File 'lib/syntax_tree/yarv/vm.rb', line 157

def publish_tracepoint(event)
  puts "%-16s %s" % ["tracepoint", event.inspect]
end