Class: Duby::AST::Ensure

Inherits:
Node show all
Defined in:
lib/duby/ast/flow.rb,
lib/duby/compiler.rb,
lib/duby/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

#[], #each, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

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

Returns a new instance of Ensure.



311
312
313
314
# File 'lib/duby/ast/flow.rb', line 311

def initialize(parent, position, &block)
  super(parent, position, &block)
  @body, @clause = children
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



308
309
310
# File 'lib/duby/ast/flow.rb', line 308

def body
  @body
end

#clauseObject (readonly)

Returns the value of attribute clause.



308
309
310
# File 'lib/duby/ast/flow.rb', line 308

def clause
  @clause
end

#stateObject

Used by the some compilers.



309
310
311
# File 'lib/duby/ast/flow.rb', line 309

def state
  @state
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



255
256
257
258
# File 'lib/duby/compiler.rb', line 255

def compile(compiler, expression)
  compiler.line(line_number)
  compiler.ensure(self, expression)
end

#ensuresObject



323
324
325
# File 'lib/duby/ast/flow.rb', line 323

def ensures
  [self]
end

#expr?(compiler) ⇒ Boolean

Returns:



138
139
140
# File 'lib/duby/jvm/source_generator/precompile.rb', line 138

def expr?(compiler)
  false
end

#infer(typer) ⇒ Object



316
317
318
319
320
321
# File 'lib/duby/ast/flow.rb', line 316

def infer(typer)
  resolve_if(typer) do
    typer.infer(clause)
    typer.infer(body)
  end
end