Class ArgumentListProcessor

java.lang.Object
org.armedbear.lisp.ArgumentListProcessor
All Implemented Interfaces:
Serializable

public class ArgumentListProcessor extends Object implements Serializable
A class to parse a lambda list and match function call arguments with it. The lambda list may either be of type ORDINARY or MACRO lambda list. All other lambda lists are parsed elsewhere in our code base.
See Also:
  • Constructor Details

    • ArgumentListProcessor

      public ArgumentListProcessor(Operator fun, int requiredCount, ArgumentListProcessor.OptionalParam[] optional, ArgumentListProcessor.KeywordParam[] keyword, boolean key, boolean moreKeys, Symbol rest)
      Constructor to be used from compiled code The compiler hands in pre-parsed lambda lists. The process of matching function call arguments with lambda lists which are constructed this way don't support non-constant initforms for invalid input: '&optional', invalid input: '&key' and invalid input: '&aux' parameters. As a result, there's no need to create an evaluation environment which in turn eliminates the need to know which variables are special.
      Parameters:
      fun - The function to report function call argument matching errors on
      optional - The list of optional arguments
      keyword - The list of keyword parameters
      key - Indicates whether invalid input: '&key' was specified (optionally without naming keys)
      moreKeys - Indicates whether invalid input: '&allow'-other-keys was specified
      rest - Specifies the invalid input: '&rest' variable name, if one was specified, or 'null' if none
      required - The list of required arguments
    • ArgumentListProcessor

      public ArgumentListProcessor(Operator fun, LispObject lambdaList, LispObject specials, ArgumentListProcessor.LambdaListType type)
      Instantiates an ArgumentListProcessor by parsing the lambda list specified in 'lambdaList'. This constructor sets up the object to support evaluation of non-constant initforms.
      Parameters:
      fun - Function to use when reporting errors
      lambdaList - Lambda list to parse and use for function call
      specials - A list of symbols specifying which variables to bind as specials during initform evaluation
  • Method Details

    • setFunction

      public void setFunction(Operator fun)
    • match

      public LispObject[] match(LispObject[] args, Environment _environment, Environment env, LispThread thread)
      Matches the function call arguments 'args' with the lambda list, returning an array with variable values to be used. The array is sorted the same way as the variables returned by the 'extractVariables' function.
      Parameters:
      args - Funcion call arguments to be matched
      _environment - Environment to be used for the invalid input: '&environment' variable
      env - Environment to evaluate initforms in
      thread - Thread to be used for binding special variables -- must be LispThread.currentThread()
      Returns:
      An array of LispObjects corresponding to the values to be bound to the variables in the lambda list
    • bindVars

      public void bindVars(LispObject[] values, Environment env, LispThread thread)
      Binds the variable values returned from 'match' to their corresponding variables in the environment 'env', with specials bound in thread 'thread'.
      Parameters:
      values - Values to be bound
      env -
      thread -
    • freeSpecials

      public Symbol[] freeSpecials(LispObject specials)
    • getArity

      public int getArity()
    • getMinArgs

      public int getMinArgs()
    • getMaxArgs

      public int getMaxArgs()
    • getVariables

      public Symbol[] getVariables()