Class: Mirah::AST::RescueClause
- Defined in:
- lib/mirah/ast/flow.rb
Instance Attribute Summary collapse
-
#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 included from Scope
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #binding_type(mirah = nil) ⇒ Object
- #binding_type=(type) ⇒ Object
- #has_binding? ⇒ Boolean
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, position) ⇒ RescueClause
constructor
A new instance of RescueClause.
Methods included from Scoped
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, position) ⇒ RescueClause
Returns a new instance of RescueClause.
279 280 281 282 283 284 |
# File 'lib/mirah/ast/flow.rb', line 279 def initialize(parent, position) super(parent, position) do static_scope.parent = scope.static_scope yield(self) if block_given? end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
275 276 277 |
# File 'lib/mirah/ast/flow.rb', line 275 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
275 276 277 |
# File 'lib/mirah/ast/flow.rb', line 275 def type @type end |
#types ⇒ Object
Returns the value of attribute types.
275 276 277 |
# File 'lib/mirah/ast/flow.rb', line 275 def types @types end |
Instance Method Details
#binding_type(mirah = nil) ⇒ Object
303 304 305 |
# File 'lib/mirah/ast/flow.rb', line 303 def binding_type(mirah=nil) static_scope.parent.binding_type(defining_class, mirah) end |
#binding_type=(type) ⇒ Object
307 308 309 |
# File 'lib/mirah/ast/flow.rb', line 307 def binding_type=(type) static_scope.parent.binding_type = type end |
#has_binding? ⇒ Boolean
311 312 313 |
# File 'lib/mirah/ast/flow.rb', line 311 def has_binding? static_scope.parent.has_binding? end |
#infer(typer, expression) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/mirah/ast/flow.rb', line 286 def infer(typer, expression) unless resolved? @types ||= type_nodes.map {|n| n.type_reference(typer)} if name static_scope.shadow(name) # TODO find the common parent Throwable @type = types.size == 1 ? types[0] : AST.type(nil, 'java.lang.Throwable') typer.learn_local_type(static_scope, name, @type) end @inferred_type = typer.infer(body, true) (@inferred_type && body.resolved?) ? resolved! : typer.defer(self) end @inferred_type end |