cleaning, upgrade last pre

This commit is contained in:
Torsten Ruger 2015-07-31 19:31:02 +03:00
parent cfc6f09ec1
commit ab08fcc7c1
13 changed files with 6 additions and 309 deletions

View File

@ -1,6 +1,6 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'volt', '0.9.5.pre3' gem 'volt', '0.9.5.pre4'
# volt uses mongo as the default data store. # volt uses mongo as the default data store.
gem 'volt-mongo', '~> 0.1.0' gem 'volt-mongo', '~> 0.1.0'
@ -16,6 +16,8 @@ gem "susy" , "2.2.5"
gem 'csso-rails', '~> 0.3.4', require: false gem 'csso-rails', '~> 0.3.4', require: false
gem 'uglifier', '>= 2.4.0', require: false gem 'uglifier', '>= 2.4.0', require: false
#gem "foundation" , :github => "zurb/foundation"
group :test do group :test do
# Testing dependencies # Testing dependencies
gem "minitest" gem "minitest"

View File

@ -137,7 +137,7 @@ GEM
uglifier (2.7.1) uglifier (2.7.1)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
volt (0.9.5.pre3) volt (0.9.5.pre4)
bcrypt (~> 3.1.9) bcrypt (~> 3.1.9)
bundler (>= 1.5) bundler (>= 1.5)
concurrent-ruby (= 0.8.0) concurrent-ruby (= 0.8.0)
@ -180,7 +180,7 @@ DEPENDENCIES
susy (= 2.2.5) susy (= 2.2.5)
thin (~> 1.6.0) thin (~> 1.6.0)
uglifier (>= 2.4.0) uglifier (>= 2.4.0)
volt (= 0.9.5.pre3) volt (= 0.9.5.pre4)
volt-mongo (~> 0.1.0) volt-mongo (~> 0.1.0)
BUNDLED WITH BUNDLED WITH

View File

@ -1,49 +0,0 @@
require "instruction_view"
class BlockView
include React::Component
required_param :interpreter
define_state :block => []
define_state :block_name => ""
before_mount do
interpreter.register_event(:instruction_changed, self)
update_block
end
def update_block
return unless interpreter.instruction
block_name! interpreter.block.name
codes = interpreter.block.codes.dup
slice = codes.index(interpreter.instruction) #- 1
codes.shift( slice ) if slice >= 0
codes.pop while(codes.length > 4)
block! codes
end
def instruction_changed
update_block
end
def render
return unless block
div.block_view do
div do
h4 { method_name}
h4 {"Block: #{block_name}"}
end
block.each do |code|
InstructionView :interpreter => interpreter , :instruction => code
end
end
end
def method_name
bl = interpreter.block
return bl.method if bl.method.is_a? String
"#{bl.method.for_class.name}.#{bl.method.name}"
end
end

View File

@ -1,16 +0,0 @@
class ClassView
include React::Component
required_param :classes, type: {}
def render
div.classes do
h4 { "Classes" }
classes.each do |name , clas|
div.one_class do
clas.name
end
end
end
end
end

View File

@ -1,37 +0,0 @@
require "register_view"
require "class_view"
require "source_view"
require "block_view"
require "status_view"
class Debugger
include React::Component
required_param :machine , :type => Virtual::Machine
define_state :interpreter => Interpreter.new
before_mount do
code = Ast::ExpressionList.new( [Ast::CallSiteExpression.new(:putstring, [] ,Ast::StringExpression.new("Hello again"))])
Virtual::Compiler.compile( code , machine.space.get_main )
machine.run_before "Register::CallImplementation"
interpreter.start machine.init
end
def render
div.debugger_view do
ClassView classes: machine.space.classes
div.file_view do
"Future Source code view"
end
SourceView :interpreter => interpreter
BlockView :interpreter => interpreter
StatusView :interpreter => interpreter
div.registers_view do
interpreter.registers.each do |r , oid|
RegisterView interpreter: interpreter , register: r
end
end
end
end
end

View File

