From 9383f0d75ee194edde05c0bafd3b06aced630252 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 29 Jul 2015 20:50:39 +0300 Subject: [PATCH] salaam boots and classes are shown --- {lib => app/main/controllers}/eventable.rb | 0 {lib => app/main/controllers}/interpreter.rb | 2 +- app/main/controllers/main_controller.rb | 26 ++++++++++++++++---- app/main/views/main/index.html | 9 ++++++- config/initializers/server/salama.rb | 2 ++ 5 files changed, 32 insertions(+), 7 deletions(-) rename {lib => app/main/controllers}/eventable.rb (100%) rename {lib => app/main/controllers}/interpreter.rb (99%) create mode 100644 config/initializers/server/salama.rb diff --git a/lib/eventable.rb b/app/main/controllers/eventable.rb similarity index 100% rename from lib/eventable.rb rename to app/main/controllers/eventable.rb diff --git a/lib/interpreter.rb b/app/main/controllers/interpreter.rb similarity index 99% rename from lib/interpreter.rb rename to app/main/controllers/interpreter.rb index b86ba4f..753f334 100644 --- a/lib/interpreter.rb +++ b/app/main/controllers/interpreter.rb @@ -1,5 +1,5 @@ -require "eventable" +require_relative "eventable" class Interpreter # fire events for changed pc and register contents diff --git a/app/main/controllers/main_controller.rb b/app/main/controllers/main_controller.rb index 547c80a..7c67267 100644 --- a/app/main/controllers/main_controller.rb +++ b/app/main/controllers/main_controller.rb @@ -1,11 +1,12 @@ # By default Volt generates this controller for your Main component +require "salama" +require_relative "interpreter" + module Main class MainController < Volt::ModelController def index -# 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 + init_machine + init_classes end def about @@ -13,7 +14,22 @@ module Main end private - + def init_machine + machine = Virtual.machine.boot + machine.run_before "Register::CallImplementation" + code = Ast::ExpressionList.new( [Ast::CallSiteExpression.new(:putstring, [] ,Ast::StringExpression.new("Hello again"))]) + Virtual::Compiler.compile( code , machine.space.get_main ) + @interpreter = Interpreter.new + @interpreter.start machine.init + end + def init_classes + page._classes!.clear + Virtual.machine.space.classes.each do |name , claz| + next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name + c = Volt::Model.new :name => name + page._classes << c + end + end # The main template contains a #template binding that shows another # template. This is the path to that template. It may change based # on the params._component, params._controller, and params._action values. diff --git a/app/main/views/main/index.html b/app/main/views/main/index.html index 7805be8..7831a13 100644 --- a/app/main/views/main/index.html +++ b/app/main/views/main/index.html @@ -2,8 +2,15 @@ Home <:Body> +
+

Classes

+ {{page._classes!.each do |clas| }} +
+ {{ clas._name }} +
+ {{end}} +
- ClassView classes: machine.space.classes
"Future Source code view"
diff --git a/config/initializers/server/salama.rb b/config/initializers/server/salama.rb new file mode 100644 index 0000000..6771268 --- /dev/null +++ b/config/initializers/server/salama.rb @@ -0,0 +1,2 @@ +Opal.use_gem "salama" +Opal.use_gem "salama-arm"