update to work with positions
This commit is contained in:
parent
9832c8730b
commit
3451b546c3
@ -10,13 +10,13 @@ class HtmlConverter < AST::Processor
|
||||
puts "Missing: " + s.type
|
||||
"Missing #{s.type}"
|
||||
end
|
||||
def div statement , html
|
||||
def div( statement , html)
|
||||
"<div class='statement' id='i#{statement.object_id.to_s(16)}'>" + html + "</div>"
|
||||
end
|
||||
def span statement , html
|
||||
def span( statement , html)
|
||||
"<span class='expression' id='i#{statement.object_id.to_s(16)}'>" + html + "</span>"
|
||||
end
|
||||
def on_function statement
|
||||
def on_function( statement)
|
||||
return_type , name , parameters, kids , receiver = *statement
|
||||
str = return_type + " "
|
||||
str += receiver + "." if receiver
|
||||
|
@ -57,13 +57,13 @@ class SelectView < ElementView
|
||||
|
||||
def select( code )
|
||||
puts "selecting #{code}"
|
||||
machine = Risc.machine.boot
|
||||
Risc.machine.boot
|
||||
@interpreter.set_state :stopped
|
||||
@element.at_css(".selected").text = code
|
||||
ruby = get_codes[code]
|
||||
Vool::VoolCompiler.ruby_to_vool( as_main(ruby) )
|
||||
machine.objects
|
||||
@interpreter.start machine.risc_init
|
||||
Risc.machine.boot
|
||||
Vool::VoolCompiler.ruby_to_binary( as_main(ruby) , :interpreter )
|
||||
@interpreter.start_machine
|
||||
end
|
||||
def as_main(statements)
|
||||
"class Space ;def main(arg) ; #{statements}; end; end"
|
||||
@ -73,6 +73,7 @@ class SelectView < ElementView
|
||||
set_internal_byte: "return 'Hello'.set_internal_byte(1,75)" ,
|
||||
called_if: 'if( 10 ); return "then";else;return "else";end' ,
|
||||
plus: 'return 5 + 7' ,
|
||||
return: 'return 5' ,
|
||||
hello_world: "h = 'Hello World'.putstring;return h",
|
||||
dynamic_call: "a = 150 ; return a.div10",
|
||||
}
|
||||
|
@ -40,8 +40,10 @@ class ObjectView < ListView
|
||||
end
|
||||
|
||||
def class_header
|
||||
pos = Risc::Position.set?(@object)
|
||||
str = pos ? pos.to_s : @object.object_id.to_s(16)
|
||||
clazz = @object.class.name.split("::").last
|
||||
[clazz, @object.object_id.to_s(16)].join " : "
|
||||
[clazz, str].join " : "
|
||||
end
|
||||
|
||||
def content_elements
|
||||
|
@ -60,6 +60,8 @@ class RefView < ListView
|
||||
elsif is_object?
|
||||
var = @value
|
||||
str = var.class.name.split("::").last[0,2]
|
||||
pos = Risc::Position.set?(@value)
|
||||
str += pos ? pos.to_s : @value.object_id.to_s(16)
|
||||
str + " : #{@value.object_id.to_s(16)}"
|
||||
elsif is_label?
|
||||
str = "Label"
|
||||
|
@ -24,10 +24,10 @@ 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
|
||||
has = Risc.machine.objects[value.object_id]
|
||||
has = Risc::Position.set?(value)
|
||||
if( has )
|
||||
if has.is_a?(Risc::Label)
|
||||
swap = ValueView.new "Label: #{has.name}"
|
||||
if has.object.is_a?(Risc::Label)
|
||||
swap = ValueView.new "Label: #{has.object.name}"
|
||||
else
|
||||
swap = ObjectView.new( value , @interpreter , 16 - index )
|
||||
end
|
||||
@ -49,6 +49,6 @@ class ValueView < ElementView
|
||||
def draw
|
||||
li = div("li")
|
||||
li << div("span", @value)
|
||||
@element = div("ul.nav!") << li
|
||||
@element = div("ul.nav!") << li
|
||||
end
|
||||
end
|
||||
|
@ -19,8 +19,10 @@ class StatusView < ElementView
|
||||
div("span.clock" , clock_text) <<
|
||||
div( "br") <<
|
||||
div("span.flags" , flags_text) <<
|
||||
div( "br" , "Stdout") <<
|
||||
div("span.stdout")
|
||||
div( "br") <<
|
||||
div( "span.stdout" , "Stdout") <<
|
||||
div( "br") <<
|
||||
div( "span.status" , "Status")
|
||||
# set up event handler
|
||||
@element.at_css(".next").on("click") { self.update }
|
||||
@element.at_css(".run").on("mousedown") { self.start( 0.1 ) }
|
||||
@ -52,8 +54,18 @@ class StatusView < ElementView
|
||||
@element.at_css(".header_state").text = state_text
|
||||
@element.at_css(".flags").text = flags_text
|
||||
@element.at_css(".stdout").text = @interpreter.stdout
|
||||
@element.at_css(".status").text = status_text
|
||||
end
|
||||
|
||||
def status_text
|
||||
return "#{@interpreter.instruction.to_s}" unless @interpreter.instruction.source
|
||||
source = @interpreter.instruction.source
|
||||
s = "#{source.to_s}"
|
||||
if( source.respond_to?(:source) and source.source )
|
||||
s += @interpreter.instruction.source.source.to_s
|
||||
end
|
||||
s
|
||||
end
|
||||
def state_text
|
||||
" (#{@interpreter.state})"
|
||||
end
|
||||
@ -67,6 +79,6 @@ class StatusView < ElementView
|
||||
end
|
||||
|
||||
def clock_text
|
||||
"Instruction #{@interpreter.clock}"
|
||||
"Instruction #{@interpreter.clock}-0x#{@interpreter.pc.to_s(16)}"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user