Class: Duby::AST::RescueClause
- Includes:
- Scoped
- Defined in:
- lib/duby/ast/flow.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#types ⇒ Object
Returns the value of attribute types.
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #infer(typer) ⇒ Object
-
#initialize(parent, position, &block) ⇒ RescueClause
constructor
A new instance of RescueClause.
Methods included from Scoped
Methods inherited from Node
#[], #each, #expr?, #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.
262 263 264 265 |
# File 'lib/duby/ast/flow.rb', line 262 def initialize(parent, position, &block) super(parent, position, &block) @types, @body = children end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
260 261 262 |
# File 'lib/duby/ast/flow.rb', line 260 def body @body end |
#name ⇒ Object
Returns the value of attribute name.
260 261 262 |
# File 'lib/duby/ast/flow.rb', line 260 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
260 261 262 |
# File 'lib/duby/ast/flow.rb', line 260 def type @type end |
#types ⇒ Object
Returns the value of attribute types.
260 261 262 |
# File 'lib/duby/ast/flow.rb', line 260 def types @types end |
Instance Method Details
#infer(typer) ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/duby/ast/flow.rb', line 267 def infer(typer) unless resolved? if name orig_type = typer.local_type(scope, name) # TODO find the common parent Throwable @type = types.size == 1 ? types[0] : AST.type('java.lang.Throwable') typer.learn_local_type(scope, name, @type) end @inferred_type = typer.infer(body) (@inferred_type && body.resolved?) ? resolved! : typer.defer(self) typer.local_type_hash(scope)[name] = orig_type if name end @inferred_type end |