gnu.expr

Class ApplyExp

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
static int
TAILCALL
ApplyExp
nextCall
The next ApplyExp in ((ReferenceExp)func).binding.firstCall list.
protected Type
type
Cache for getType().

Fields inherited from class gnu.expr.Expression

NEXT_AVAIL_FLAG, flags, noExpressions

Constructor Summary

ApplyExp(Method m, Expression[] a)
ApplyExp(Expression f, Expression[] a)
ApplyExp(Procedure p, Expression[] a)

Method Summary

void
apply(CallContext ctx)
static void
compile(ApplyExp exp, Compilation comp, Target target)
void
compile(Compilation comp, Target target)
static void
compileToArray(Expression[] args, Compilation comp)
Object
eval(Environment env)
int
getArgCount()
Expression[]
getArgs()
Expression
getFunction()
Object
getFunctionValue()
If getFunction() is constant, return its value; otherwise null.
Type
getType()
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

apply, apply0, compile, compile, compileNotePosition, compileWithPosition, compileWithPosition, eval, eval, getColumn, getFile, getFlag, getFlags, getLine, getType, makeWhile, match0, print, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, walk, walkChildren

Methods inherited from class gnu.mapping.Procedure0

apply0, apply1, apply2, apply3, apply4, applyN, numArgs

Methods inherited from class gnu.mapping.Procedure

apply, apply, apply0, apply1, apply2, apply3, apply4, applyN, check0, check1, check2, check3, check4, checkArgCount, checkN, getName, getProperty, getSetter, getSymbol, match0, match1, match2, match3, match4, matchN, maxArgs, minArgs, name, numArgs, removeProperty, set0, set1, setN, setName, setProperty, setProperty, setSetter, setSymbol, toString

Field Details

INLINE_IF_CONSTANT

public static final int INLINE_IF_CONSTANT
Field Value:
2

TAILCALL

public static final int TAILCALL
Field Value:
1

nextCall

public ApplyExp nextCall
The next ApplyExp in ((ReferenceExp)func).binding.firstCall list.

type

protected Type type
Cache for getType().

Constructor Details

ApplyExp

public ApplyExp(Method m,
                Expression[] a)

ApplyExp

public ApplyExp(Expression f,
                Expression[] a)

ApplyExp

public ApplyExp(Procedure p,
                Expression[] a)

Method Details

apply

public void apply(CallContext ctx)
            throws Throwable
Overrides:
apply in interface Expression

compile

public static void compile(ApplyExp exp,
                           Compilation comp,
                           Target target)

compile

public void compile(Compilation comp,
                    Target target)
Overrides:
compile in interface Expression

compileToArray

public static void compileToArray(Expression[] args,
                                  Compilation comp)

eval

public Object eval(Environment env)
            throws Throwable
Overrides:
eval in interface Expression

getArgCount

public final int getArgCount()

getArgs

public final Expression[] getArgs()

getFunction

public final Expression getFunction()

getFunctionValue

public final Object getFunctionValue()
If getFunction() is constant, return its value; otherwise null.

getType

public final Type getType()
Overrides:
getType in interface 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.

isTailCall

public final boolean isTailCall()

print

public void print(OutPort out)
Overrides:
print in interface Expression

setArgs

public void setArgs(Expression[] args)

setFunction

public void setFunction(Expression func)

setTailCall

public final void setTailCall(boolean tailCall)

walk

protected Expression walk(ExpWalker walker)
Overrides:
walk in interface Expression

walkChildren

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