public abstract class SimpleFunction extends AbstractFunction
Function
implementation for when the parameters are all normal expressions.Modifier and Type | Field and Description |
---|---|
protected int |
maxArgs |
protected int |
minArgs |
log, name, spaceParser
Modifier | Constructor and Description |
---|---|
protected |
SimpleFunction(String name,
int minArgs,
int maxArgs)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Value |
apply(ParseSession session,
Object info)
Evaluate this function.
|
protected abstract Value |
apply(ParseSession session,
Value[] params)
Apply this function to the given values.
|
int |
getMaxArgs()
Get the maximum number of arguments allowed (inclusive).
|
int |
getMinArgs()
Get the minimum number of arguments allowed (inclusive).
|
Node[] |
parseParams(ParseSession session,
ParseContext ctx,
boolean complete)
Parse function parameters.
|
getHelpDetail, getName, getSessionModes, parseExpressionParams, parseNextParameter
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHelpSummary, getUsage
protected SimpleFunction(String name, int minArgs, int maxArgs)
name
- function nameminArgs
- minimum number of arguments (inclusive)maxArgs
- maximum number of arguments (inclusive)public int getMinArgs()
public int getMaxArgs()
public final Node[] parseParams(ParseSession session, ParseContext ctx, boolean complete)
Function
The ctx
will be pointing at the first parameter (if any) or closing parenthesis. This method should parse
(but not evaluate) function parameters up through the closing parenthesis. The return value is an opaque value
representing the parsed parameters and subsequently passed to apply()
.
session
- parse sessionctx
- parse contextcomplete
- false if parse is "for real", true if only for tab completion calculationapply()
public final Value apply(ParseSession session, Object info)
Function
session
- parse sessioninfo
- parsed parameters returned by parseParams()
protected abstract Value apply(ParseSession session, Value[] params)
session
- parse sessionparams
- parsed parameters; will already be checked between getMinArgs()
and getMaxArgs()
RuntimeException
- if there is an errorCopyright © 2022. All rights reserved.