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

47 lines
1.5 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"
require_relative "interpreter"
2015-07-29 16:26:04 +02:00
module Main
class MainController < Volt::ModelController
def index
2015-07-29 19:50:39 +02:00
init_machine
init_classes
2015-07-29 16:26:04 +02:00
end
def about
# Add code for when the about view is loaded
end
private
2015-07-29 19:50:39 +02:00
def init_machine
machine = Virtual.machine.boot
machine.run_before "Register::CallImplementation"
code = Ast::ExpressionList.new( [Ast::CallSiteExpression.new(:putstring, [] ,Ast::StringExpression.new("Hello again"))])
Virtual::Compiler.compile( code , machine.space.get_main )
@interpreter = Interpreter.new
@interpreter.start machine.init
end
def init_classes
page._classes!.clear
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
end
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