Class: Riml::CallNode

Inherits:
Struct
  • Object
show all
Includes:
Constants, FullyNameable, Visitable, Walkable
Defined in:
lib/nodes.rb

Overview

Node of a method call, can take any of these forms:

Method()
s:Method(argument1, argument2)

Direct Known Subclasses

ExplicitCallNode, RimlCommandNode

Constant Summary collapse

ALL_BUILTIN_FUNCTIONS =
BUILTIN_FUNCTIONS + BUILTIN_COMMANDS
ALL_BUILTIN_COMMANDS =
BUILTIN_COMMANDS  + RIML_COMMANDS + VIML_COMMANDS

Constants included from Visitable

Visitable::DESCENDANT_OF_REGEX

Constants included from Constants

Riml::Constants::BUILTIN_COMMANDS, Riml::Constants::BUILTIN_FUNCTIONS, Riml::Constants::COMPARISON_OPERATORS, Riml::Constants::DEFINE_KEYWORDS, Riml::Constants::END_KEYWORDS, Riml::Constants::IGNORECASE_CAPABLE_OPERATORS, Riml::Constants::KEYWORDS, Riml::Constants::REGISTERS, Riml::Constants::RIML_COMMANDS, Riml::Constants::RIML_END_KEYWORDS, Riml::Constants::RIML_KEYWORDS, Riml::Constants::SPECIAL_VARIABLE_PREFIXES, Riml::Constants::SPLAT_LITERAL, Riml::Constants::VIML_COMMANDS, Riml::Constants::VIML_END_KEYWORDS, Riml::Constants::VIML_KEYWORDS

Instance Attribute Summary collapse

Attributes included from Visitable

#compiled_output, #force_newline, #parent_node, #scope

Instance Method Summary collapse

Methods included from Walkable

#child_after, #child_previous_to, #each, #index_by_children, #index_by_member, #insert_after, #insert_before, #next, #previous, #remove, #replace_with

Methods included from FullyNameable

#full_name, included

Methods included from Visitable

#accept, #method_missing, #respond_to?

Constructor Details

#initialize(scope_modifier, name, arguments) ⇒ CallNode

Returns a new instance of CallNode.



342
343
344
345
# File 'lib/nodes.rb', line 342

def initialize(scope_modifier, name, arguments)
  super
  remove_parens_wrapper if builtin_command?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Riml::Visitable

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments

Returns:

  • (Object)

    the current value of arguments



333
334
335
# File 'lib/nodes.rb', line 333

def arguments
  @arguments
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



333
334
335
# File 'lib/nodes.rb', line 333

def name
  @name
end

#scope_modifierObject

Returns the value of attribute scope_modifier

Returns:

  • (Object)

    the current value of scope_modifier



333
334
335
# File 'lib/nodes.rb', line 333

def scope_modifier
  @scope_modifier
end

Instance Method Details

#autoload?Boolean

Returns:

  • (Boolean)


369
370
371
# File 'lib/nodes.rb', line 369

def autoload?
  name.include?('#')
end

#builtin_command?Boolean

Returns:

  • (Boolean)


358
359
360
361
# File 'lib/nodes.rb', line 358

def builtin_command?
  return false unless name.is_a?(String)
  scope_modifier.nil? and ALL_BUILTIN_COMMANDS.include?(name)
end

#builtin_function?Boolean

Returns:

  • (Boolean)


353
354
355
356
# File 'lib/nodes.rb', line 353

def builtin_function?
  return false unless name.is_a?(String)
  scope_modifier.nil? and ALL_BUILTIN_FUNCTIONS.include?(name)
end

#childrenObject



373
374
375
376
377
378
379
# File 'lib/nodes.rb', line 373

def children
  if name.is_a?(String)
    arguments
  else
    [name] + arguments
  end
end

#must_be_explicit_call?Boolean

Returns:

  • (Boolean)


363
364
365
366
367
# File 'lib/nodes.rb', line 363

def must_be_explicit_call?
  return false if builtin_command?
  return true  if parent.instance_of?(Nodes)
  false
end

#remove_parens_wrapperObject

TODO: find way to remove this hack



348
349
350
351
# File 'lib/nodes.rb', line 348

def remove_parens_wrapper
  return unless WrapInParensNode === arguments.first
  arguments[0] = arguments[0].expression
end