|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--at.dms.util.Utils | +--at.dms.compiler.Phylum | +--at.dms.kjc.JPhylum | +--at.dms.kjc.JExpression
Root class for all expressions in the syntax tree.
Field Summary | |
static JExpression[] |
EMPTY
Empty expression-list constant. |
Fields inherited from class at.dms.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
Fields inherited from interface at.dms.kjc.Constants |
CMP_VERSION, JAV_CLASS, JAV_CLONE, JAV_CLONEABLE, JAV_CONSTRUCTOR, JAV_ERROR, JAV_EXCEPTION, JAV_INIT, JAV_LENGTH, JAV_NAME_SEPARATOR, JAV_OBJECT, JAV_OUTER_THIS, JAV_RUNTIME, JAV_RUNTIME_EXCEPTION, JAV_STATIC_INIT, JAV_STRING, JAV_STRINGBUFFER, JAV_THIS, JAV_THROWABLE, OPE_BAND, OPE_BNOT, OPE_BOR, OPE_BSR, OPE_BXOR, OPE_EQ, OPE_GE, OPE_GT, OPE_LE, OPE_LNOT, OPE_LT, OPE_MINUS, OPE_NE, OPE_PERCENT, OPE_PLUS, OPE_POSTDEC, OPE_POSTINC, OPE_PREDEC, OPE_PREINC, OPE_SIMPLE, OPE_SL, OPE_SLASH, OPE_SR, OPE_STAR, TID_ARRAY, TID_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_LONG, TID_SHORT, TID_VOID |
Constructor Summary | |
JExpression(TokenReference where)
Construct a node in the parsing tree |
Method Summary | |
abstract void |
accept(KjcVisitor p)
Accepts the specified visitor |
abstract JExpression |
checkExpression(CExpressionContext context)
Check expression and evaluate and alter context. |
JExpression |
checkExpression(CExpressionContext context,
boolean isLeftSide,
boolean discardValue)
Check expression and evaluate and alter context |
JExpression |
convertType(CType dest,
CExpressionContext context)
Changes the type of this expression to an other type. |
protected void |
fail(CContext context,
MessageDescription key,
java.lang.Object[] params)
Adds a compiler error. |
void |
genBranch(boolean cond,
CodeSequence code,
CodeLabel label)
Generates a sequence of bytecodes to branch on a label This method helps to handle heavy optimizables conditions |
abstract void |
genCode(CodeSequence code)
Generates a sequence of bytecodes |
JBooleanLiteral |
getBooleanLiteral()
Returns a typed literal for this expression The expression must be a constant |
JLiteral |
getLiteral()
Returns the literal value of this expression. |
JNumberLiteral |
getNumberLiteral()
Returns a typed literal for this expression The expression must be a constant |
JOrdinalLiteral |
getOrdinalLiteral()
Returns a typed literal for this expression The expression must be a constant |
JRealLiteral |
getRealLiteral()
Returns a typed literal for this expression The expression must be a constant |
JStringLiteral |
getStringLiteral()
Returns a typed literal for this expression The expression must be a constant |
abstract CType |
getType()
Returns the type of this expression (call after parsing only) |
boolean |
isAssignableTo(CType dest)
Can this expression be converted to the specified type by assignment conversion (JLS 5.2) ? |
boolean |
isConstant()
Returns true if this expression is constant according to the JLS. |
boolean |
isLiteral()
Returns true if this expression is a literal. |
boolean |
isStatementExpression()
Returns true iff this expression can be used as a statement (JLS 14.7) |
boolean |
isSubTypePossible()
Returns whether this expression can result in subtypes of the type returned by the getType() method, or whether it always
returns the exact type returned by getType() . |
void |
setConstant(boolean constant)
Change this JLS-constantness of this literal. |
JExpression |
unParenthesize()
|
Methods inherited from class at.dms.kjc.JPhylum |
check, check, check, check |
Methods inherited from class at.dms.compiler.Phylum |
getTokenReference, setTokenReference |
Methods inherited from class at.dms.util.Utils |
assert, assert, fail, fail, hasFlag, hasMoreThanOneFlag, hasOtherFlags, splitQualifiedName, splitQualifiedName, vectorToArray, vectorToIntArray |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final JExpression[] EMPTY
Constructor Detail |
public JExpression(TokenReference where)
where
- the line of this node in the source codeMethod Detail |
public abstract CType getType()
public boolean isSubTypePossible()
getType()
method, or whether it always
returns the exact type returned by getType()
.
The return value of this method has no meaning unless getType() returns
a Class-type. (CType.isClassType()
)public boolean isConstant()
public void setConstant(boolean constant)
public boolean isStatementExpression()
public boolean isLiteral()
In this particular case there is the added problem that the field cannot be stored in a classfile as a compile-time constant; a "final static String" constant larger than 65535 characters cannot be stored in the classes' constant pool. When compiling against the source of a file containing such a large constant, the compiler can ignore this problem. The problem appears when you try to compile another program against a class file with such a String constant, as the other program will not consider the field a compile-time constant. Some expression may be a literal, such as the NullLiteral or the result of ( true ? 10 : System.currentTimeMillis() ), but they're not constant as defined by the Java Language Specification, 2nd edition.
public JLiteral getLiteral()
public final JOrdinalLiteral getOrdinalLiteral()
public final JRealLiteral getRealLiteral()
public final JBooleanLiteral getBooleanLiteral()
public final JNumberLiteral getNumberLiteral()
public final JStringLiteral getStringLiteral()
public abstract JExpression checkExpression(CExpressionContext context) throws PositionedError
context
- the actual context of analysePositionedError
- if the check failsUnpositionedError
- this error will be positioned soonpublic final JExpression checkExpression(CExpressionContext context, boolean isLeftSide, boolean discardValue) throws PositionedError
context
- the actual context of analyseisLeftSide
- discardValue
- PositionedError
- if the check failsprotected void fail(CContext context, MessageDescription key, java.lang.Object[] params) throws PositionedError
fail
in class JPhylum
context
- the context in which the error occurredkey
- the message ident to be displayedparams
- the array of parameterspublic JExpression convertType(CType dest, CExpressionContext context) throws PositionedError
dest
- The destination type.public boolean isAssignableTo(CType dest)
dest
- the destination typepublic abstract void accept(KjcVisitor p)
accept
in class JPhylum
p
- the visitorpublic abstract void genCode(CodeSequence code)
code
- the code listpublic void genBranch(boolean cond, CodeSequence code, CodeLabel label)
code
- the code listpublic JExpression unParenthesize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |