gnu.expr
Class ApplyExp

java.lang.Object
  extended by gnu.mapping.Procedure
      extended by gnu.mapping.Procedure0
          extended by gnu.expr.Expression
              extended by gnu.expr.ApplyExp
All Implemented Interfaces:
Named, Printable

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.


Field Summary
static int INLINE_IF_CONSTANT
           
 ApplyExp nextCall
          The next ApplyExp in ((ReferenceExp)func).binding.firstCall list.
static int TAILCALL
           
protected  Type type
          Cache for getType().
 
Fields inherited from class gnu.expr.Expression
flags, NEXT_AVAIL_FLAG, noExpressions
 
Constructor Summary
ApplyExp(Expression f, Expression[] a)
           
ApplyExp(Method m, Expression[] a)
           
ApplyExp(Procedure p, Expression[] a)
           
 
Method Summary
 void apply(CallContext ctx)
          Call this Procedure using the explicit-CallContext-convention.
static void compile(ApplyExp exp, Compilation comp, Target target)
           
 void compile(Compilation comp, Target target)
           
static void compileToArray(Expression[] args, Compilation comp)
           
 java.lang.Object eval(Environment env)
           
 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.
 Expression inlineIfConstant(Procedure proc, ExpWalker walker)
           
 Expression inlineIfConstant(Procedure proc, SourceMessages messages)
          Inline this ApplyExp if parameters are constant.
 boolean isTailCall()
           
 void print(OutPort out)
           
 void setArgs(Expression[] args)
           
 void setFunction(Expression func)
           
 void setTailCall(boolean tailCall)
           
protected  Expression walk(ExpWalker walker)
           
protected  void walkChildren(ExpWalker walker)
           
 
Methods inherited from class gnu.expr.Expression
apply0, compile, compileButFirst, compileNotePosition, compileWithPosition, compileWithPosition, eval, getColumn, getFile, getFlag, getFlags, getLine, makeWhile, match0, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine
 
Methods inherited from class gnu.mapping.Procedure0
apply1, apply2, apply3, apply4, applyN, numArgs
 
Methods inherited from class gnu.mapping.Procedure
apply, check0, check1, check2, check3, check4, checkArgCount, checkN, getName, getProperty, getSetter, getSymbol, match1, match2, match3, match4, matchN, maxArgs, minArgs, name, removeProperty, set0, set1, setN, setName, setProperty, setProperty, setSetter, setSymbol, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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().

Constructor Detail

ApplyExp

public ApplyExp(Expression f,
                Expression[] a)

ApplyExp

public ApplyExp(Procedure p,
                Expression[] a)

ApplyExp

public ApplyExp(Method m,
                Expression[] a)
Method Detail

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)

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.


eval

public java.lang.Object eval(Environment env)
                      throws java.lang.Throwable
Overrides:
eval in class Expression
Throws:
java.lang.Throwable

apply

public void apply(CallContext ctx)
           throws java.lang.Throwable
Description copied from class: Procedure
Call this Procedure using the explicit-CallContext-convention. The input arguments are (by default) in stack.args; the result is written to ctx.consumer.

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

walkChildren

protected void walkChildren(ExpWalker walker)
Overrides:
walkChildren in class Expression

print

public void print(OutPort out)
Specified by:
print 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

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.