Class: Y2R::AST::YCP::YEReference

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, #creates_local_scope?, #needs_copy?, #never_nil?, #optimize_last_statement, #optimize_next, #optimize_return, #remove_duplicate_imports, transfers_comments

Instance Method Details

#compile(context) ⇒ Object



2328
2329
2330
# File 'lib/y2r/ast/ycp.rb', line 2328

def compile(context)
  child.compile_as_ref(context)
end

#compile_as_getter(context) ⇒ Object



2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
# File 'lib/y2r/ast/ycp.rb', line 2345

def compile_as_getter(context)
  Ruby::Assignment.new(
    :lhs => child.compile(context),
    :rhs => Ruby::MethodCall.new(
      :receiver => compile(context),
      :name     => "value",
      :args     => [],
      :block    => nil,
      :parens   => true
    )
  )
end

#compile_as_setter(context) ⇒ Object



2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
# File 'lib/y2r/ast/ycp.rb', line 2332

def compile_as_setter(context)
  Ruby::Assignment.new(
    :lhs => compile(context),
    :rhs => Ruby::MethodCall.new(
      :receiver => nil,
      :name     => "arg_ref",
      :args     => [child.compile(context)],
      :block    => nil,
      :parens   => true
    )
  )
end