Class: Mirah::AST::Ensure

Inherits:
Node
  • Object
show all
Defined in:
lib/mirah/ast/flow.rb,
lib/mirah/compiler/flow.rb,
lib/mirah/jvm/source_generator/precompile.rb

Instance Attribute Summary collapse

Attributes inherited from Node

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

Instance Method Summary collapse

Methods inherited from Node

#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #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, &block) ⇒ Ensure

Returns a new instance of Ensure.



355
356
357
# File 'lib/mirah/ast/flow.rb', line 355

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

Instance Attribute Details

#stateObject

Used by some compilers.



353
354
355
# File 'lib/mirah/ast/flow.rb', line 353

def state
  @state
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



101
102
103
104
105
106
# File 'lib/mirah/compiler/flow.rb', line 101

def compile(compiler, expression)
  compiler.line(line_number)
  compiler.ensure(self, expression)
rescue Exception => ex
  raise Mirah::InternalCompilerError.wrap(ex, self)
end

#expr?(compiler) ⇒ Boolean

Returns:



194
195
196
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 194

def expr?(compiler)
  false
end

#infer(typer, expression) ⇒ Object



359
360
361
362
363
364
# File 'lib/mirah/ast/flow.rb', line 359

def infer(typer, expression)
  resolve_if(typer) do
    typer.infer(clause, false)
    typer.infer(body, true)
  end
end