2015-08-21 19:07:27 +02:00
|
|
|
require_relative "object_view"
|
|
|
|
require_relative "value_view"
|
2015-07-09 14:23:36 +02:00
|
|
|
|
2015-08-21 19:07:27 +02:00
|
|
|
class RegistersView < ListView
|
2015-07-09 14:23:36 +02:00
|
|
|
|
2015-08-21 19:07:27 +02:00
|
|
|
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 root
|
|
|
|
"div.registers_view"
|
|
|
|
end
|
2015-07-09 14:23:36 +02:00
|
|
|
|
2015-08-21 19:07:27 +02:00
|
|
|
def draw
|
2015-08-22 02:23:53 +02:00
|
|
|
super()
|
|
|
|
@element.children.each do |reg|
|
2015-08-22 01:37:15 +02:00
|
|
|
elem = div("div.register_view")
|
2015-08-21 19:07:27 +02:00
|
|
|
wrap_node_with reg , elem
|
2015-07-09 14:23:36 +02:00
|
|
|
end
|
2015-08-22 01:37:15 +02:00
|
|
|
@element
|
2015-08-21 19:07:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def register_changed reg , old , value
|
|
|
|
reg = reg.symbol unless reg.is_a? Symbol
|
2015-08-22 02:23:53 +02:00
|
|
|
index = reg.to_s[1 .. -1 ].to_i
|
|
|
|
if( is_object? value )
|
|
|
|
swap = ObjectView.new( value )
|
|
|
|
else
|
|
|
|
swap = ValueView.new value
|
|
|
|
end
|
|
|
|
replace_at index , swap
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_object?( id )
|
|
|
|
Virtual.machine.objects[id] != nil
|
2015-08-21 19:07:27 +02:00
|
|
|
end
|
2015-07-09 15:34:02 +02:00
|
|
|
|
2015-08-21 19:07:27 +02:00
|
|
|
def calc_fields
|
|
|
|
#puts "My id #{objects_id} , #{objects_id.class}"
|
|
|
|
object = Virtual.machine.objects[value]
|
|
|
|
self.fields.clear
|
|
|
|
if object and ! object.is_a?(String)
|
|
|
|
clazz = object.class.name.split("::").last
|
|
|
|
#puts "found #{clazz}"
|
|
|
|
self.fields << "#{clazz}:#{object.internal_object_length}"
|
|
|
|
self.fields << object.get_layout
|
|
|
|
object.get_instance_variables.each do |variable|
|
|
|
|
f = object.get_instance_variable(variable)
|
|
|
|
self.fields << f
|
|
|
|
end
|
2015-07-09 15:34:02 +02:00
|
|
|
end
|
2015-07-09 14:23:36 +02:00
|
|
|
end
|
2015-08-21 19:07:27 +02:00
|
|
|
|
2015-07-09 14:23:36 +02:00
|
|
|
end
|