rubyx-debugger/app/main/controllers/main_controller.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

2015-07-29 16:26:04 +02:00
# By default Volt generates this controller for your Main component
2015-07-29 19:50:39 +02:00
require "salama"
2015-07-30 18:23:25 +02:00
require "interpreter/interpreter"
2015-07-29 19:50:39 +02:00
2015-07-30 09:09:04 +02:00
2015-07-29 16:26:04 +02:00
module Main
class MainController < Volt::ModelController
def initialize *args
super(*args)
@volt_app.class.attr_accessor :interpreter
@volt_app.interpreter = Interpreter::Interpreter.new
end
2015-07-29 16:26:04 +02:00
def index
2015-07-29 19:50:39 +02:00
init_machine
2015-07-29 16:26:04 +02:00
end
private
2015-07-30 14:05:22 +02:00
2015-07-29 19:50:39 +02:00
def init_machine
machine = Virtual.machine.boot
2015-08-04 20:45:49 +02:00
code = Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5))
2015-07-29 19:50:39 +02:00
Virtual::Compiler.compile( code , machine.space.get_main )
2015-07-30 09:27:27 +02:00
machine.run_before "Register::CallImplementation"
2015-07-30 14:05:22 +02:00
page._interpreter = { }
@volt_app.interpreter.start machine.init
2015-07-29 19:50:39 +02:00
end
2015-07-31 18:31:02 +02:00
2015-07-29 16:26:04 +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