Package org.armedbear.lisp
Class ArgumentListProcessor
java.lang.Object
org.armedbear.lisp.ArgumentListProcessor
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class used to represent optional parameters and their initformsstatic enum
static class
Class used to match optional parameters, or, if not provided, evaluate the initform.static class
Abstract parent of the classes used to represent the different argument types: - EnvironmentParam - RequiredParam - OptionalParam - RestParam - KeywordParam - AuxParamstatic class
Class used to match required parameters -
Constructor Summary
ConstructorsConstructorDescriptionArgumentListProcessor
(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.ArgumentListProcessor
(Operator fun, LispObject lambdaList, LispObject specials, ArgumentListProcessor.LambdaListType type) Instantiates an ArgumentListProcessor by parsing the lambda list specified in 'lambdaList'. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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'.Symbol[]
freeSpecials
(LispObject specials) int
getArity()
int
int
Symbol[]
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.void
setFunction
(Operator fun)
-
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 onoptional
- The list of optional argumentskeyword
- The list of keyword parameterskey
- Indicates whether invalid input: '&key' was specified (optionally without naming keys)moreKeys
- Indicates whether invalid input: '&allow'-other-keys was specifiedrest
- Specifies the invalid input: '&rest' variable name, if one was specified, or 'null' if nonerequired
- 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 errorslambdaList
- Lambda list to parse and use for function callspecials
- A list of symbols specifying which variables to bind as specials during initform evaluation
-
-
Method Details
-
setFunction
-
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' variableenv
- Environment to evaluate initforms inthread
- 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
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 boundenv
-thread
-
-
freeSpecials
-
getArity
public int getArity() -
getMinArgs
public int getMinArgs() -
getMaxArgs
public int getMaxArgs() -
getVariables
-