Class: Y2R::AST::YCP::YEReturn

Inherits:
Node
  • Object
show all
Defined in:
lib/y2r/ast/ycp.rb

Instance Method Summary collapse

Methods inherited from Node

#always_returns?, #compile_as_copy_if_needed, #compile_statements, #compile_statements_inside_block, #compile_statements_with_whitespace, #needs_copy?, #never_nil?, #optimize_last_statement, #optimize_next, #optimize_return, #remove_duplicate_imports, transfers_comments

Instance Method Details

#compile(context) ⇒ Object



2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
# File 'lib/y2r/ast/ycp.rb', line 2366

def compile(context)
  Ruby::MethodCall.new(
    :receiver => nil,
    :name     => "lambda",
    :args     => [],
    :block    => Ruby::Block.new(
      :args       => [],
      :statements => child.compile(context)
    ),
    :parens   => true
  )
end

#compile_as_block(context) ⇒ Object



2379
2380
2381
2382
2383
2384
2385
2386
# File 'lib/y2r/ast/ycp.rb', line 2379

def compile_as_block(context)
  context.inside self do |inner_context|
    Ruby::Block.new(
      :args       => args.map { |a| a.compile(inner_context) },
      :statements => child.compile(inner_context)
    )
  end
end

#creates_local_scope?Boolean

Returns:

  • (Boolean)


2362
2363
2364
# File 'lib/y2r/ast/ycp.rb', line 2362

def creates_local_scope?
  true
end