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.
Method Summary |
void |
apply(CallContext ctx)
Evaluate the expression. |
static Inlineable |
asInlineable(Procedure proc)
|
static void |
compile(ApplyExp exp,
Compilation comp,
Target target)
|
void |
compile(Compilation comp,
Target target)
|
static void |
compileToArray(Expression[] args,
Compilation comp)
|
Expression |
deepCopy(IdentityHashTable mapper)
|
Expression |
getArg(int i)
|
int |
getArgCount()
|
Expression[] |
getArgs()
|
Expression |
getFunction()
|
java.lang.Object |
getFunctionValue()
If getFunction() is constant, return its value; otherwise null. |
Type |
getType()
Return the Type used to represent the values of this Expression. |
Type |
getTypeRaw()
|
Expression |
inlineIfConstant(Procedure proc,
InlineCalls visitor)
|
Expression |
inlineIfConstant(Procedure proc,
SourceMessages messages)
Inline this ApplyExp if parameters are constant. |
boolean |
isTailCall()
|
protected boolean |
mustCompile()
|
void |
print(OutPort out)
|
void |
setArg(int i,
Expression arg)
|
void |
setArgs(Expression[] args)
|
void |
setFunction(Expression func)
|
void |
setTailCall(boolean tailCall)
|
void |
setType(Type type)
|
boolean |
side_effects()
True if evaluating may have side-effects. |
java.lang.String |
toString()
|
protected
|
visit(ExpVisitor<R,D> visitor,
D d)
|
void |
visitArgs(InlineCalls visitor)
|
protected
|
visitChildren(ExpVisitor<R,D> visitor,
D d)
|
Methods inherited from class gnu.expr.Expression |
apply0, compile, compile, compileButFirst, compileNotePosition, compileWithPosition, compileWithPosition, deepCopy, deepCopy, deepCopy, eval, eval, getColumnNumber, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getSystemId, isSingleValue, isStableSourceLocation, makeWhile, match0, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLocation, validateApply, valueIfConstant |
Methods inherited from class gnu.mapping.Procedure |
apply, check0, check1, check2, check3, check4, checkArgCount, checkN, getReturnType, getSetter, getSourceLocation, isSideEffectFree, match1, match2, match3, match4, matchN, maxArgs, maxArgs, minArgs, 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
MAY_CONTAIN_BACK_JUMP
public static final int MAY_CONTAIN_BACK_JUMP
- 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)
deepCopy
public Expression deepCopy(IdentityHashTable mapper)
- Overrides:
deepCopy
in class Expression
visit
protected <R,D> R visit(ExpVisitor<R,D> visitor,
D d)
- Overrides:
visit
in class Expression
visitArgs
public void visitArgs(InlineCalls visitor)
visitChildren
protected <R,D> void visitChildren(ExpVisitor<R,D> visitor,
D d)
- Overrides:
visitChildren
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)
side_effects
public boolean side_effects()
- Description copied from class:
Expression
- True if evaluating may have side-effects.
- Overrides:
side_effects
in class Expression
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
asInlineable
public static Inlineable asInlineable(Procedure proc)
inlineIfConstant
public final Expression inlineIfConstant(Procedure proc,
InlineCalls visitor)
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