@ -1,28 +0,0 @@
class InstructionView
include React::Component
required_param :interpreter
required_param :instruction
define_state :active => ""
before_mount do
check_active interpreter.instruction
end
def check_active i
active! instruction == i ? "bright" : ""
end
def instruction_changed old , ins
check_active ins
end
def render
div :class => active do
instruction.to_s if instruction
end
end
end

View File

@ -15,7 +15,6 @@ module Main
def index def index
init_machine init_machine
init_classes init_classes
init_registers
init_blocks init_blocks
init_source init_source
end end
@ -34,16 +33,7 @@ module Main
page._interpreter = { } page._interpreter = { }
@volt_app.interpreter.start machine.init @volt_app.interpreter.start machine.init
end end
def init_registers
page._registers!.clear
@volt_app.interpreter.registers.each do |reg , val|
model = RegisterModel.new( :name => reg , :value => val)
page._registers << model
@volt_app.interpreter.register_event(:register_changed, model)
@volt_app.interpreter.register_event(:object_changed, model)
model.register_changed( reg , nil , @volt_app.interpreter.registers[reg])
end
end
def init_classes def init_classes
page._classes!.clear page._classes!.clear
Virtual.machine.space.classes.each do |name , claz| Virtual.machine.space.classes.each do |name , claz|

View File

@ -1,64 +0,0 @@
class RegisterView
include React::Component
required_param :interpreter
required_param :register
define_state :objects_id
define_state :fields => []
before_mount do
interpreter.register_event(:register_changed, self)
interpreter.register_event(:object_changed, self)
register_changed( register , nil , interpreter.registers[register])
end
def register_changed reg , old , value
reg = reg.symbol unless reg.is_a? Symbol
return unless reg == register
objects_id! value
calc_fields
end
def object_changed reg
reg = reg.symbol unless reg.is_a? Symbol
return unless reg == register
#puts "Object changed in #{reg}"
calc_fields
end
def calc_fields
#puts "My id #{objects_id} , #{objects_id.class}"
object = Virtual.machine.objects[objects_id]
if object and ! object.is_a?(String)
has_fields = []
clazz = object.class.name.split("::").last
#puts "found #{clazz}"
has_fields << clazz
object.get_instance_variables.each do |variable|
f = object.get_instance_variable(variable)
has_fields << f
end
fields! has_fields
end
end
def render
div.register_view do
div do
objects_id.to_s
end
fields.each do |attribute|
div.col_md_12 do
"#{marker(attribute)} - #{attribute.object_id}".span
end
end
end
end
def marker var
return "W" if var.is_a? String
var.class.name.split("::").last[0]
end
end

View File

@ -1,38 +0,0 @@
class SourceView
include React::Component
required_param :interpreter
define_state :sources => []
before_mount do
interpreter.register_event(:instruction_changed, self)
instruction_changed nil , interpreter.instruction
end
def instruction_changed old , ins
text = ins ? source_text(ins.source) : "exit"
return if sources.last == text
sources << text
sources.shift if sources.length > 5
sources! sources
end
def render
div.source_view do
h4 {"Virtual Machine Instruction"}
sources.each do |s|
s.br
end
end
end
def source_text source
if source.is_a? Virtual::Instruction
return source.class.name
else
return "Method: #{source.name}"
end
end
end

View File

@ -1,41 +0,0 @@
class StatusView
include React::Component
required_param :interpreter
define_state :state => "starting"
define_state :stdout
before_mount do
interpreter.register_event(:instruction_changed, self)
end
def update_state
state! interpreter.state
stdout! interpreter.stdout
end
def instruction_changed old , nex
update_state
end
def render
div.status_view do
div do
button.bright { "next" }.on(:click) { interpreter.tick }
" ".br
end
div do
h4 {"Status:"}
state.to_s.br
end
div do
h4 {"Stdout:"}
end
div do
interpreter.stdout.br
end
end
end
end

View File

@ -1,22 +0,0 @@
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :test)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
if ENV['CODECLIMATE_REPO_TOKEN']
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
end
require "minitest/autorun"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', "app" , "main",'lib'))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))
require "salama"
require "interpreter"