Package gnu.expr
Class ApplyExp
java.lang.Object
gnu.mapping.PropertySet
gnu.mapping.Procedure
gnu.expr.Expression
gnu.expr.ApplyExp
- All Implemented Interfaces:
gnu.kawa.format.Printable
,Named
,SourceLocator
,SourceLocator
,Locator
- Direct Known Subclasses:
CurryExp
This class is used to represent "combination" or "application".
A function and arguments are evaluated, and then the function applied.
-
Nested Class Summary
Nested classes/interfaces inherited from interface gnu.text.SourceLocator
SourceLocator.Simple
-
Field Summary
FieldsModifier and TypeFieldDescriptionint
Index of argument for first keyword argument.int
Index of first argument that is a MakeSplice.static final int
static final int
static final int
The next ApplyExp in ((ReferenceExp)func).binding.firstCall list.int
static final int
Fields inherited from class gnu.expr.Expression
applyMethodExpression, flags, NEXT_AVAIL_FLAG, noExpressions, type, VALIDATED
Fields inherited from class gnu.mapping.Procedure
applyMethodType, applyToConsumerDefault, applyToConsumerMethod, applyToObjectDefault, applyToObjectMethod, compilerKey, compilerXKey, inlineIfConstantSymbol, validateApplyKey, validateXApplyKey
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
Constructor Summary
ConstructorsConstructorDescriptionApplyExp
(Method m, Expression... a) ApplyExp
(Expression f, Expression... a) ApplyExp
(Procedure p, Expression... a) -
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustSplice
(ApplyExp src, int delta) Copy over splice and keyword start indexes.void
apply
(CallContext ctx) Evaluate the expression.protected Type
static void
compile
(ApplyExp exp, Compilation comp, Target target) void
compile
(Compilation comp, Target target) static void
compileArgsToContext
(ApplyExp exp, Method setupMethod, Compilation comp) deepCopy
(IdentityHashTable mapper) getArg
(int i) final int
final Expression[]
getArgs()
final Expression
final Object
If getFunction() is constant, return its value; otherwise null.boolean
final Expression
inlineIfConstant
(Procedure proc, InlineCalls visitor) final Expression
inlineIfConstant
(Procedure proc, SourceMessages messages) Inline this ApplyExp if parameters are constant.boolean
static boolean
isInlineable
(Procedure proc) boolean
isSimple()
boolean
isSimple
(int min) boolean
isSimple
(int min, int max) final boolean
protected boolean
void
print
(gnu.kawa.io.OutPort out) void
setArg
(int i, Expression arg) void
setArgs
(Expression[] args) setFuncArgs
(Expression func, Expression[] args) setFuncArgs
(Procedure proc, Expression[] args) void
setFunction
(Expression func) void
setFunction
(Procedure proc) final void
setTailCall
(boolean tailCall) boolean
True if evaluating may have side-effects.int
toString()
protected <R,
D> R visit
(ExpVisitor<R, D> visitor, D d) void
visitArgs
(InlineCalls visitor) void
visitArgs
(InlineCalls visitor, LambdaExp lexp) protected <R,
D> void visitChildren
(ExpVisitor<R, D> visitor, D d) Methods inherited from class gnu.expr.Expression
applyMethodExpression, checkLiteralKeyword, compile, compile, compileWithPosition, compileWithPosition, deepCopy, deepCopy, deepCopy, eval, eval, getColumnNumber, getEndColumn, getEndLine, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getStartColumn, getStartLine, getSystemId, getType, getTypeRaw, isSingleValue, isStableSourceLocation, makeWhile, maybeSetLine, neverReturns, numArgs, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLine, setLocation, setType, validateApply, valueIfConstant
Methods inherited from class gnu.mapping.Procedure
apply0, apply1, apply2, apply3, apply4, applyL, applyN, applyToConsumerDefault, applyToObjectDefault, checkArgCount, checkBadCode, getApplyMethod, getApplyToConsumerMethod, getApplyToObjectMethod, getReturnType, getSetter, getSourceLocation, isSideEffectFree, lookupApplyHandle, maxArgs, maxArgs, minArgs, minArgs, set0, set1, setN, setSetter, setSourceLocation
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
Field Details
-
TAILCALL
public static final int TAILCALL- See Also:
-
INLINE_IF_CONSTANT
public static final int INLINE_IF_CONSTANT- See Also:
-
MAY_CONTAIN_BACK_JUMP
public static final int MAY_CONTAIN_BACK_JUMP- See Also:
-
IS_SUPER_INIT
public static final int IS_SUPER_INIT- See Also:
-
nextCall
The next ApplyExp in ((ReferenceExp)func).binding.firstCall list. -
firstKeywordArgIndex
public int firstKeywordArgIndexIndex of argument for first keyword argument. If zero, no keyword arguments. If non-zero, thenfirstKeywordArgIndex-1
is the index in theargs
array of the first keyword. -
numKeywordArgs
public int numKeywordArgs -
firstSpliceArg
public int firstSpliceArgIndex of first argument that is a MakeSplice. The value is -1 is no argument is a splice.
-
-
Constructor Details
-
ApplyExp
-
ApplyExp
-
ApplyExp
-
-
Method Details
-
getFunction
-
getArgs
-
getArgCount
public final int getArgCount() -
setFunction
-
setFunction
-
setArgs
-
getArg
-
setArg
-
isTailCall
public final boolean isTailCall() -
setTailCall
public final void setTailCall(boolean tailCall) -
setFuncArgs
-
setFuncArgs
-
getFunctionValue
If getFunction() is constant, return its value; otherwise null. -
adjustSplice
Copy over splice and keyword start indexes.- Parameters:
src
- orginal ApplyExp (may be the same as this)delta
- amount to adjust indexes by
-
spliceCount
public int spliceCount() -
isSimple
public boolean isSimple() -
isSimple
public boolean isSimple(int min) -
isSimple
public boolean isSimple(int min, int max) -
hasSpliceAllowingKeywords
public boolean hasSpliceAllowingKeywords() -
isAppendValues
public boolean isAppendValues() -
mustCompile
protected boolean mustCompile()- Specified by:
mustCompile
in classExpression
-
apply
Description copied from class:Expression
Evaluate the expression. This is named apply rather than eval so it is compatible with the full-tail-call calling convention, and we can stash an Expression in CallContext's proc field. FIXME - are we making use of this?- Overrides:
apply
in classExpression
- Throws:
Throwable
-
compile
- Specified by:
compile
in classExpression
-
compile
-
compileArgsToContext
-
deepCopy
- Overrides:
deepCopy
in classExpression
-
visit
- Overrides:
visit
in classExpression
-
visitArgs
-
visitArgs
-
visitChildren
- Overrides:
visitChildren
in classExpression
-
print
public void print(gnu.kawa.io.OutPort out) - Specified by:
print
in classExpression
-
side_effects
public boolean side_effects()Description copied from class:Expression
True if evaluating may have side-effects.- Overrides:
side_effects
in classExpression
-
calculateType
- Overrides:
calculateType
in classExpression
-
isInlineable
-
inlineIfConstant
-
inlineIfConstant
Inline this ApplyExp if parameters are constant.- Parameters:
proc
- the procedure bound to this.func.- Returns:
- the constant result (as a QuoteExp) if inlining was possible; otherwise this ApplyExp. If applying proc throws an exception, print a warning on walker.messages.
-
toString
- Overrides:
toString
in classExpression
-