From a49ef347ff53d48dee02a40e180fd925494e59ee Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 14 Jul 2015 16:03:06 +0300 Subject: [PATCH] more opal changes --- Gemfile | 2 +- Gemfile.lock | 12 ++++++++---- config.ru | 13 ++++++++++++- lib/debugger.rb | 2 +- lib/main_view.rb | 22 +++++++++++++++------- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index 7402aee..9eae1a3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' -gem 'opal-browser' +gem 'opal-browser' , :path => "../opal-browser" #gem "salama" , "0.2" , :path => "../salama" diff --git a/Gemfile.lock b/Gemfile.lock index f9f0671..4b15662 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +PATH + remote: ../opal-browser + specs: + opal-browser (0.2.0.beta1) + opal + paggio + PATH remote: ../parslet specs: @@ -48,9 +55,6 @@ GEM sourcemap (~> 0.1.0) sprockets (~> 3.1) tilt (>= 1.4) - opal-browser (0.1.0.beta1) - opal (>= 0.5.5) - paggio opal-rspec (0.4.3) opal (>= 0.7.0, < 0.9) paggio (0.2.4) @@ -98,7 +102,7 @@ PLATFORMS DEPENDENCIES capybara (~> 2.4.2) chromedriver2-helper (~> 0.0.8) - opal-browser + opal-browser! opal-rspec (~> 0.4.2) parslet! poltergeist (~> 1.5.0) diff --git a/config.ru b/config.ru index f3d09ef..ff3b732 100644 --- a/config.ru +++ b/config.ru @@ -1,11 +1,22 @@ require 'bundler' Bundler.require +require_relative "lib/parse_task" require "opal" Opal.use_gem("salama") -run Opal::Server.new { |s| +class DebugServer < Opal::Server + def call(env) + if( env["REQUEST_PATH"] == "/tasks.json") + [200, { 'Content-Type' => 'text/json' }, [ParseTask.new.parse(1).to_json]] + else + super(env) + end + end +end +run DebugServer.new { |s| s.main = 'debugger' s.append_path 'lib' + s.source_map = true s.debug = true } diff --git a/lib/debugger.rb b/lib/debugger.rb index 9d35f24..186a704 100644 --- a/lib/debugger.rb +++ b/lib/debugger.rb @@ -1,6 +1,6 @@ require "opal" - +require "opal-parser" require "main_view" Virtual::Machine.boot diff --git a/lib/main_view.rb b/lib/main_view.rb index be68244..b1492dc 100644 --- a/lib/main_view.rb +++ b/lib/main_view.rb @@ -1,4 +1,7 @@ + require 'browser' +require 'browser/canvas' +require 'browser/http' require 'native' require "salama" require "point" @@ -11,6 +14,18 @@ class MainView def initialize @canvas = Browser::Canvas.new + @canvas.element.width = 1000 + @canvas.element.height = 500 + Browser::HTTP.get "/tasks.json" do + on :success do |res| + is = Ast::Expression.from_basic(res.json) + Virtual::Compiler.compile( is , Virtual.machine.space.get_main ) + Virtual.machine.run_before Virtual::Machine::FIRST_PASS + end + end + @canvas.append_to($document.body) + end + def no height = `window.innerHeight` width = `window.innerWidth` @@ -23,13 +38,6 @@ class MainView registers = RegisterView.new(height - 150) @canvas.add_child registers - ParseTask.parse(1).then do |result| - is = Ast::Expression.from_basic(result) - Virtual::Compiler.compile( is , Virtual.machine.space.get_main ) - Virtual.machine.run_before Virtual::Machine::FIRST_PASS - end.fail do |error| - raise "Error: #{error}" - end space = SpaceView.new @container.add_child space