inlined mini clases

This commit is contained in:
Torsten Ruger 2015-08-24 01:49:41 +02:00
parent b3de7c9b5e
commit c5a07be6ac
8 changed files with 80 additions and 80 deletions

View File

@ -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

View File

@ -1,4 +1,3 @@
require_relative "block_view"
class BlocksView < ListView class BlocksView < ListView
@ -41,3 +40,16 @@ class BlocksView < ListView
"#{bl.method.for_class.name}.#{bl.method.name}" "#{bl.method.for_class.name}.#{bl.method.name}"
end end
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

View File

@ -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

View File

@ -1,4 +1,3 @@
require_relative "class_view"
class ClassesView < ListView class ClassesView < ListView
@ -21,3 +20,18 @@ class ClassesView < ListView
end end
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

View File

@ -1,7 +1,47 @@
require "opal" require "opal"
require "opal-parser" 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 = MainView.new()
view.draw.append_to($document.body) view.draw.append_to($document.body)

View File

@ -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

View File

@ -1,5 +1,4 @@
require_relative "object_view" require_relative "object_view"
require_relative "value_view"
class RegistersView < ListView class RegistersView < ListView
@ -39,3 +38,14 @@ class RegistersView < ListView
end end
end end
class ValueView < ElementView
def initialize value
@value = value
end
def draw
@element = div("ul.nav!") << div("li") << div("span", @value)
end
end

View File

@ -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