rubyx-debugger/lib/main_view.rb

57 lines
1.3 KiB
Ruby
Raw Normal View History

2015-07-14 15:03:06 +02:00
2015-07-14 13:08:28 +02:00
require 'browser'
2015-07-08 01:10:34 +02:00
require 'native'
2015-07-09 21:43:07 +02:00
require "salama"
2015-08-20 00:53:20 +02:00
require "interpreter/interpreter"
2015-08-20 14:48:45 +02:00
require "list_view"
2015-08-20 00:53:20 +02:00
require_relative "class_view"
#require_relative "registers_view"
#require_relative "object_view"
#require_relative "space_view"
2015-08-20 14:48:45 +02:00
class MainView < ListView
2015-07-09 11:32:29 +02:00
2015-07-06 20:55:34 +02:00
def initialize
2015-08-20 00:53:20 +02:00
machine = Virtual.machine.boot
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
2015-08-20 14:48:45 +02:00
@parent = $document.body
puts @parent.parent.name
2015-08-20 00:53:20 +02:00
draw
2015-07-14 15:03:06 +02:00
end
2015-07-09 11:32:29 +02:00
2015-08-20 00:53:20 +02:00
def draw
2015-08-20 14:48:45 +02:00
node = DOM {
2015-08-20 00:53:20 +02:00
div.info {
span.red "I'm all cooked up."
}
2015-08-20 14:48:45 +02:00
}
node.append_to(@parent)
2015-08-20 00:53:20 +02:00
end
def no
2015-07-14 13:08:28 +02:00
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)
2015-07-14 13:08:28 +02:00
@canvas.add_child registers
2015-07-13 14:14:34 +02:00
space = SpaceView.new
2015-07-09 15:34:02 +02:00
@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)`
registers.draw_me
space.draw_me
2015-07-09 15:34:02 +02:00
renderer.render @container
2015-07-06 20:55:34 +02:00
end
2015-07-09 11:32:29 +02:00
animate.call
2015-07-06 20:55:34 +02:00
end
2015-07-06 20:55:34 +02:00
end