Class: Riml::CallNode

Inherits:
Struct
  • Object
show all
Includes:
Constants, FullyNameable, Visitable
Defined in:
lib/riml/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::EMPTY_CHILDREN

Constants included from Constants

Riml::Constants::BUILTIN_COMMANDS, Riml::Constants::BUILTIN_FUNCTIONS, Riml::Constants::COMPARISON_OPERATORS, Riml::Constants::COMPILED_STRING_LOCATION, Riml::Constants::DEFINE_KEYWORDS, Riml::Constants::END_KEYWORDS, Riml::Constants::IGNORECASE_CAPABLE_OPERATORS, Riml::Constants::KEYWORDS, Riml::Constants::REGISTERS, Riml::Constants::RIML_CLASS_COMMANDS, Riml::Constants::RIML_COMMANDS, Riml::Constants::RIML_END_KEYWORDS, Riml::Constants::RIML_FILE_COMMANDS, Riml::Constants::RIML_KEYWORDS, Riml::Constants::SPECIAL_VARIABLE_PREFIXES, Riml::Constants::SPLAT_LITERAL, Riml::Constants::UNKNOWN_LOCATION_INFO, 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, #parser_info, #scope

Instance Method Summary collapse

Methods included from FullyNameable

#full_name, included

Methods included from Visitable

#accept, #location_info

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

Constructor Details

#initialize(scope_modifier, name, arguments) ⇒ CallNode

Returns a new instance of CallNode.



270
271
272
273
# File 'lib/riml/nodes.rb', line 270

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

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments

Returns:

  • (Object)

    the current value of arguments



260
261
262
# File 'lib/riml/nodes.rb', line 260

def arguments
  @arguments
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



260
261
262
# File 'lib/riml/nodes.rb', line 260

def name
  @name
end

#scope_modifierObject

Returns the value of attribute scope_modifier

Returns:

  • (Object)

    the current value of scope_modifier



260
261
262
# File 'lib/riml/nodes.rb', line 260

def scope_modifier
  @scope_modifier
end

#super_callObject Also known as: super_call?

Returns the value of attribute super_call.



265
266
267
# File 'lib/riml/nodes.rb', line 265

def super_call
  @super_call
end

Instance Method Details

#autoload?Boolean

Returns:

  • (Boolean)


304
305
306
# File 'lib/riml/nodes.rb', line 304

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

#builtin_command?Boolean

Returns:

  • (Boolean)


285
286
287
288
# File 'lib/riml/nodes.rb', line 285

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)


280
281
282
283
# File 'lib/riml/nodes.rb', line 280

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

#childrenObject



312
313
314
315
316
317
318
# File 'lib/riml/nodes.rb', line 312

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

#force_newline_if_child_call_node?Boolean

Returns:

  • (Boolean)


308
309
310
# File 'lib/riml/nodes.rb', line 308

def force_newline_if_child_call_node?
  false
end

#method_call?Boolean

Returns:

  • (Boolean)


296
297
298
299
300
# File 'lib/riml/nodes.rb', line 296

def method_call?
  name.instance_of?(DictGetDotNode) &&
    name.dict.name == 'self' &&
    name.dict.scope_modifier.nil?
end

#must_be_explicit_call?Boolean

Returns:

  • (Boolean)


290
291
292
293
294
# File 'lib/riml/nodes.rb', line 290

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

#remove_parens_wrapperObject



275
276
277
278
# File 'lib/riml/nodes.rb', line 275

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