Class: Rubex::AST::Statement::BeginBlock::Rescue

Inherits:
Base show all
Defined in:
lib/rubex/ast/statement/begin_block/rescue.rb

Instance Attribute Summary collapse

Attributes inherited from Rubex::AST::Statement::Base

#location

Instance Method Summary collapse

Methods inherited from Rubex::AST::Statement::Base

#==, #statement?

Constructor Details

#initialize(error_klass, error_obj, statements, location) ⇒ Rescue

Returns a new instance of Rescue.



8
9
10
11
12
# File 'lib/rubex/ast/statement/begin_block/rescue.rb', line 8

def initialize(error_klass, error_obj, statements, location)
  super(statements, location)
  @error_klass = error_klass
  @error_obj = error_obj
end

Instance Attribute Details

#error_klassObject (readonly)

Returns the value of attribute error_klass.



6
7
8
# File 'lib/rubex/ast/statement/begin_block/rescue.rb', line 6

def error_klass
  @error_klass
end

Instance Method Details

#analyse_statement(local_scope) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/rubex/ast/statement/begin_block/rescue.rb', line 14

def analyse_statement(local_scope)
  @error_klass.analyse_types local_scope
  unless @error_klass.type.ruby_constant?
    raise "Must pass an error class to raise. Location #{@location}."
  end

  @statements.each do |stmt|
    stmt.analyse_statement local_scope
  end
end

#generate_code(code, local_scope) ⇒ Object



25
26
27
28
29
# File 'lib/rubex/ast/statement/begin_block/rescue.rb', line 25

def generate_code(code, local_scope)
  @statements.each do |stmt|
    stmt.generate_code code, local_scope
  end
end