2015-08-24 01:45:33 +02:00
|
|
|
require "base/constant_view"
|
|
|
|
require "base/list_view"
|
2015-08-21 00:37:41 +02:00
|
|
|
|
2015-08-24 01:45:33 +02:00
|
|
|
class InstructionView < ListView
|
2015-08-21 00:37:41 +02:00
|
|
|
|
2015-08-24 01:45:33 +02:00
|
|
|
def initialize interpreter
|
|
|
|
@interpreter = interpreter
|
|
|
|
super([ConstantView.new( "span.bright" , "starting" )])
|
|
|
|
@interpreter.register_event(:instruction_changed, self)
|
2015-08-21 00:37:41 +02:00
|
|
|
end
|
|
|
|
|
2015-08-24 01:45:33 +02:00
|
|
|
def instruction_changed
|
|
|
|
@element.at_css(".bright").remove_class("bright")
|
|
|
|
instruction = append( ConstantView.new( "span.bright" , instruction_text ) )
|
|
|
|
wrap_node_with instruction , div
|
|
|
|
remove_first if( @elements.length > 5)
|
2015-08-21 00:37:41 +02:00
|
|
|
end
|
2015-08-24 01:45:33 +02:00
|
|
|
|
|
|
|
def draw
|
|
|
|
super()
|
|
|
|
wrap_node_with @elements.first , div
|
|
|
|
wrap_element div(".source_view") << div("h4" ,"Virtual Machine Instruction")
|
|
|
|
@element
|
2015-08-21 00:37:41 +02:00
|
|
|
end
|
|
|
|
|
2015-08-24 01:45:33 +02:00
|
|
|
def instruction_text
|
|
|
|
return "" unless @interpreter.instruction
|
|
|
|
@interpreter.instruction.to_s
|
2015-08-21 00:37:41 +02:00
|
|
|
end
|
|
|
|
end
|