Class: Mirah::Commands::Run

Inherits:
Base
  • Object
show all
Defined in:
lib/mirah/commands/run.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #argument_processor, #state

Instance Method Summary collapse

Methods inherited from Base

#execute_base, #initialize

Constructor Details

This class inherits a constructor from Mirah::Commands::Base

Instance Method Details

#command_nameObject



42
43
44
# File 'lib/mirah/commands/run.rb', line 42

def command_name
  :run
end

#executeObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mirah/commands/run.rb', line 22

def execute
  execute_base do
    main = nil
    class_map = {}
    
    # generate all bytes for all classes
    generator = Mirah::Generator.new(@state, @state.compiler_class, false, @state.verbose)
    
    generator.generate(args).each do |result|
      class_map[result.classname.gsub(/\//, '.')] = Mirah::Util::ClassLoader.binary_string result.bytes
    end
    
    # load all classes
    main = load_classes_and_find_main(class_map)
    
    # run the main method we found
    run_main(main)
  end
end