public abstract class Expression extends Procedure0 implements Printable, SourceLocator
Modifier and Type | Field and Description |
---|---|
protected int |
flags |
protected static int |
NEXT_AVAIL_FLAG |
static Expression[] |
noExpressions |
protected Type |
type |
static int |
VALIDATED |
compilerKey, compilerXKey, validateApplyKey, validateXApplyKey
nameKey
Constructor and Description |
---|
Expression() |
Modifier and Type | Method and Description |
---|---|
void |
apply(CallContext ctx)
Evaluate the expression.
|
java.lang.Object |
apply0() |
protected Type |
calculateType() |
Keyword |
checkLiteralKeyword()
Is this a keyword argument?
In the future this will return non-null only for explicit
literal non-quoted Keywords.
|
void |
compile(Compilation comp,
Declaration lhs)
Compile an expression with checking suitable for a known Declaration.
|
abstract void |
compile(Compilation comp,
Target target) |
void |
compile(Compilation comp,
Type type) |
static void |
compileButFirst(Expression exp,
Compilation comp)
Compile all but the first sub-"statement".
|
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.
|
protected static Expression |
deepCopy(Expression exp) |
static Expression[] |
deepCopy(Expression[] exps,
IdentityHashTable mapper) |
static Expression |
deepCopy(Expression exp,
IdentityHashTable mapper)
Make a deep copy of this expression, if possible.
|
protected Expression |
deepCopy(IdentityHashTable mapper) |
java.lang.Object |
eval(CallContext ctx) |
java.lang.Object |
eval(Environment env) |
int |
getColumnNumber()
Return current column number.
|
java.lang.String |
getFileName()
Normally same as getSystemId.
|
boolean |
getFlag(int flag) |
int |
getFlags() |
int |
getLineNumber()
Get the line number of (the start of) this Expression.
|
java.lang.String |
getPublicId() |
java.lang.String |
getSystemId() |
Type |
getType()
Return the Type used to represent the values of this Expression.
|
Type |
getTypeRaw() |
boolean |
isSingleValue() |
boolean |
isStableSourceLocation()
True if position is unlikely to change.
|
static Expression |
makeWhile(java.lang.Object cond,
java.lang.Object body,
Compilation parser)
Helper method to create a `while' statement.
|
int |
match0(CallContext ctx)
Pass zero arguments.
|
Expression |
maybeSetLine(Expression old) |
protected abstract boolean |
mustCompile() |
boolean |
neverReturns()
True if the expression provably never returns.
|
void |
print(Consumer out) |
abstract void |
print(gnu.kawa.io.OutPort ps) |
void |
printLineColumn(gnu.kawa.io.OutPort out)
Print line and column number if specified.
|
void |
setFile(java.lang.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) |
void |
setLocation(SourceLocator location)
Copies the current location.
|
void |
setType(Type type) |
boolean |
side_effects()
True if evaluating may have side-effects.
|
java.lang.String |
toString() |
Expression |
validateApply(ApplyExp exp,
InlineCalls visitor,
Type required,
Declaration decl)
Apply inlining transformations on a given ApplyExp.
|
java.lang.Object |
valueIfConstant()
Return value if it is constant, or null if non-constant or unknown.
|
protected <R,D> R |
visit(ExpVisitor<R,D> visitor,
D d) |
protected <R,D> void |
visitChildren(ExpVisitor<R,D> visitor,
D d) |
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
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
public static final Expression[] noExpressions
protected Type type
protected int flags
public static final int VALIDATED
protected static final int NEXT_AVAIL_FLAG
public final java.lang.Object eval(CallContext ctx) throws java.lang.Throwable
java.lang.Throwable
public final java.lang.Object eval(Environment env) throws java.lang.Throwable
java.lang.Throwable
protected abstract boolean mustCompile()
public final int match0(CallContext ctx)
Procedure
public final java.lang.Object apply0() throws java.lang.Throwable
apply0
in class Procedure0
java.lang.Throwable
public void apply(CallContext ctx) throws java.lang.Throwable
public abstract void print(gnu.kawa.io.OutPort ps)
public void printLineColumn(gnu.kawa.io.OutPort out)
public abstract void compile(Compilation comp, Target target)
public final void compileWithPosition(Compilation comp, Target target)
public final void compileWithPosition(Compilation comp, Target target, Expression position)
public final void compile(Compilation comp, Type type)
public final void compile(Compilation comp, Declaration lhs)
public static void compileButFirst(Expression exp, Compilation comp)
public static Expression deepCopy(Expression exp, IdentityHashTable mapper)
mapper
- used to lookup parts (expressions, declarations)
that have been translated in the parent.
Needed for copied Declarations and BlockExps.public static Expression[] deepCopy(Expression[] exps, IdentityHashTable mapper)
protected static Expression deepCopy(Expression exp)
protected Expression deepCopy(IdentityHashTable mapper)
protected <R,D> R visit(ExpVisitor<R,D> visitor, D d)
protected <R,D> void visitChildren(ExpVisitor<R,D> visitor, D d)
public Expression validateApply(ApplyExp exp, InlineCalls visitor, Type required, Declaration decl)
exp
- an application whose function expression can be simplified
to this expression.visitor
- the context for the current inlining passdecl
- if non-null, a Declaration bound to this expression.public static Expression makeWhile(java.lang.Object cond, java.lang.Object body, Compilation parser)
public final void setLocation(SourceLocator location)
public final Expression setLine(Expression old)
public final Expression maybeSetLine(Expression old)
public final void setFile(java.lang.String filename)
public final void setLine(int lineno, int colno)
public final void setLine(int lineno)
public final java.lang.String getFileName()
SourceLocator
public void setLine(Compilation comp)
Compilation
.public java.lang.String getPublicId()
getPublicId
in interface javax.xml.transform.SourceLocator
getPublicId
in interface org.xml.sax.Locator
public java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.SourceLocator
getSystemId
in interface org.xml.sax.Locator
public final int getLineNumber()
getLineNumber
in interface javax.xml.transform.SourceLocator
getLineNumber
in interface org.xml.sax.Locator
public final int getColumnNumber()
SourceLocator
getColumnNumber
in interface javax.xml.transform.SourceLocator
getColumnNumber
in interface org.xml.sax.Locator
public boolean isStableSourceLocation()
SourceLocator
public final Type getType()
protected Type calculateType()
public final Type getTypeRaw()
public void setType(Type type)
public boolean neverReturns()
public Keyword checkLiteralKeyword()
public boolean isSingleValue()
public java.lang.Object valueIfConstant()
public void setFlag(boolean setting, int flag)
public void setFlag(int flag)
public int getFlags()
public boolean getFlag(int flag)
public boolean side_effects()