rubyx-debugger/lib/views/vool_view.rb

47 lines
1.1 KiB
Ruby
Raw Normal View History

require_relative "html_converter"
class VoolView < ElementView
2015-10-29 15:49:14 +01:00
def initialize interpreter
@interpreter = interpreter
@interpreter.register_event(:instruction_changed, self)
end
def draw
2015-11-01 17:11:38 +01:00
@text = div(".text")
@ticker = div(".ticker")
@element = div(".vool_view") << div("h4.source" , "Class.Method") << @ticker << @text
2015-10-29 15:49:14 +01:00
@element
end
def instruction_changed
i = @interpreter.instruction
return "" unless i
if i.is_a?(Risc::FunctionReturn)
link = @interpreter.get_register( i.register )
puts "Link #{link}:#{link.class}"
raise "No link method" unless link
end
method = nil
2015-10-29 15:49:14 +01:00
case i.source
2018-04-03 17:24:57 +02:00
when Mom::Instruction
if(i.source.is_a?(Mom::SimpleCall))
method = i.source.method
end
#TODO, give mom a source
2018-07-30 16:17:27 +02:00
when Parfait::Callable
method = i.source
2015-10-29 15:49:14 +01:00
when String
return
2015-10-29 15:49:14 +01:00
else
raise "Unrecognized source #{i.source.class.name} for #{i}"
2015-10-29 15:49:14 +01:00
end
update_method(method) if method
2015-10-29 15:49:14 +01:00
end
2015-11-01 12:03:03 +01:00
def update_method(method)
@text.inner_html = method.name
2015-10-29 18:10:02 +01:00
end
2015-10-29 15:49:14 +01:00
end