2015-07-08 01:10:34 +02:00
|
|
|
require 'opal/pixi'
|
|
|
|
require 'native'
|
2015-07-09 14:23:36 +02:00
|
|
|
require "main/lib/registers_view"
|
2015-07-09 15:34:02 +02:00
|
|
|
require "main/lib/space_view"
|
2015-07-09 21:43:07 +02:00
|
|
|
require "salama"
|
2015-07-06 20:55:34 +02:00
|
|
|
|
2015-07-09 14:23:36 +02:00
|
|
|
class MainView
|
2015-07-09 11:32:29 +02:00
|
|
|
|
2015-07-06 20:55:34 +02:00
|
|
|
def initialize
|
2015-07-09 14:23:36 +02:00
|
|
|
@container = PIXI::Container.new
|
2015-07-09 11:32:29 +02:00
|
|
|
|
|
|
|
height = `window.innerHeight`
|
|
|
|
width = `window.innerWidth`
|
2015-07-09 14:23:36 +02:00
|
|
|
renderer = PIXI::WebGLRenderer.new( width - 100 , height - 100, {"backgroundColor" => 0xFFFFFF})
|
2015-07-08 01:10:34 +02:00
|
|
|
body = Native(`window.document.body`)
|
|
|
|
# bit of a hack as it assumes index's structure
|
2015-07-09 11:32:29 +02:00
|
|
|
html_con = body.firstElementChild
|
|
|
|
html_con.insertBefore renderer.view , html_con.lastElementChild
|
2015-07-06 20:55:34 +02:00
|
|
|
|
2015-07-09 15:34:02 +02:00
|
|
|
registers = RegisterView.new(height - 150)
|
|
|
|
@container.add_child registers
|
|
|
|
space = SpaceView.new
|
|
|
|
@container.add_child space
|
2015-07-06 20:55:34 +02:00
|
|
|
|
2015-07-08 01:10:34 +02:00
|
|
|
animate = Proc.new do
|
2015-07-09 11:32:29 +02:00
|
|
|
`requestAnimationFrame(animate)`
|
2015-07-09 15:34:02 +02:00
|
|
|
registers.update
|
|
|
|
space.update
|
|
|
|
renderer.render @container
|
2015-07-06 20:55:34 +02:00
|
|
|
end
|
2015-07-09 11:32:29 +02:00
|
|
|
animate.call
|
2015-07-09 14:23:36 +02:00
|
|
|
|
2015-07-09 21:43:07 +02:00
|
|
|
string_input = '"Hello again\n".putstring()'
|
|
|
|
|
|
|
|
machine = ::Virtual::Machine.boot
|
|
|
|
expressions = machine.compile_main string_input
|
|
|
|
if( expressions.first.is_a? Parfait::Method )
|
|
|
|
# stops the whole objectspace beeing tested
|
|
|
|
# with the class comes superclass and all methods
|
|
|
|
expressions.first.instance_variable_set :@for_class , nil
|
|
|
|
expressions.first.secret_layout_hammer
|
|
|
|
expressions.first.code.secret_layout_hammer
|
|
|
|
end
|
|
|
|
if( expressions.first.is_a? Virtual::Self )
|
|
|
|
# stops the whole objectspace beeing tested
|
|
|
|
# with the class comes superclass and all methods
|
|
|
|
expressions.first.type.instance_variable_set :@of_class , nil
|
|
|
|
end
|
|
|
|
is = Sof.write(expressions)
|
|
|
|
#puts is
|
|
|
|
is.gsub!("\n" , "*^*")
|
|
|
|
|
2015-07-06 20:55:34 +02:00
|
|
|
end
|
2015-07-09 14:23:36 +02:00
|
|
|
|
|
|
|
attr_reader :container
|
2015-07-06 20:55:34 +02:00
|
|
|
end
|