show labels correctly

This commit is contained in:
Torsten Ruger 2015-11-04 12:20:44 +02:00
parent ccf3a37003
commit 6bbbef235c
2 changed files with 20 additions and 5 deletions

View File

@ -24,20 +24,26 @@ class RefView < ListView
def ref_text def ref_text
"#{@name} : #{marker(@value)}" "#{@name} : #{marker(@value)}"
end end
def add_hover def add_hover
return if is_string? return if is_string?
@element.on("hover"){ hover } if is_object?(@value) @element.on("hover"){ hover } if is_object?(@value)
end end
def is_object?( ) def is_object?( )
Register.machine.objects[@value] != nil has = Register.machine.objects[@value]
return false unless has
! is_label?
end end
def is_string?() def is_string?()
Register.machine.objects[@value].is_a? String Register.machine.objects[@value].is_a? String
end end
def is_label?
Register.machine.objects[@value].is_a?(Register::Label)
end
def is_nil?() def is_nil?()
Register.machine.objects[@value].nil? Register.machine.objects[@value].nil?
end end
@ -55,6 +61,8 @@ class RefView < ListView
var = Register.machine.objects[id] var = Register.machine.objects[id]
str = var.class.name.split("::").last[0,2] str = var.class.name.split("::").last[0,2]
str + " : #{id.to_s}" str + " : #{id.to_s}"
elsif is_label?
str = "Label"
else else
str = @value.to_s str = @value.to_s
end end

View File

@ -24,8 +24,13 @@ class RegistersView < ListView
def register_changed reg , old , value def register_changed reg , old , value
reg = reg.symbol unless reg.is_a? Symbol reg = reg.symbol unless reg.is_a? Symbol
index = reg.to_s[1 .. -1 ].to_i index = reg.to_s[1 .. -1 ].to_i
if( is_object? value ) has = Register.machine.objects[value]
swap = ObjectView.new( value , @interpreter , 16 - index ) if( has )
if has.is_a?(Register::Label)
swap = ValueView.new "Label: #{has.name}"
else
swap = ObjectView.new( value , @interpreter , 16 - index )
end
else else
swap = ValueView.new value swap = ValueView.new value
end end
@ -34,7 +39,9 @@ class RegistersView < ListView
end end
def is_object?( id ) def is_object?( id )
Register.machine.objects[id] != nil has = Register.machine.objects[id]
return false unless has
has.is_a?(Register::Label) ? false : true
end end
end end