gnu.expr

Class Expression

Implemented Interfaces:
Named, Printable
Known Direct Subclasses:
AccessExp, ApplyExp, BeginExp, BlockExp, ErrorExp, ExitExp, IfExp, LangExp, QuoteExp, ScopeExp, SynchronizedExp, TryExp

public abstract class Expression
extends Procedure0
implements Printable

Abstract class for syntactic forms that evaluate to a value. Scheme S-expressions get re-written to these before evaluation.

Field Summary

protected static int
NEXT_AVAIL_FLAG
protected int
flags
static Expression[]
noExpressions

Method Summary

void
apply(CallContext ctx)
Object
apply0()
void
compile(Compilation comp, Type type)
abstract void
compile(Compilation comp, Target target)
static void
compileButFirst(Expression exp, Compilation comp)
Compile all but the first sub-"statement".
void
compileNotePosition(Compilation comp, Target target, Expression position)
Compile, but take note of line number.
void
compileWithPosition(Compilation comp, Target target)
Same as compile, but emit line number beforehard.
void
compileWithPosition(Compilation comp, Target target, Expression position)
Same as 2-argument compileWithPosition, but use some other Expression's line number.
Object
eval(CallContext ctx)
Object
eval(Environment env)
int
getColumn()
String
getFile()
boolean
getFlag(int flag)
int
getFlags()
int
getLine()
Get the line number of (the start of) this Expression.
Type
getType()
Return the Type used to represent the values of this Expression.
static Expression
makeWhile(Object cond, Object body, Compilation parser)
Helper method to create a `while' statement.
int
match0(CallContext ctx)
abstract void
print(OutPort ps)
void
print(java.io.PrintWriter ps)
void
printLineColumn(OutPort out)
Print line and column number if specified.
void
setFile(String filename)
void
setFlag(boolean setting, int flag)
void
setFlag(int flag)
void
setLine(Compilation comp)
Set line number from current position in Compilation.
Expression
setLine(Expression old)
void
setLine(int lineno)
void
setLine(int lineno, int colno)
protected Expression
walk(ExpWalker walker)
protected void
walkChildren(ExpWalker walker)

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

NEXT_AVAIL_FLAG

protected static final int NEXT_AVAIL_FLAG
Field Value:
1

flags

protected int flags

noExpressions

public static final Expression[] noExpressions

Method Details

apply

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

apply0

public final Object apply0()
            throws Throwable
Overrides:
apply0 in interface Procedure0

compile

public final void compile(Compilation comp,
                          Type type)

compile

public abstract void compile(Compilation comp,
                             Target target)

compileButFirst

public static void compileButFirst(Expression exp,
                                   Compilation comp)
Compile all but the first sub-"statement". A kludge used for constructor methods, since if the first "statement" is a super-constructor we need to inject initializer expressions.

compileNotePosition

public final void compileNotePosition(Compilation comp,
                                      Target target,
                                      Expression position)
Compile, but take note of line number.

compileWithPosition

public final void compileWithPosition(Compilation comp,
                                      Target target)
Same as compile, but emit line number beforehard.

compileWithPosition

public final void compileWithPosition(Compilation comp,
                                      Target target,
                                      Expression position)
Same as 2-argument compileWithPosition, but use some other Expression's line number.

eval

public final Object eval(CallContext ctx)
            throws Throwable

eval

public Object eval(Environment env)
            throws Throwable

getColumn

public final int getColumn()

getFile

public final String getFile()

getFlag

public boolean getFlag(int flag)

getFlags

public int getFlags()

getLine

public final int getLine()
Get the line number of (the start of) this Expression. The "first" line is line 1.

getType

public Type getType()
Return the Type used to represent the values of this Expression.

makeWhile

public static Expression makeWhile(Object cond,
                                   Object body,
                                   Compilation parser)
Helper method to create a `while' statement.

match0

public final int match0(CallContext ctx)
Overrides:
match0 in interface Procedure

print

public abstract void print(OutPort ps)

print

public final void print(java.io.PrintWriter ps)

printLineColumn

public void printLineColumn(OutPort out)
Print line and column number if specified. This is a helper routineintended for use by print(OutPort).

setFile

public final void setFile(String filename)

setFlag

public void setFlag(boolean setting,
                    int flag)

setFlag

public void setFlag(int flag)

setLine

public void setLine(Compilation comp)
Set line number from current position in Compilation.

setLine

public final Expression setLine(Expression old)

setLine

public final void setLine(int lineno)

setLine

public final void setLine(int lineno,
                          int colno)

walk

protected Expression walk(ExpWalker walker)

walkChildren

protected void walkChildren(ExpWalker walker)