public interface JavaConstant extends Constant, JavaValue, Value
JavaConstant
instances that represent frequently used constant values, such as
NULL_POINTER
.Value.IllegalValue
Modifier and Type | Field and Description |
---|---|
static PrimitiveConstant |
DOUBLE_0 |
static PrimitiveConstant |
DOUBLE_1 |
static PrimitiveConstant |
FALSE |
static PrimitiveConstant |
FLOAT_0 |
static PrimitiveConstant |
FLOAT_1 |
static PrimitiveConstant |
INT_0 |
static PrimitiveConstant |
INT_1 |
static PrimitiveConstant |
INT_2 |
static PrimitiveConstant |
INT_MINUS_1 |
static PrimitiveConstant |
LONG_0 |
static PrimitiveConstant |
LONG_1 |
static JavaConstant |
NULL_POINTER |
static PrimitiveConstant |
TRUE |
Modifier and Type | Method and Description |
---|---|
static JavaConstant |
add(JavaConstant x,
JavaConstant y)
Adds two numeric constants.
|
boolean |
asBoolean()
Returns the primitive boolean value this constant represents.
|
Object |
asBoxedPrimitive()
Returns the value of this constant as a boxed Java value.
|
double |
asDouble()
Returns the primitive double value this constant represents.
|
float |
asFloat()
Returns the primitive float value this constant represents.
|
int |
asInt()
Returns the primitive int value this constant represents.
|
long |
asLong()
Returns the primitive long value this constant represents.
|
static JavaConstant |
defaultForKind(Kind kind)
Returns a constant with the default value for the given kind.
|
static PrimitiveConstant |
forBoolean(boolean i)
Creates a boxed boolean constant.
|
static PrimitiveConstant |
forBoxedPrimitive(Object value)
Creates a boxed constant for the given boxed primitive value.
|
static PrimitiveConstant |
forByte(byte i)
Creates a boxed byte constant.
|
static PrimitiveConstant |
forChar(char i)
Creates a boxed char constant.
|
static PrimitiveConstant |
forDouble(double d)
Creates a boxed double constant.
|
static PrimitiveConstant |
forFloat(float f)
Creates a boxed float constant.
|
static PrimitiveConstant |
forIllegal() |
static PrimitiveConstant |
forInt(int i)
Creates a boxed integer constant.
|
static PrimitiveConstant |
forIntegerKind(Kind kind,
long i)
Creates a
JavaConstant from a primitive integer of a certain kind. |
static PrimitiveConstant |
forLong(long i)
Creates a boxed long constant.
|
static PrimitiveConstant |
forPrimitiveInt(int bits,
long i)
Creates a
JavaConstant from a primitive integer of a certain width. |
static PrimitiveConstant |
forShort(short i)
Creates a boxed short constant.
|
boolean |
isDefaultForKind()
Checks whether this constant is the default value for its kind (null, 0, 0.0, false).
|
default boolean |
isNonNull()
Checks whether this constant is non-null.
|
boolean |
isNull()
Checks whether this constant is null.
|
static boolean |
isNull(Constant c) |
static PrimitiveConstant |
mul(JavaConstant x,
JavaConstant y)
Multiplies two numeric constants.
|
static JavaConstant |
one(Kind kind)
Returns the one value for a given numeric kind.
|
static String |
toString(JavaConstant constant) |
default String |
toValueString() |
static JavaConstant |
zero(Kind kind)
Returns the zero value for a given numeric kind.
|
getLIRKind, getPlatformKind, identityEquals
getKind
static final JavaConstant NULL_POINTER
static final PrimitiveConstant INT_MINUS_1
static final PrimitiveConstant INT_0
static final PrimitiveConstant INT_1
static final PrimitiveConstant INT_2
static final PrimitiveConstant LONG_0
static final PrimitiveConstant LONG_1
static final PrimitiveConstant FLOAT_0
static final PrimitiveConstant FLOAT_1
static final PrimitiveConstant DOUBLE_0
static final PrimitiveConstant DOUBLE_1
static final PrimitiveConstant TRUE
static final PrimitiveConstant FALSE
boolean isNull()
true
if this constant is the null constantdefault boolean isNonNull()
true
if this constant is a primitive, or an object constant that is not nullboolean isDefaultForKind()
isDefaultForKind
in interface Constant
true
if this constant is the default value for its kindObject asBoxedPrimitive()
int asInt()
Kind.getStackKind()
of Kind.Int
.boolean asBoolean()
Kind.Boolean
.long asLong()
Kind.Long
, a Kind.getStackKind()
of Kind.Int
.float asFloat()
Kind.Float
.double asDouble()
Kind.Double
.default String toValueString()
toValueString
in interface Constant
static String toString(JavaConstant constant)
static PrimitiveConstant forDouble(double d)
d
- the double value to boxvalue
static PrimitiveConstant forFloat(float f)
f
- the float value to boxvalue
static PrimitiveConstant forLong(long i)
i
- the long value to boxvalue
static PrimitiveConstant forInt(int i)
i
- the integer value to boxvalue
static PrimitiveConstant forByte(byte i)
i
- the byte value to boxvalue
static PrimitiveConstant forBoolean(boolean i)
i
- the boolean value to boxvalue
static PrimitiveConstant forChar(char i)
i
- the char value to boxvalue
static PrimitiveConstant forShort(short i)
i
- the short value to boxvalue
static PrimitiveConstant forIntegerKind(Kind kind, long i)
JavaConstant
from a primitive integer of a certain kind.static PrimitiveConstant forPrimitiveInt(int bits, long i)
JavaConstant
from a primitive integer of a certain width.static PrimitiveConstant forBoxedPrimitive(Object value)
value
- the Java boxed valuevalue
static PrimitiveConstant forIllegal()
static JavaConstant defaultForKind(Kind kind)
static JavaConstant zero(Kind kind)
static JavaConstant one(Kind kind)
static JavaConstant add(JavaConstant x, JavaConstant y)
static PrimitiveConstant mul(JavaConstant x, JavaConstant y)