52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
|
|
require "opal"
|
|
require "opal-parser"
|
|
|
|
|
|
require 'browser'
|
|
require 'native'
|
|
require "salama"
|
|
require "salama-reader"
|
|
require "ast"
|
|
require "interpreter/interpreter"
|
|
# the base, our own litle framework, allows for child and parent views and handles updates
|
|
require "base/list_view"
|
|
# each seperate view is in it's own class.
|
|
require "views/classes_view"
|
|
require "views/status_view"
|
|
require "views/file_view"
|
|
require "views/blocks_view"
|
|
require "views/instruction_view"
|
|
require "views/registers_view"
|
|
require "code"
|
|
|
|
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
|
|
|
|
Phisol::Compiler.compile( CODE )
|
|
|
|
machine.collect
|
|
@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)
|