better view for registers
This commit is contained in:
parent
6ba3c54690
commit
6ce51c38db
@ -1,4 +1,9 @@
|
||||
|
||||
require "register_view"
|
||||
require "class_view"
|
||||
require "source_view"
|
||||
require "block_view"
|
||||
|
||||
class Debugger
|
||||
|
||||
include React::Component
|
||||
@ -26,7 +31,13 @@ class Debugger
|
||||
BlockView interpreter: interpreter
|
||||
end
|
||||
end
|
||||
RegisterView interpreter: interpreter
|
||||
div.row do
|
||||
interpreter.registers.each do |r , oid|
|
||||
div.col_md_1 do
|
||||
RegisterView interpreter: interpreter , register: r
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,10 +6,6 @@ require "interpreter"
|
||||
|
||||
require 'opal-react'
|
||||
|
||||
require "class_view"
|
||||
require "register_view"
|
||||
require "source_view"
|
||||
require "block_view"
|
||||
require "debugger"
|
||||
|
||||
require 'opal-jquery'
|
||||
|
@ -1,45 +1,50 @@
|
||||
|
||||
class RegisterView
|
||||
|
||||
include React::Component
|
||||
required_param :interpreter
|
||||
define_state :registers
|
||||
required_param :register
|
||||
|
||||
define_state :objects_id
|
||||
define_state :fields => []
|
||||
|
||||
before_mount do
|
||||
interpreter.register_event(:register_changed, self)
|
||||
registers! interpreter.registers
|
||||
register_changed( register , nil , interpreter.registers[register])
|
||||
end
|
||||
|
||||
def register_changed reg , old , bl
|
||||
registers! interpreter.registers
|
||||
def register_changed reg , old , value
|
||||
return unless reg == register
|
||||
objects_id! value
|
||||
calc_fields
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
fields! has_fields
|
||||
end
|
||||
end
|
||||
|
||||
def render
|
||||
div.row do
|
||||
registers.each do |r , has|
|
||||
div.col_md_1 do
|
||||
div.row do
|
||||
div.col_md_12 do
|
||||
"#{r} : #{has}"
|
||||
objects_id.to_s
|
||||
end
|
||||
if object = has_object(has)
|
||||
fields.each do |variable|
|
||||
div.col_md_12 do
|
||||
object.class.name.split("::").last.span
|
||||
variable.span
|
||||
end
|
||||
object.get_instance_variables.each do |variable|
|
||||
div.col_md_12 do
|
||||
## deal with String
|
||||
## even better, make ObjectView
|
||||
object.get_instance_variable(variable).to_s.span
|
||||
end
|
||||
end
|
||||
end #if
|
||||
end
|
||||
end #row
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def has_object has
|
||||
object = Virtual.machine.objects[has]
|
||||
end
|
||||
end
|
||||
|
26
app/registers_view.rb
Normal file
26
app/registers_view.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require "register_view"
|
||||
|
||||
class RegistersView
|
||||
|
||||
include React::Component
|
||||
|
||||
required_param :interpreter
|
||||
|
||||
def render
|
||||
div.row do
|
||||
interpreter.registers.each do |r , has|
|
||||
div.col_md_1 do
|
||||
div.row do
|
||||
div.col_md_12 do
|
||||
" #{has}"
|
||||
end
|
||||
div.col_md_12 do
|
||||
ObjectView :object_id => has
|
||||
end
|
||||
end
|
||||
end #row
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user