2015-07-06 20:55:34 +02:00
|
|
|
|
2015-07-16 09:43:49 +02:00
|
|
|
require "opal/parser" # to get eval to work
|
2015-07-17 21:44:20 +02:00
|
|
|
|
|
|
|
$LOAD_PATH.unshift("/Users/raisa/salama/salama-debugger/app/main/lib")
|
|
|
|
|
2015-07-16 09:43:49 +02:00
|
|
|
require "salama"
|
2015-07-09 14:23:36 +02:00
|
|
|
|
2015-07-12 09:03:23 +02:00
|
|
|
Virtual::Machine.boot
|
|
|
|
|
2015-07-06 13:20:21 +02:00
|
|
|
module Main
|
|
|
|
class MainController < Volt::ModelController
|
2015-07-06 21:22:57 +02:00
|
|
|
|
2015-07-06 13:20:21 +02:00
|
|
|
def index
|
2015-07-16 09:43:49 +02:00
|
|
|
page._registers!.clear
|
|
|
|
page._classes!.clear
|
|
|
|
page._objects!.clear
|
2015-07-17 21:44:20 +02:00
|
|
|
page._source = InstructionModel.new nil
|
2015-07-17 14:14:41 +02:00
|
|
|
page._block = BlockModel.new nil
|
2015-07-16 09:43:49 +02:00
|
|
|
fill_regs
|
|
|
|
parse_and_fill
|
2015-07-06 13:20:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def about
|
2015-07-12 09:03:23 +02:00
|
|
|
|
2015-07-06 13:20:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-07-16 09:43:49 +02:00
|
|
|
def parse_and_fill
|
|
|
|
ParseTask.parse(1).then do |result|
|
|
|
|
is = Ast::Expression.from_basic(result)
|
|
|
|
Virtual::Compiler.compile( is , Virtual.machine.space.get_main )
|
2015-07-17 14:14:41 +02:00
|
|
|
Virtual.machine.run_before "Register::CallImplementation"
|
2015-07-16 09:43:49 +02:00
|
|
|
fill_classes
|
|
|
|
end.fail do |error|
|
|
|
|
raise "Error: #{error}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def fill_classes
|
|
|
|
Virtual.machine.space.classes.each do |name , claz|
|
|
|
|
next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name
|
|
|
|
c = Volt::Model.new :name => name
|
|
|
|
page._classes << c
|
|
|
|
end
|
2015-07-17 14:14:41 +02:00
|
|
|
page._block = BlockModel.new Virtual.machine.init
|
2015-07-16 09:43:49 +02:00
|
|
|
end
|
|
|
|
def fill_regs
|
|
|
|
register_names = (0..8).collect {|i| "r#{i}"}
|
|
|
|
register_names.each do |reg_name|
|
|
|
|
reg = Volt::Model.new :name => reg_name
|
|
|
|
page._registers << reg
|
|
|
|
end
|
|
|
|
end
|
2015-07-06 13:20:21 +02:00
|
|
|
# The main template contains a #template binding that shows another
|
|
|
|
# template. This is the path to that template. It may change based
|
|
|
|
# on the params._component, params._controller, and params._action values.
|
|
|
|
def main_path
|
|
|
|
"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Determine if the current nav component is the active one by looking
|
|
|
|
# at the first part of the url against the href attribute.
|
|
|
|
def active_tab?
|
|
|
|
url.path.split('/')[1] == attrs.href.split('/')[1]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|