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

View File

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