adds button and blocks tick over
This commit is contained in:
parent
d8a3657365
commit
bb24a6cae5
@ -12,16 +12,16 @@ module Main
|
|||||||
init_blocks
|
init_blocks
|
||||||
end
|
end
|
||||||
|
|
||||||
def about
|
def tick
|
||||||
# Add code for when the about view is loaded
|
@interpreter.tick
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def init_machine
|
def init_machine
|
||||||
machine = Virtual.machine.boot
|
machine = Virtual.machine.boot
|
||||||
machine.run_before "Register::CallImplementation"
|
|
||||||
code = Ast::ExpressionList.new( [Ast::CallSiteExpression.new(:putstring, [] ,Ast::StringExpression.new("Hello again"))])
|
code = Ast::ExpressionList.new( [Ast::CallSiteExpression.new(:putstring, [] ,Ast::StringExpression.new("Hello again"))])
|
||||||
Virtual::Compiler.compile( code , machine.space.get_main )
|
Virtual::Compiler.compile( code , machine.space.get_main )
|
||||||
|
machine.run_before "Register::CallImplementation"
|
||||||
@interpreter = Interpreter.new
|
@interpreter = Interpreter.new
|
||||||
@interpreter.start machine.init
|
@interpreter.start machine.init
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
class BlocksModel < Volt::ArrayModel
|
class BlocksModel < Volt::ArrayModel
|
||||||
|
|
||||||
def instruction_changed old , ins
|
def instruction_changed old , ins
|
||||||
self.last._class_name = "" if( page._blocks.length > 0)
|
self.last._class_name = "inactive" if( self.length > 0)
|
||||||
self << { :name => ins.to_s , :class_name => "active" }
|
self << { :name => ins.to_s , :class_name => "bright" }
|
||||||
|
puts "block #{self.length}"
|
||||||
|
self.delete_at(0) if( self.length > 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ class RegisterModel < Volt::Model
|
|||||||
field :value
|
field :value
|
||||||
|
|
||||||
def register_changed reg , old , ins
|
def register_changed reg , old , ins
|
||||||
self.last._class_name = "" if( page._blocks.length > 0)
|
self.last._class_name = "" if( self.length > 0)
|
||||||
self << { :name => ins.to_s , :class_name => "active" }
|
self << { :name => ins.to_s , :class_name => "active" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,13 +28,14 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ page._blocks.each do |b| }}
|
{{ page._blocks.each do |b| }}
|
||||||
<div class="{{b._class_name}}">
|
<div class="{{b._class_name}}">
|
||||||
{{b._string}}
|
{{b._name}}
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="status-view">
|
<div class="status-view">
|
||||||
<div>
|
<div>
|
||||||
button.bright { "next" }.on(:click) { interpreter.tick }
|
<button e-click="tick">Next</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4> Status </h4>
|
<h4> Status </h4>
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# represent a block and hold the actual instance (as transient)
|
|
||||||
|
|
||||||
class BlockModel < Volt::Model
|
|
||||||
field :name
|
|
||||||
attr_accessor :block
|
|
||||||
|
|
||||||
def initialize(b)
|
|
||||||
super()
|
|
||||||
@block = b
|
|
||||||
self.name = b.nil? ? 'undefined' : b.name
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user