Class: Y2R::AST::YCP::Include

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



1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/y2r/ast/ycp.rb', line 1429

def compile(context)
  if !context.at_toplevel?
    raise NotImplementedError,
          "Non-toplevel includes are not supported."
  end

  args = [
    if context.options[:as_include_file]
      Ruby::Variable.new(:name => "include_target")
    else
      Ruby::Self.new
    end,
    Ruby::Literal.new(:value => name.sub(/\.y(cp|h)$/, ".rb"))
  ]

  Ruby::MethodCall.new(
    :receiver => Ruby::Variable.new(:name => "Yast"),
    :name     => "include",
    :args     => args,
    :block    => nil,
    :parens   => false
  )
end