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 => []
|
2015-07-24 12:56:31 +02:00
|
|
|
|
|
|
|
before_mount do
|
|
|
|
interpreter.register_event(:register_changed, self)
|
2015-07-26 11:51:57 +02:00
|
|
|
register_changed( register , nil , interpreter.registers[register])
|
2015-07-24 12:56:31 +02:00
|
|
|
end
|
|
|
|
|
2015-07-26 11:51:57 +02:00
|
|
|
def register_changed reg , old , value
|
|
|
|
return unless reg == register
|
|
|
|
objects_id! value
|
|
|
|
calc_fields
|
2015-07-24 12:56:31 +02:00
|
|
|
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}"
|
2015-07-26 12:24:00 +02:00
|
|
|
has_fields << clazz
|
2015-07-26 11:51:57 +02:00
|
|
|
object.get_instance_variables.each do |variable|
|
2015-07-26 12:24:00 +02:00
|
|
|
f = object.get_instance_variable(variable)
|
|
|
|
has_fields << f
|
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
|
2015-07-26 12:24:00 +02:00
|
|
|
fields.each do |attribute|
|
2015-07-26 11:51:57 +02:00
|
|
|
div.col_md_12 do
|
2015-07-26 12:24:00 +02:00
|
|
|
"#{marker(attribute)} - #{attribute.object_id}".span
|
2015-07-26 11:51:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-07-25 20:04:20 +02:00
|
|
|
end
|
2015-07-26 11:51:57 +02:00
|
|
|
|
2015-07-26 12:24:00 +02:00
|
|
|
def marker var
|
|
|
|
var.class.name.split("::").last[0]
|
|
|
|
end
|
2015-07-22 15:22:54 +02:00
|
|
|
end
|