dee9eb4dca
strings and encodings are definitely not the same for mir and opal the code point version works for me with utf16 encoding (on my machine?) utf16 is sensible choice though may go with it
59 lines
1.3 KiB
Ruby
59 lines
1.3 KiB
Ruby
|
|
require "opal"
|
|
require "opal-parser"
|
|
|
|
require "logger"
|
|
require 'browser'
|
|
require 'browser/http'
|
|
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/switch_view"
|
|
require "views/status_view"
|
|
require "views/source_view"
|
|
require "views/instruction_view"
|
|
require "views/registers_view"
|
|
class Bignum
|
|
end
|
|
class String
|
|
def codepoints
|
|
arr = []
|
|
one = nil
|
|
self.each_byte do |c|
|
|
if( one )
|
|
arr << (one + c * 256)
|
|
one = nil
|
|
else
|
|
one = c
|
|
end
|
|
end
|
|
arr
|
|
end
|
|
end
|
|
class MainView < ListView
|
|
include AST::Sexp
|
|
|
|
def initialize
|
|
machine = Register.machine.boot
|
|
code = s(:statements, s(:class, :Object, s(:derives, nil),
|
|
s(:statements, s(:class_field, :Integer, :x))))
|
|
Soml.compile( code )
|
|
machine.collect
|
|
@interpreter = Interpreter::Interpreter.new
|
|
super( [SwitchView.new(@interpreter) ,
|
|
SourceView.new(@interpreter) ,
|
|
InstructionView.new(@interpreter) ,
|
|
StatusView.new(@interpreter) ,
|
|
RegistersView.new(@interpreter) ] )
|
|
end
|
|
|
|
end
|
|
|
|
view = MainView.new()
|
|
view.draw.append_to($document.body)
|