made status into own view

This commit is contained in:
Torsten Ruger 2015-07-31 14:10:55 +03:00
parent 5bd6b3517d
commit 1728cc1b25
5 changed files with 54 additions and 32 deletions

View File

@ -13,29 +13,11 @@ module Main
init_source
end
def tick
@interpreter.tick
update_interpreter
end
def update_interpreter
page._interpreter._clock = @interpreter.clock
page._interpreter._state = @interpreter.state
page._interpreter._stdout = @interpreter.stdout
page._interpreter._link = @interpreter.link.to_s
page._method_name = method_name
page._block_name = @interpreter.block ? @interpreter.block.name : " "
end
private
def marker var
return "W" if var.is_a? String
var.class.name.split("::").last[0]
end
def method_name
bl = @interpreter.block
return " " unless bl
return bl.method if bl.method.is_a? String
"#{bl.method.for_class.name}.#{bl.method.name}"
end
def init_machine
machine = Virtual.machine.boot
@ -44,7 +26,6 @@ module Main
machine.run_before "Register::CallImplementation"
@interpreter = Interpreter::Interpreter.new
page._interpreter = { }
update_interpreter
@interpreter.start machine.init
end
def init_registers

View File

@ -0,0 +1,31 @@
module Main
class StatusController < Volt::ModelController
def initialize app , context
super(app , context)
@interpreter = attrs.interpreter
self.model = Volt::Model.new
update_interpreter
end
def tick
@interpreter.tick
update_interpreter
end
def update_interpreter
self._clock = @interpreter.clock
self._state = @interpreter.state
self._stdout = @interpreter.stdout
self._link = @interpreter.link.to_s
page._method_name = method_name
page._block_name = @interpreter.block ? @interpreter.block.name : " "
end
def method_name
bl = @interpreter.block
return " " unless bl
return bl.method if bl.method.is_a? String
"#{bl.method.for_class.name}.#{bl.method.name}"
end
end
end

View File

@ -35,18 +35,6 @@
{{ end }}
</div>
<div class="status-view">
<h4> Interpreter </h4>
Instruction {{ page._interpreter._clock}}
<button e-click="tick"> Next </button>
<br/>
<span> State </span>
<span> {{page._interpreter._state}} </span>
<br/>
<span> Link: {{page._interpreter._link}} </span>
<br/>
Stdout <br/>
<span> {{page._interpreter._stdout}} </span>
</div>
<:status interpreter="{{ @interpreter }}"/>
<:registers interpreter="{{ @interpreter }}"/>

View File

@ -0,0 +1,17 @@
<:Title>
status index
<:Body>
<div class="status-view">
<h4> Interpreter </h4>
Instruction {{ _clock}}
<button e-click="tick"> Next </button>
<br/>
<span> State </span>
<span> {{_state}} </span>
<br/>
<span> Link: {{_link}} </span>
<br/>
Stdout <br/>
<span> {{_stdout}} </span>
</div>

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe '', type: :feature do
# Specs here
end