diff --git a/app/main/controllers/main_controller.rb b/app/main/controllers/main_controller.rb index e56388f..2106b67 100644 --- a/app/main/controllers/main_controller.rb +++ b/app/main/controllers/main_controller.rb @@ -1,9 +1,6 @@ -# By default Volt generates this controller for your Main component -require "salama" -if RUBY_PLATFORM == 'opal' - require "main/lib/main_view" -end +require "opal/parser" # to get eval to work +require "salama" Virtual::Machine.boot @@ -11,7 +8,12 @@ module Main class MainController < Volt::ModelController def index - MainView.new() + page._registers!.clear + page._classes!.clear + page._objects!.clear + + fill_regs + parse_and_fill end def about @@ -20,6 +22,34 @@ module Main private + def parse_and_fill + ParseTask.parse(1).then do |result| + is = Ast::Expression.from_basic(result) + Virtual::Compiler.compile( is , Virtual.machine.space.get_main ) + begin + Virtual.machine.run_before Virtual::Machine::FIRST_PASS + rescue => e + puts "FILL #{e}" + end + fill_classes + end.fail do |error| + raise "Error: #{error}" + end + end + def fill_classes + 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 + def fill_regs + register_names = (0..8).collect {|i| "r#{i}"} + register_names.each do |reg_name| + reg = Volt::Model.new :name => reg_name + page._registers << reg + 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/lib/main_view.rb b/app/main/lib/main_view.rb deleted file mode 100644 index a593807..0000000 --- a/app/main/lib/main_view.rb +++ /dev/null @@ -1,26 +0,0 @@ - -require "salama" - -require_relative "registers_view" -require_relative "object_view" -require_relative "space_view" - -class MainView - - def initialize - - registers = RegisterView.new(max) - - 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(max) - - - end - -end diff --git a/app/main/lib/registers_view.rb b/app/main/lib/registers_view.rb deleted file mode 100644 index b2f363d..0000000 --- a/app/main/lib/registers_view.rb +++ /dev/null @@ -1,8 +0,0 @@ - -class RegisterView - - @@register_names = (0..8).collect {|i| "r#{i}"} - - def initialize max - end -end diff --git a/app/main/views/main/index.html b/app/main/views/main/index.html index 4776f93..cf60634 100644 --- a/app/main/views/main/index.html +++ b/app/main/views/main/index.html @@ -1,4 +1,20 @@ <:Title> - Home + Debugger <:Body> +
+ {{ page._classes.each do |c| }} +
+ {{ c._name }}
+ +
+ {{ end }} +
+ +
+ {{ page._registers.each do |c| }} +
+ {{ c._name }} +
+ {{ end }} +