rubyx-debugger/app/main/models/register_model.rb

41 lines
1005 B
Ruby
Raw Normal View History

2015-07-30 09:09:04 +02:00
class RegisterModel < Volt::Model
field :name
field :value
2015-07-30 13:00:49 +02:00
field :fields
2015-07-30 09:09:04 +02:00
def register_changed reg , old , ins
2015-07-30 09:27:27 +02:00
self.last._class_name = "" if( self.length > 0)
2015-07-30 09:09:04 +02:00
self << { :name => ins.to_s , :class_name => "active" }
end
2015-07-30 13:00:49 +02:00
def register_changed reg , old , value
reg = reg.symbol unless reg.is_a? Symbol
return unless reg == name
self.value = value
calc_fields
end
def object_changed reg
reg = reg.symbol unless reg.is_a? Symbol
return unless reg == name
puts "Object changed in #{reg}"
calc_fields
end
def calc_fields
#puts "My id #{objects_id} , #{objects_id.class}"
object = Virtual.machine.objects[value]
if object and ! object.is_a?(String)
self.fields.clear
clazz = object.class.name.split("::").last
#puts "found #{clazz}"
self.fields << clazz
object.get_instance_variables.each do |variable|
f = object.get_instance_variable(variable)
self.fields << f
end
end
end
2015-07-30 09:09:04 +02:00
end