gnu.expr
Class ApplyExp
java.lang.Object
gnu.mapping.PropertySet
gnu.mapping.Procedure
gnu.mapping.Procedure0
gnu.expr.Expression
gnu.expr.ApplyExp
- All Implemented Interfaces:
- Named, Printable, javax.xml.transform.SourceLocator, org.xml.sax.Locator
public class ApplyExp
- extends Expression
This class is used to represent "combination" or "application".
A function and arguments are evaluated, and then the function applied.
Methods inherited from class gnu.expr.Expression |
apply0, compile, compile, compileButFirst, compileNotePosition, compileWithPosition, compileWithPosition, eval, eval, getColumnNumber, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getSystemId, inline, isStableSourceLocation, makeWhile, match0, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLocation, side_effects, valueIfConstant |
Methods inherited from class gnu.mapping.Procedure |
apply, check0, check1, check2, check3, check4, checkArgCount, checkN, getSetter, getSourceLocation, match1, match2, match3, match4, matchN, maxArgs, minArgs, set0, set1, setN, setSetter, setSourceLocation |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
TAILCALL
public static final int TAILCALL
- See Also:
- Constant Field Values
INLINE_IF_CONSTANT
public static final int INLINE_IF_CONSTANT
- See Also:
- Constant Field Values
nextCall
public ApplyExp nextCall
- The next ApplyExp in ((ReferenceExp)func).binding.firstCall list.
type
protected Type type
- Cache for getType().
ApplyExp
public ApplyExp(Expression f,
Expression[] a)
ApplyExp
public ApplyExp(Procedure p,
Expression[] a)
ApplyExp
public ApplyExp(Method m,
Expression[] a)
getFunction
public final Expression getFunction()
getArgs
public final Expression[] getArgs()
getArgCount
public final int getArgCount()
setFunction
public void setFunction(Expression func)
setArgs
public void setArgs(Expression[] args)
getArg
public Expression getArg(int i)
setArg
public void setArg(int i,
Expression arg)
isTailCall
public final boolean isTailCall()
setTailCall
public final void setTailCall(boolean tailCall)
getFunctionValue
public final java.lang.Object getFunctionValue()
- If getFunction() is constant, return its value; otherwise null.
mustCompile
protected boolean mustCompile()
- Specified by:
mustCompile
in class Expression
apply
public void apply(CallContext ctx)
throws java.lang.Throwable
- 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 class Expression
- Throws:
java.lang.Throwable
compileToArray
public static void compileToArray(Expression[] args,
Compilation comp)
compile
public void compile(Compilation comp,
Target target)
- Specified by:
compile
in class Expression
compile
public static void compile(ApplyExp exp,
Compilation comp,
Target target)
walk
protected Expression walk(ExpWalker walker)
- Overrides:
walk
in class Expression
walkArgs
public void walkArgs(ExpWalker walker)
walkArgs
public void walkArgs(ExpWalker walker,
boolean argsInlined)
walkChildren
protected void walkChildren(ExpWalker walker)
- Overrides:
walkChildren
in class Expression
print
public void print(OutPort out)
- Specified by:
print
in class Expression
getTypeRaw
public final Type getTypeRaw()
setType
public final void setType(Type type)
getType
public final Type getType()
- Description copied from class:
Expression
- Return the Type used to represent the values of this Expression.
- Overrides:
getType
in class Expression
inlineIfConstant
public final Expression inlineIfConstant(Procedure proc,
ExpWalker walker)
inlineIfConstant
public final Expression inlineIfConstant(Procedure proc,
SourceMessages messages)
- 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
public java.lang.String toString()
- Overrides:
toString
in class Expression