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 TypeFieldDescriptionintIndex of argument for first keyword argument.intIndex of first argument that is a MakeSplice.static final intstatic final intstatic final intThe next ApplyExp in ((ReferenceExp)func).binding.firstCall list.intstatic final intFields inherited from class gnu.expr.Expression
applyMethodExpression, flags, NEXT_AVAIL_FLAG, noExpressions, type, VALIDATEDFields inherited from class gnu.mapping.Procedure
applyMethodType, applyToConsumerDefault, applyToConsumerMethod, applyToObjectDefault, applyToObjectMethod, compilerKey, compilerXKey, inlineIfConstantSymbol, validateApplyKey, validateXApplyKeyFields 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 TypeMethodDescriptionvoidadjustSplice(ApplyExp src, int delta) Copy over splice and keyword start indexes.voidapply(CallContext ctx) Evaluate the expression.protected Typestatic voidcompile(ApplyExp exp, Compilation comp, Target target) voidcompile(Compilation comp, Target target) static voidcompileArgsToContext(ApplyExp exp, Method setupMethod, Compilation comp) deepCopy(IdentityHashTable mapper) getArg(int i) final intfinal Expression[]getArgs()final Expressionfinal ObjectIf getFunction() is constant, return its value; otherwise null.booleanfinal ExpressioninlineIfConstant(Procedure proc, InlineCalls visitor) final ExpressioninlineIfConstant(Procedure proc, SourceMessages messages) Inline this ApplyExp if parameters are constant.booleanstatic booleanisInlineable(Procedure proc) booleanisSimple()booleanisSimple(int min) booleanisSimple(int min, int max) final booleanprotected booleanvoidprint(gnu.kawa.io.OutPort out) voidsetArg(int i, Expression arg) voidsetArgs(Expression[] args) setFuncArgs(Expression func, Expression[] args) setFuncArgs(Procedure proc, Expression[] args) voidsetFunction(Expression func) voidsetFunction(Procedure proc) final voidsetTailCall(boolean tailCall) booleanTrue if evaluating may have side-effects.inttoString()protected <R,D> R visit(ExpVisitor<R, D> visitor, D d) voidvisitArgs(InlineCalls visitor) voidvisitArgs(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, valueIfConstantMethods 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, setSourceLocationMethods 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-1is the index in theargsarray 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:
mustCompilein classExpression
-
apply
Description copied from class:ExpressionEvaluate 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:
applyin classExpression- Throws:
Throwable
-
compile
- Specified by:
compilein classExpression
-
compile
-
compileArgsToContext
-
deepCopy
- Overrides:
deepCopyin classExpression
-
visit
- Overrides:
visitin classExpression
-
visitArgs
-
visitArgs
-
visitChildren
- Overrides:
visitChildrenin classExpression
-
print
public void print(gnu.kawa.io.OutPort out) - Specified by:
printin classExpression
-
side_effects
public boolean side_effects()Description copied from class:ExpressionTrue if evaluating may have side-effects.- Overrides:
side_effectsin classExpression
-
calculateType
- Overrides:
calculateTypein 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:
toStringin classExpression
-