Class: Y2R::AST::YCP::Import

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



1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
# File 'lib/y2r/ast/ycp.rb', line 1411

def compile(context)
  # Using any SCR or WFM function results in an auto-import. We ignore
  # these auto-imports becasue neither SCR nor WFM are real modules.
  return nil if name == "SCR" || name == "WFM"

  Ruby::MethodCall.new(
    :receiver => Ruby::Variable.new(:name => "Yast"),
    :name     => "import",
    :args     => [Ruby::Literal.new(:value => name)],
    :block    => nil,
    :parens   => false
  )
end