gnu.expr
Class ApplyExp

java.lang.Object
  extended by gnu.mapping.PropertySet
      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, 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.


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)
          Evaluate the expression.
static void compile(ApplyExp exp, Compilation comp, Target target)
           
 void compile(Compilation comp, Target target)
           
static void compileToArray(Expression[] args, Compilation comp)
           
 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, ExpWalker walker)
           
 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)
           
 java.lang.String toString()
           
protected  Expression walk(ExpWalker walker)
           
protected  void walkChildren(ExpWalker walker)
           
 
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.Procedure0
apply1, apply2, apply3, apply4, applyN, numArgs
 
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 gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
 
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)

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

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