|
mjc | ||||||||||
| 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
org.multijava.mjc.JLiteral
org.multijava.mjc.JNumberLiteral
org.multijava.mjc.JOrdinalLiteral
This class represents literals of primitive integral types (byte, short, int, long). Instances of this class are also used to hold the results of computations of constant expressions over integral types.
| Field Summary | |
protected String |
image
|
protected CType |
type
|
protected Number |
value
|
| Fields inherited from class org.multijava.mjc.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 | |
JOrdinalLiteral(TokenReference where,
Number value,
CNumericType type)
Construct a node in the parsing tree |
|
JOrdinalLiteral(TokenReference where,
String image)
Construct a node in the parsing tree |
|
JOrdinalLiteral(TokenReference where,
long value,
CNumericType type)
Construct a node in the parsing tree |
|
| Method Summary | |
void |
accept(MjcVisitor p)
Accepts the specified visitor |
protected void |
calculateType()
Determines the smallest magnitude ordinal type (byte, short, int, or long) that can represent the value of this literal. |
JExpression |
convertType(CType dest,
CExpressionContextType context)
convertType changes the type of this expression to another |
void |
genCode(CodeSequence code)
Generates a sequence of bytecodes |
CType |
getType()
Returns the type of this expression. |
Object |
getValue()
Returns a Number that represents the value of this literal. |
String |
image()
|
boolean |
isAssignableTo(CType dest)
Is this type assignable to the given type by assignment type conversion [JLS2 5.2]. |
boolean |
isImageOnly()
|
boolean |
isOrdinalLiteral()
Does this expression represent an ordinal literal? |
void |
negate()
This is needed to handle -2147483648 that is allowed against 2147483648 that is not allowed, so we need to know if there is an unary minus before us |
Number |
numberValue()
Returns a Number that represents the value of this literal. |
private void |
setValue(Number newValue,
CNumericType newType)
Sets value to the smallest numeric type that can contain newValue and sets type to newType. |
JExpression |
typecheck(CExpressionContextType context)
Typechecks the expression and mutates the context to record information gathered during typechecking. |
| Methods inherited from class org.multijava.mjc.JNumberLiteral |
isDefault, toString |
| Methods inherited from class org.multijava.mjc.JLiteral |
createLiteral, getLiteral, isConstant, isLiteral, isLValue |
| Methods inherited from class org.multijava.mjc.JExpression |
buildUniverseDynChecks, clone, dumpArray, fail, genBranch, genUniverseDynCheckCode, getApparentType, getBooleanLiteral, getFANonNulls, getFANulls, getNumberLiteral, getOrdinalLiteral, getRealLiteral, getStringLiteral, isBooleanLiteral, isDeclaredNonNull, isMaybeInitializable, isNonNull, isRealLiteral, isStatementExpression, isStringLiteral, typecheck, unParenthesize |
| 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, wait, wait, wait |
| Field Detail |
protected String image
protected Number value
protected CType type
| Constructor Detail |
public JOrdinalLiteral(TokenReference where,
String image)
where - the line of this node in the source codeimage - the string representation of this literal
public JOrdinalLiteral(TokenReference where,
Number value,
CNumericType type)
where - the line of this node in the source codevalue - the value of this literaltype - the type of this literal
public JOrdinalLiteral(TokenReference where,
long value,
CNumericType type)
where - the line of this node in the source codevalue - the value of this literaltype - the type of this literal| Method Detail |
public void negate()
public boolean isImageOnly()
public CType getType()
public Number numberValue()
public Object getValue()
private void setValue(Number newValue,
CNumericType newType)
public String image()
public boolean isOrdinalLiteral()
JExpression
isOrdinalLiteral in class JExpression
public JExpression typecheck(CExpressionContextType context)
throws PositionedError
typecheck in class JLiteralcontext - the context in which this expression appears
JExpression.typecheck())
PositionedError - if the check fails
public JExpression convertType(CType dest,
CExpressionContextType context)
throws PositionedError
convertType in class JExpressiondest - the destination typecontext - the context in which this expression appears
PositionedErrorpublic boolean isAssignableTo(CType dest)
isAssignableTo in class JExpressiondest - the destination type
protected void calculateType()
value is computed, if it is null.
public void accept(MjcVisitor p)
p - the visitorpublic void genCode(CodeSequence code)
code - the code list
|
mjc | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||