Class: Duby::AST::RescueClause

Inherits:
Node
  • Object
show all
Includes:
Scoped
Defined in:
lib/duby/ast/flow.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #inferred_type, #newline, #parent, #position

Instance Method Summary collapse

Methods included from Scoped

#containing_scope, #scope

Methods inherited from Node

#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

#initialize(parent, position, &block) ⇒ RescueClause

Returns a new instance of RescueClause.



286
287
288
# File 'lib/duby/ast/flow.rb', line 286

def initialize(parent, position, &block)
  super(parent, position, &block)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



282
283
284
# File 'lib/duby/ast/flow.rb', line 282

def name
  @name
end

#typeObject

Returns the value of attribute type.



282
283
284
# File 'lib/duby/ast/flow.rb', line 282

def type
  @type
end

Instance Method Details

#infer(typer) ⇒ Object



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/duby/ast/flow.rb', line 290

def infer(typer)
  unless resolved?
    if name
      scope.static_scope << name
      orig_type = typer.local_type(containing_scope, name)
      # TODO find the common parent Throwable
      @type = types.size == 1 ? types[0] : AST.type('java.lang.Throwable')
      typer.learn_local_type(containing_scope, name, @type)
    end
    @inferred_type = typer.infer(body)

    if (@inferred_type && !body.resolved?)
      puts "#{body} not resolved"
    end

    (@inferred_type && body.resolved?) ? resolved! : typer.defer(self)
    typer.local_type_hash(containing_scope)[name] = orig_type if name
  end

  @inferred_type
end