Class ArgumentListProcessor

  • All Implemented Interfaces:
    java.io.Serializable

    public class ArgumentListProcessor
    extends java.lang.Object
    implements java.io.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:
    Serialized Form
    • Constructor Detail

      • 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 &optional, &key and &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
        required - The list of required arguments
        optional - The list of optional arguments
        keyword - The list of keyword parameters
        key - Indicates whether &key was specified (optionally without naming keys)
        moreKeys - Indicates whether &allow-other-keys was specified
        rest - Specifies the &rest variable name, if one was specified, or 'null' if none
      • 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 Detail

      • 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 &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 -
      • getArity

        public int getArity()
      • getMinArgs

        public int getMinArgs()
      • getMaxArgs

        public int getMaxArgs()
      • getVariables

        public Symbol[] getVariables()