From f5ece67233f93a745964b0b19e67b0a1d4e2a28a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 24 Jul 2015 10:15:58 +0300 Subject: [PATCH] first interpreted instruction, with gui change --- app/block_view.rb | 15 ++++++++++----- app/source_view.rb | 4 ++-- lib/interpreter.rb | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/block_view.rb b/app/block_view.rb index 910ac42..af3b5b3 100644 --- a/app/block_view.rb +++ b/app/block_view.rb @@ -6,21 +6,26 @@ class BlockView include React::Component required_param :interpreter + define_state :block + before_mount do - interpreter.register_event(event: :block_changed, listener: self, callback: :block_changed) + interpreter.register_event(:block_changed, self) + block! interpreter.block end - def block_changed block - block! block + def block_changed old , bl + block! bl end def render + return unless block div.row do div.col_md_5 do - SourceView :source => interpreter.block.codes.first.source + SourceView :source => block.codes.first.source end div.col_md_5 do - interpreter.block.codes.each do |code| + h6 { "Block: #{block.name}"} + block.codes.each do |code| code.to_s.br end end diff --git a/app/source_view.rb b/app/source_view.rb index 3ba87d6..d5fabbb 100644 --- a/app/source_view.rb +++ b/app/source_view.rb @@ -6,8 +6,8 @@ class SourceView def render div.row do - "Virtual Machine Instruction".span - source + "Virtual Machine Instruction".br + source.class.name end end diff --git a/lib/interpreter.rb b/lib/interpreter.rb index 3dcbf6f..da6f92a 100644 --- a/lib/interpreter.rb +++ b/lib/interpreter.rb @@ -36,7 +36,8 @@ class Interpreter end def execute_Branch - target = @instruction.to + target = @instruction.block set_block target + false end end