rubyx-debugger/lib/views/registers_view.rb

55 lines
1.2 KiB
Ruby
Raw Normal View History

require_relative "object_view"
class RegistersView < ListView
def initialize interpreter
@interpreter = interpreter
@interpreter.register_event(:register_changed, self)
kids = []
@interpreter.registers.each do |reg , val|
kids << ValueView.new( val )
end
super(kids)
end
def draw
super( "div.registers_view" )
2015-08-23 02:16:32 +02:00
@element.children.each_with_index do |reg, index|
elem = div("div.register_view")
wrap_node_with reg , elem
end
@element
end
def register_changed( reg , old , value )
reg = reg.symbol unless reg.is_a? Symbol
index = reg.to_s[1 .. -1 ].to_i
2018-06-22 18:44:50 +02:00
has = Risc::Position.set?(value)
2015-11-04 11:20:44 +01:00
if( has )
2018-06-22 18:44:50 +02:00
if has.object.is_a?(Risc::Label)
swap = ValueView.new "Label: #{has.object.name}"
2015-11-04 11:20:44 +01:00
else
swap = ObjectView.new( value , @interpreter , 16 - index )
end
else
swap = ValueView.new value
end
replace_at index , swap
2015-08-23 02:16:32 +02:00
# @elements[index].style["z-index"] = -index
end
end
2015-08-24 01:49:41 +02:00
class ValueView < ElementView
def initialize value
@value = value
end
def draw
li = div("li")
li << div("span", @value)
2018-06-22 18:44:50 +02:00
@element = div("ul.nav!") << li
2015-08-24 01:49:41 +02:00
end
end