2015-11-01 18:14:31 +01:00
|
|
|
require_relative "html_converter"
|
|
|
|
|
2018-04-17 18:08:10 +02:00
|
|
|
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")
|
2015-11-01 18:14:31 +01:00
|
|
|
@ticker = div(".ticker")
|
2018-04-17 18:08:10 +02:00
|
|
|
@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
|
2018-04-18 19:09:22 +02:00
|
|
|
if i.is_a?(Risc::FunctionReturn)
|
|
|
|
link = @interpreter.get_register( i.register )
|
2018-07-03 18:16:12 +02:00
|
|
|
puts "Link #{link}:#{link.class}"
|
2018-04-18 19:09:22 +02:00
|
|
|
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
|
2018-04-18 19:09:22 +02:00
|
|
|
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
|
2018-04-18 19:09:22 +02:00
|
|
|
method = i.source
|
2015-10-29 15:49:14 +01:00
|
|
|
when String
|
2018-04-18 19:09:22 +02:00
|
|
|
return
|
2015-10-29 15:49:14 +01:00
|
|
|
else
|
2018-04-09 14:08:56 +02:00
|
|
|
raise "Unrecognized source #{i.source.class.name} for #{i}"
|
2015-10-29 15:49:14 +01:00
|
|
|
end
|
2018-04-18 19:09:22 +02:00
|
|
|
update_method(method) if method
|
2015-10-29 15:49:14 +01:00
|
|
|
end
|
2015-11-01 12:03:03 +01:00
|
|
|
|
2018-04-18 19:09:22 +02:00
|
|
|
def update_method(method)
|
|
|
|
@text.inner_html = method.name
|
2015-10-29 18:10:02 +01:00
|
|
|
end
|
2015-11-01 18:14:31 +01:00
|
|
|
|
2015-10-29 15:49:14 +01:00
|
|
|
end
|