diff --git a/lib/block_view.rb b/lib/block_view.rb deleted file mode 100644 index 15bbd10..0000000 --- a/lib/block_view.rb +++ /dev/null @@ -1,12 +0,0 @@ -class BlockView < ElementView - - def initialize block - @block = block - end - attr_reader :block - - def draw - @element = div("div") << div("span.bright" , @block.name ) - end - -end diff --git a/lib/blocks_view.rb b/lib/blocks_view.rb index be162b5..444c5f9 100644 --- a/lib/blocks_view.rb +++ b/lib/blocks_view.rb @@ -1,4 +1,3 @@ -require_relative "block_view" class BlocksView < ListView @@ -41,3 +40,16 @@ class BlocksView < ListView "#{bl.method.for_class.name}.#{bl.method.name}" end end + +class BlockView < ElementView + + def initialize block + @block = block + end + attr_reader :block + + def draw + @element = div("div") << div("span.bright" , @block.name ) + end + +end diff --git a/lib/class_view.rb b/lib/class_view.rb deleted file mode 100644 index 5257b95..0000000 --- a/lib/class_view.rb +++ /dev/null @@ -1,14 +0,0 @@ -class ClassView < ElementView - def initialize clazz - @clazz = clazz - end - - def draw - @element = div("li") << div( "a" , @clazz.name ) << (ul = div("ul")) - @clazz.object_layout.object_instance_names.each do |name| - ul << (div("li") << div("a", name )) - end - @element.style["z-index"] = 20 - @element - end -end diff --git a/lib/classes_view.rb b/lib/classes_view.rb index bf41d9d..cf9f57c 100644 --- a/lib/classes_view.rb +++ b/lib/classes_view.rb @@ -1,4 +1,3 @@ -require_relative "class_view" class ClassesView < ListView @@ -21,3 +20,18 @@ class ClassesView < ListView end end + +class ClassView < ElementView + def initialize clazz + @clazz = clazz + end + + def draw + @element = div("li") << div( "a" , @clazz.name ) << (ul = div("ul")) + @clazz.object_layout.object_instance_names.each do |name| + ul << (div("li") << div("a", name )) + end + @element.style["z-index"] = 20 + @element + end +end diff --git a/lib/debugger.rb b/lib/debugger.rb index 30a73cd..3d0bc0d 100644 --- a/lib/debugger.rb +++ b/lib/debugger.rb @@ -1,7 +1,47 @@ require "opal" require "opal-parser" -require "main_view" + + +require 'browser' +require 'native' +require "salama" +require "interpreter/interpreter" +require "base/list_view" +require_relative "classes_view" +require_relative "status_view" +require_relative "file_view" +require_relative "blocks_view" +require_relative "instruction_view" +require_relative "registers_view" + +class MainView < ListView + + def initialize + machine = Virtual.machine.boot + + # compile_main includes the parse + # parsing generates an ast as seen below and then compiles it. + # machine.compile_main "2 + 5" + + # so the code above is functionally equivalent to the one below, minus the parse + # When the ast expression is given all works, so pretty sure it is the parse that fails + + code = Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5)) + Virtual::Compiler.compile( code , machine.space.get_main ) + + machine.run_before "Register::CallImplementation" + @interpreter = Interpreter::Interpreter.new + @interpreter.start machine.init + super( [ClassesView.new(@interpreter) , + FileView.new , + BlocksView.new(@interpreter) , + InstructionView.new(@interpreter) , + StatusView.new(@interpreter) , + RegistersView.new(@interpreter) ] ) + end + +end view = MainView.new() view.draw.append_to($document.body) diff --git a/lib/main_view.rb b/lib/main_view.rb deleted file mode 100644 index 17d3e5c..0000000 --- a/lib/main_view.rb +++ /dev/null @@ -1,40 +0,0 @@ - -require 'browser' -require 'native' -require "salama" -require "interpreter/interpreter" -require "base/list_view" -require_relative "classes_view" -require_relative "status_view" -require_relative "file_view" -require_relative "blocks_view" -require_relative "instruction_view" -require_relative "registers_view" - -class MainView < ListView - - def initialize - machine = Virtual.machine.boot - - # compile_main includes the parse - # parsing generates an ast as seen below and then compiles it. - # machine.compile_main "2 + 5" - - # so the code above is functionally equivalent to the one below, minus the parse - # When the ast expression is given all works, so pretty sure it is the parse that fails - - code = Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5)) - Virtual::Compiler.compile( code , machine.space.get_main ) - - machine.run_before "Register::CallImplementation" - @interpreter = Interpreter::Interpreter.new - @interpreter.start machine.init - super( [ClassesView.new(@interpreter) , - FileView.new , - BlocksView.new(@interpreter) , - InstructionView.new(@interpreter) , - StatusView.new(@interpreter) , - RegistersView.new(@interpreter) ] ) - end - -end diff --git a/lib/registers_view.rb b/lib/registers_view.rb index 6e130e2..66ca88d 100644 --- a/lib/registers_view.rb +++ b/lib/registers_view.rb @@ -1,5 +1,4 @@ require_relative "object_view" -require_relative "value_view" class RegistersView < ListView @@ -39,3 +38,14 @@ class RegistersView < ListView end end + +class ValueView < ElementView + + def initialize value + @value = value + end + + def draw + @element = div("ul.nav!") << div("li") << div("span", @value) + end +end diff --git a/lib/value_view.rb b/lib/value_view.rb deleted file mode 100644 index a2005b8..0000000 --- a/lib/value_view.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ValueView < ElementView - - def initialize value - @value = value - end - - def draw - @element = div("ul.nav!") << div("li") << div("span", @value) - end -end