rubyx-debugger/app/register_view.rb

51 lines
1.1 KiB
Ruby
Raw Normal View History

2015-07-26 11:51:57 +02:00
2015-07-22 15:22:54 +02:00
class RegisterView
include React::Component
2015-07-23 19:08:40 +02:00
required_param :interpreter
2015-07-26 11:51:57 +02:00
required_param :register
define_state :objects_id
define_state :fields => []
before_mount do
interpreter.register_event(:register_changed, self)
2015-07-26 11:51:57 +02:00
register_changed( register , nil , interpreter.registers[register])
end
2015-07-26 11:51:57 +02:00
def register_changed reg , old , value
return unless reg == register
objects_id! value
calc_fields
end
2015-07-22 15:22:54 +02:00
2015-07-26 11:51:57 +02:00
def calc_fields
puts "My id #{objects_id} , #{objects_id.class}"
object = Virtual.machine.objects[objects_id]
if object and ! object.is_a?(String)
has_fields = []
clazz = object.class.name.split("::").last
puts "found #{clazz}"
has_fields << clazz
object.get_instance_variables.each do |variable|
has_fields << object.get_instance_variable(variable).to_s
2015-07-22 15:22:54 +02:00
end
2015-07-26 11:51:57 +02:00
fields! has_fields
2015-07-22 15:22:54 +02:00
end
end
2015-07-25 20:04:20 +02:00
2015-07-26 11:51:57 +02:00
def render
div.row do
div.col_md_12 do
objects_id.to_s
end
fields.each do |variable|
div.col_md_12 do
variable.span
end
end
end
2015-07-25 20:04:20 +02:00
end
2015-07-26 11:51:57 +02:00
2015-07-22 15:22:54 +02:00
end