diff --git a/lib/views/html_converter.rb b/lib/views/html_converter.rb
index f958e4a..92ed8f1 100644
--- a/lib/views/html_converter.rb
+++ b/lib/views/html_converter.rb
@@ -10,13 +10,13 @@ class HtmlConverter < AST::Processor
puts "Missing: " + s.type
"Missing #{s.type}"
end
- def div statement , html
+ def div( statement , html)
"
" + html + "
"
end
- def span statement , html
+ def span( statement , html)
"" + html + ""
end
- def on_function statement
+ def on_function( statement)
return_type , name , parameters, kids , receiver = *statement
str = return_type + " "
str += receiver + "." if receiver
diff --git a/lib/views/left_view.rb b/lib/views/left_view.rb
index f778d85..8b589a5 100644
--- a/lib/views/left_view.rb
+++ b/lib/views/left_view.rb
@@ -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",
}
diff --git a/lib/views/object_view.rb b/lib/views/object_view.rb
index 21ef735..616bcc9 100644
--- a/lib/views/object_view.rb
+++ b/lib/views/object_view.rb
@@ -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
diff --git a/lib/views/ref_view.rb b/lib/views/ref_view.rb
index 885a37f..912c6f8 100644
--- a/lib/views/ref_view.rb
+++ b/lib/views/ref_view.rb
@@ -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"
diff --git a/lib/views/registers_view.rb b/lib/views/registers_view.rb
index 0a95dc0..e55a228 100644
--- a/lib/views/registers_view.rb
+++ b/lib/views/registers_view.rb
@@ -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
diff --git a/lib/views/status_view.rb b/lib/views/status_view.rb
index 6666160..5f3d638 100644
--- a/lib/views/status_view.rb
+++ b/lib/views/status_view.rb
@@ -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