|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.multijava.util.Utils
org.multijava.util.compiler.Phylum
org.multijava.mjc.JPhylum
org.multijava.mjc.JExpression
This class is the root class for all classes representing expression nodes in the AST.
| Field Summary | |
static JExpression[] |
EMPTY
|
| Fields inherited from class org.multijava.util.compiler.Phylum |
|
| Fields inherited from class org.multijava.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
| Constructor Summary | |
JExpression(TokenReference where)
Construct a node in the parsing tree |
|
| Method Summary | |
abstract void |
accept(MjcVisitor p)
Accepts the specified visitor |
void |
buildUniverseDynChecks(CExpressionContextType context,
JExpression var)
Creates the expressions for the dynamic universe typechecks. |
Object |
clone()
|
JExpression |
convertType(CType dest,
CExpressionContextType context)
Changes the type of this expression to the given type. |
void |
dumpArray(String msg,
Object[] exprs)
Print the message followed by the array's elements. |
protected void |
fail(CContextType context,
MessageDescription key,
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 |
void |
genUniverseDynCheckCode(CodeSequence code)
Generate the code for the dynamic universe typechecks. |
CType |
getApparentType()
Returns the type of this expression (called after parsing). |
JBooleanLiteral |
getBooleanLiteral()
Returns a typed literal for this expression The expression must be a constant |
Object[] |
getFANonNulls(CContextType context)
Returns a list of expressions known to be non-null if this evaluates to true. |
Object[] |
getFANulls(CContextType context)
Returns a list of expressions known to be null if this evaluates to false. |
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)
Is this type assignable to the given type by assignment type conversion [JLS2 5.2]. |
boolean |
isBooleanLiteral()
Does this expression represent a boolean literal? |
boolean |
isConstant()
|
boolean |
isDeclaredNonNull()
Returns true iff the variable, field or method represente by this expression was declared non_null. |
boolean |
isLiteral()
Does this expression represent a literal? |
boolean |
isMaybeInitializable()
Indicates whether this expression can appear on the left-hand side of an assignment or in an increment or decrement operation. |
boolean |
isNonNull(CContextType context)
Returns true iff the value represented by this expression is non-null |
boolean |
isOrdinalLiteral()
Does this expression represent an ordinal literal? |
boolean |
isRealLiteral()
Does this expression represent a real literal? |
boolean |
isStatementExpression()
Returns true iff this expression can be used as a statement (JLS 14.7) |
boolean |
isStringLiteral()
Does this expression represent a string literal? |
abstract JExpression |
typecheck(CExpressionContextType context)
Typechecks the expression and mutates the context to record information gathered during typechecking. |
JExpression |
typecheck(CExpressionContextType context,
boolean isIncDec,
boolean isLeftSide,
boolean discardValue)
Typechecks the expression and mutates the context to record information gathered during typechecking. |
JExpression |
unParenthesize()
Returns this with outer parentheses removed. |
| Methods inherited from class org.multijava.mjc.JPhylum |
check, check, check, check, fail, fail, warn, warn, warn, warn |
| Methods inherited from class org.multijava.util.compiler.Phylum |
getTokenReference, setTokenReference |
| Methods inherited from class org.multijava.util.Utils |
assertTrue, assertTrue, combineArrays, escapeString, escapeString, fail, fail, getFilePath, hasFlag, hasOtherFlags, parsePathParts, relativePathTo, splitQualifiedName, splitQualifiedName, stripJavaModifiers, stripNonJavaModifiers, stripPrivateModifier, unescapeString, vectorToArray, vectorToIntArray |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final JExpression[] EMPTY
| Constructor Detail |
public JExpression(TokenReference where)
where - the line of this node in the source code| Method Detail |
public Object clone()
clone in class Objectpublic abstract CType getType()
public boolean isNonNull(CContextType context)
public boolean isDeclaredNonNull()
public Object[] getFANonNulls(CContextType context)
public void dumpArray(String msg,
Object[] exprs)
public Object[] getFANulls(CContextType context)
public CType getApparentType()
getType(); but for nodes such as
JNewAnonymousClassExpression, it returns the type
written by the programmer, e.g., T in
new T(...) {...}.
getType()public boolean isConstant()
public boolean isStatementExpression()
public boolean isMaybeInitializable()
instanceof checks in
several places during typechecking.
The converse is not true.ensures \result ==> (this instanceof CInitializable);
JParenthesedExpressionpublic JLiteral getLiteral()
public final JOrdinalLiteral getOrdinalLiteral()
public final JRealLiteral getRealLiteral()
public final JBooleanLiteral getBooleanLiteral()
public final JNumberLiteral getNumberLiteral()
public final JStringLiteral getStringLiteral()
public boolean isLiteral()
public boolean isOrdinalLiteral()
public boolean isRealLiteral()
public boolean isBooleanLiteral()
public boolean isStringLiteral()
public abstract JExpression typecheck(CExpressionContextType context)
throws PositionedError
context - the context in which this expression appears
PositionedError - if the check fails
public final JExpression typecheck(CExpressionContextType context,
boolean isIncDec,
boolean isLeftSide,
boolean discardValue)
throws PositionedError
Typechecks the expression and mutates the context to record
information gathered during typechecking. This overloaded
method is used when the expression is an increment/decrement or
appears as one entire side of an assignment. While at first
glance it appears that the last two boolean arguments would
vary together (either both true or both false) in the case of
compound assignments, like x += 3, the expression
for x is on the left side but its value is not
discarded.
The context tracks the boolean values of these flags so subexpressions have access to this information. These flags in the current context are reset to their old values at the conclusion of this method.
context - the context in which this expression appearsisIncDec - indicates whether this expression appears in
an increment or decrement expressionisLeftSide - indicates whether this expression appears on
the left side of an assignmentdiscardValue - indicates whether the result of an
expression should be discarded
JExpression.typecheck())
PositionedError - if the check fails
protected void fail(CContextType context,
MessageDescription key,
Object[] params)
throws PositionedError
fail in class JPhylumcontext - the context in which the error occurredkey - the message ident to be displayedparams - the array of parameters
PositionedError
public JExpression convertType(CType dest,
CExpressionContextType context)
throws PositionedError
isAssignableTo to
verify that the conversion is valid.
dest - the destination typecontext - the context in which this expression appears
PositionedError - if a type promotion is required and
the promotion fails to typecheck
!FIXME! it seems like this
will never happen public boolean isAssignableTo(CType dest)
dest - the destination type
public abstract void accept(MjcVisitor p)
p - the visitorpublic abstract void genCode(CodeSequence code)
code - the code list
public void genBranch(boolean cond,
CodeSequence code,
CodeLabel label)
code - the code listpublic JExpression unParenthesize()
public void buildUniverseDynChecks(CExpressionContextType context,
JExpression var)
throws PositionedError
context - context used to typecheck the expressions createdvar - the variable where the new object is found
PositionedError - By scdaniel.public void genUniverseDynCheckCode(CodeSequence code)
code - the CodeSequence for the codegeneration
By scdaniel.
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||