Class: Mirah::Commands::Base
- Inherits:
-
Object
- Object
- Mirah::Commands::Base
- Defined in:
- lib/mirah/commands/base.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#argument_processor ⇒ Object
Returns the value of attribute argument_processor.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #execute_base ⇒ Object
-
#initialize(args) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(args) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 |
# File 'lib/mirah/commands/base.rb', line 24 def initialize(args) Mirah::AST.type_factory = Mirah::JVM::Types::TypeFactory.new @state = Mirah::Util::CompilationState.new @state.command = command_name @args = args @argument_processor = Mirah::Util::ArgumentProcessor.new(@state, @args) end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
32 33 34 |
# File 'lib/mirah/commands/base.rb', line 32 def args @args end |
#argument_processor ⇒ Object
Returns the value of attribute argument_processor.
32 33 34 |
# File 'lib/mirah/commands/base.rb', line 32 def argument_processor @argument_processor end |
#state ⇒ Object
Returns the value of attribute state.
32 33 34 |
# File 'lib/mirah/commands/base.rb', line 32 def state @state end |
Instance Method Details
#execute_base ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mirah/commands/base.rb', line 34 def execute_base # because MirahCommand is a JRuby Java class, SystemExit bubbles through and makes noise # so we use a catch/throw to early exit instead # see process_errors.rb catch(:exit) do begin argument_processor.process yield rescue Mirah::InternalCompilerError => ice Mirah.print_error(ice., ice.position) if ice.node raise ice.cause if (ice.cause && state.verbose) raise ice rescue Mirah::MirahError => ex Mirah.print_error(ex., ex.position) puts ex.backtrace if state.verbose end end end |