class Scribble::Nodes::Call

Attributes

allow_variable[R]
args[R]
name[R]
nodes[RW]
receiver[RW]

Public Class Methods

new(slice, name, args: [], receiver: nil, allow_variable: false) click to toggle source
Calls superclass method
# File lib/scribble/nodes/call.rb, line 8
def initialize slice, name, args: [], receiver: nil, allow_variable: false
  super slice
  @name, @args, @receiver, @allow_variable = name, args, receiver, allow_variable
end

Public Instance Methods

block?() click to toggle source
# File lib/scribble/nodes/call.rb, line 28
def block?
  Registry.block? name
end
evaluate(context, allow_block: true, allow_split: false) click to toggle source
# File lib/scribble/nodes/call.rb, line 13
def evaluate context, allow_block: true, allow_split: false
  disallow_split unless allow_split
  disallow_block unless allow_block

  if @receiver
    Registry.evaluate @name, evaluated_receiver(context), evaluated_args(context), self, context
  else
    context.evaluate self, evaluated_args(context), context
  end
rescue Errors::UnlocatedArgument => e
  raise Errors::Argument.new("#{e.message} #{line_and_column}")
rescue Support::Unmatched => e
  raise e.to_error self
end
split?() click to toggle source
# File lib/scribble/nodes/call.rb, line 32
def split?
  Registry.split? name
end

Private Instance Methods

disallow_block() click to toggle source
# File lib/scribble/nodes/call.rb, line 42
def disallow_block
  raise Errors::Syntax.new "Unexpected '#{name}' #{line_and_column}; block methods can't be arguments" if block?
end
disallow_split() click to toggle source
# File lib/scribble/nodes/call.rb, line 38
def disallow_split
  raise Errors::Syntax.new "Unexpected '#{name}' #{line_and_column}" if split?
end
evaluated_args(context) click to toggle source
# File lib/scribble/nodes/call.rb, line 50
def evaluated_args context
  @evaluated_args ||= args.map { |arg| arg.evaluate context, allow_block: false }
end
evaluated_receiver(context) click to toggle source
# File lib/scribble/nodes/call.rb, line 46
def evaluated_receiver context
  @evaluated_receiver ||= @receiver.evaluate context, allow_block: false
end