Class: Riml::Compiler::CallNodeVisitor

Inherits:
ScopedVisitor show all
Defined in:
lib/riml/compiler.rb

Instance Method Summary collapse

Methods inherited from Visitor

#initialize, #visit

Constructor Details

This class inherits a constructor from Riml::Compiler::Visitor

Instance Method Details

#compile(node) ⇒ Object



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/riml/compiler.rb', line 544

def compile(node)
  set_modifier(node) if node.name && !node.builtin_function?
  node.compiled_output =
    if node.name.respond_to?(:variable)
      node.name.accept(visitor_for_node(node.name))
      node.scope_modifier + node.name.compiled_output
    elsif DictGetDotNode === node.name
      node.name.accept(visitor_for_node(node.name))
      node.name.compiled_output
    else
      node.full_name
    end
  compile_arguments(node)
  node.compiled_output
end

#compile_arguments(node) ⇒ Object



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/riml/compiler.rb', line 560

def compile_arguments(node)
  builtin_cmd = node.builtin_command?
  node.compiled_output << if builtin_cmd
    if node.arguments.any? then ' ' else '' end
  else
    '('
  end
  node.arguments.each_with_index do |arg, i|
    arg.parent_node = node
    arg_visitor = visitor_for_node(arg)
    arg.accept(arg_visitor)
    node.compiled_output << ", " unless last_arg?(node.arguments, i)
  end
  node.compiled_output << ")" unless builtin_cmd
  node_p = node.parent
  if node_p.force_newline_if_child_call_node?
    node.force_newline = true
  end
end