improve style for these constants

This commit is contained in:
Robert Muir 2016-05-20 08:42:29 -04:00
parent 7bc91c00d9
commit b3c71c1e3a
30 changed files with 153 additions and 153 deletions

View File

@ -118,18 +118,18 @@ public final class AnalyzerCaster {
final Sort sort = from.sort;
if (sort == Sort.DEF) {
return Definition.defType;
return Definition.DEF_TYPE;
} else if ((sort == Sort.DOUBLE || sort == Sort.DOUBLE_OBJ) && decimal) {
return primitive ? Definition.doubleType : Definition.doubleobjType;
return primitive ? Definition.DOUBLE_TYPE : Definition.DOUBLE_OBJ_TYPE;
} else if ((sort == Sort.FLOAT || sort == Sort.FLOAT_OBJ) && decimal) {
return primitive ? Definition.floatType : Definition.floatobjType;
return primitive ? Definition.FLOAT_TYPE : Definition.FLOAT_OBJ_TYPE;
} else if (sort == Sort.LONG || sort == Sort.LONG_OBJ) {
return primitive ? Definition.longType : Definition.longobjType;
return primitive ? Definition.LONG_TYPE : Definition.LONG_OBJ_TYPE;
} else if (sort == Sort.INT || sort == Sort.INT_OBJ ||
sort == Sort.CHAR || sort == Sort.CHAR_OBJ ||
sort == Sort.SHORT || sort == Sort.SHORT_OBJ ||
sort == Sort.BYTE || sort == Sort.BYTE_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
}
return null;
@ -140,21 +140,21 @@ public final class AnalyzerCaster {
final Sort sort1 = from1.sort;
if (sort0 == Sort.DEF || sort1 == Sort.DEF) {
return Definition.defType;
return Definition.DEF_TYPE;
}
if (decimal) {
if (sort0 == Sort.DOUBLE || sort0 == Sort.DOUBLE_OBJ ||
sort1 == Sort.DOUBLE || sort1 == Sort.DOUBLE_OBJ) {
return primitive ? Definition.doubleType : Definition.doubleobjType;
return primitive ? Definition.DOUBLE_TYPE : Definition.DOUBLE_OBJ_TYPE;
} else if (sort0 == Sort.FLOAT || sort0 == Sort.FLOAT_OBJ || sort1 == Sort.FLOAT || sort1 == Sort.FLOAT_OBJ) {
return primitive ? Definition.floatType : Definition.floatobjType;
return primitive ? Definition.FLOAT_TYPE : Definition.FLOAT_OBJ_TYPE;
}
}
if (sort0 == Sort.LONG || sort0 == Sort.LONG_OBJ ||
sort1 == Sort.LONG || sort1 == Sort.LONG_OBJ) {
return primitive ? Definition.longType : Definition.longobjType;
return primitive ? Definition.LONG_TYPE : Definition.LONG_OBJ_TYPE;
} else if (sort0 == Sort.INT || sort0 == Sort.INT_OBJ ||
sort1 == Sort.INT || sort1 == Sort.INT_OBJ ||
sort0 == Sort.CHAR || sort0 == Sort.CHAR_OBJ ||
@ -163,7 +163,7 @@ public final class AnalyzerCaster {
sort1 == Sort.SHORT || sort1 == Sort.SHORT_OBJ ||
sort0 == Sort.BYTE || sort0 == Sort.BYTE_OBJ ||
sort1 == Sort.BYTE || sort1 == Sort.BYTE_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
}
return null;
@ -174,7 +174,7 @@ public final class AnalyzerCaster {
final Sort sort1 = from1.sort;
if (sort0 == Sort.STRING || sort1 == Sort.STRING) {
return Definition.stringType;
return Definition.STRING_TYPE;
}
return promoteNumeric(from0, from1, true, true);
@ -185,7 +185,7 @@ public final class AnalyzerCaster {
final Sort sort1 = from1.sort;
if (sort0.bool || sort1.bool) {
return Definition.booleanType;
return Definition.BOOLEAN_TYPE;
}
return promoteNumeric(from0, from1, false, true);
@ -196,20 +196,20 @@ public final class AnalyzerCaster {
final Sort sort1 = from1.sort;
if (sort0 == Sort.DEF || sort1 == Sort.DEF) {
return Definition.defType;
return Definition.DEF_TYPE;
}
final boolean primitive = sort0.primitive && sort1.primitive;
if (sort0.bool && sort1.bool) {
return primitive ? Definition.booleanType : Definition.booleanobjType;
return primitive ? Definition.BOOLEAN_TYPE : Definition.BOOLEAN_OBJ_TYPE;
}
if (sort0.numeric && sort1.numeric) {
return promoteNumeric(from0, from1, true, primitive);
}
return Definition.objectType;
return Definition.OBJECT_TYPE;
}
public static Type promoteReference(final Type from0, final Type from1) {
@ -217,12 +217,12 @@ public final class AnalyzerCaster {
final Sort sort1 = from1.sort;
if (sort0 == Sort.DEF || sort1 == Sort.DEF) {
return Definition.defType;
return Definition.DEF_TYPE;
}
if (sort0.primitive && sort1.primitive) {
if (sort0.bool && sort1.bool) {
return Definition.booleanType;
return Definition.BOOLEAN_TYPE;
}
if (sort0.numeric && sort1.numeric) {
@ -230,7 +230,7 @@ public final class AnalyzerCaster {
}
}
return Definition.objectType;
return Definition.OBJECT_TYPE;
}
public static Type promoteConditional(final Type from0, final Type from1, final Object const0, final Object const1) {
@ -242,48 +242,48 @@ public final class AnalyzerCaster {
final Sort sort1 = from1.sort;
if (sort0 == Sort.DEF || sort1 == Sort.DEF) {
return Definition.defType;
return Definition.DEF_TYPE;
}
final boolean primitive = sort0.primitive && sort1.primitive;
if (sort0.bool && sort1.bool) {
return primitive ? Definition.booleanType : Definition.booleanobjType;
return primitive ? Definition.BOOLEAN_TYPE : Definition.BOOLEAN_OBJ_TYPE;
}
if (sort0.numeric && sort1.numeric) {
if (sort0 == Sort.DOUBLE || sort0 == Sort.DOUBLE_OBJ || sort1 == Sort.DOUBLE || sort1 == Sort.DOUBLE_OBJ) {
return primitive ? Definition.doubleType : Definition.doubleobjType;
return primitive ? Definition.DOUBLE_TYPE : Definition.DOUBLE_OBJ_TYPE;
} else if (sort0 == Sort.FLOAT || sort0 == Sort.FLOAT_OBJ || sort1 == Sort.FLOAT || sort1 == Sort.FLOAT_OBJ) {
return primitive ? Definition.floatType : Definition.floatobjType;
return primitive ? Definition.FLOAT_TYPE : Definition.FLOAT_OBJ_TYPE;
} else if (sort0 == Sort.LONG || sort0 == Sort.LONG_OBJ || sort1 == Sort.LONG || sort1 == Sort.LONG_OBJ) {
return sort0.primitive && sort1.primitive ? Definition.longType : Definition.longobjType;
return sort0.primitive && sort1.primitive ? Definition.LONG_TYPE : Definition.LONG_OBJ_TYPE;
} else {
if (sort0 == Sort.BYTE || sort0 == Sort.BYTE_OBJ) {
if (sort1 == Sort.BYTE || sort1 == Sort.BYTE_OBJ) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
} else if (sort1 == Sort.SHORT || sort1 == Sort.SHORT_OBJ) {
if (const1 != null) {
final short constant = (short)const1;
if (constant <= Byte.MAX_VALUE && constant >= Byte.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.shortType : Definition.shortobjType;
return primitive ? Definition.SHORT_TYPE : Definition.SHORT_OBJ_TYPE;
} else if (sort1 == Sort.CHAR || sort1 == Sort.CHAR_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.INT || sort1 == Sort.INT_OBJ) {
if (const1 != null) {
final int constant = (int)const1;
if (constant <= Byte.MAX_VALUE && constant >= Byte.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
}
} else if (sort0 == Sort.SHORT || sort0 == Sort.SHORT_OBJ) {
if (sort1 == Sort.BYTE || sort1 == Sort.BYTE_OBJ) {
@ -291,43 +291,43 @@ public final class AnalyzerCaster {
final short constant = (short)const0;
if (constant <= Byte.MAX_VALUE && constant >= Byte.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.shortType : Definition.shortobjType;
return primitive ? Definition.SHORT_TYPE : Definition.SHORT_OBJ_TYPE;
} else if (sort1 == Sort.SHORT || sort1 == Sort.SHORT_OBJ) {
return primitive ? Definition.shortType : Definition.shortobjType;
return primitive ? Definition.SHORT_TYPE : Definition.SHORT_OBJ_TYPE;
} else if (sort1 == Sort.CHAR || sort1 == Sort.CHAR_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.INT || sort1 == Sort.INT_OBJ) {
if (const1 != null) {
final int constant = (int)const1;
if (constant <= Short.MAX_VALUE && constant >= Short.MIN_VALUE) {
return primitive ? Definition.shortType : Definition.shortobjType;
return primitive ? Definition.SHORT_TYPE : Definition.SHORT_OBJ_TYPE;
}
}
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
}
} else if (sort0 == Sort.CHAR || sort0 == Sort.CHAR_OBJ) {
if (sort1 == Sort.BYTE || sort1 == Sort.BYTE_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.SHORT || sort1 == Sort.SHORT_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.CHAR || sort1 == Sort.CHAR_OBJ) {
return primitive ? Definition.charType : Definition.charobjType;
return primitive ? Definition.CHAR_TYPE : Definition.CHAR_OBJ_TYPE;
} else if (sort1 == Sort.INT || sort1 == Sort.INT_OBJ) {
if (const1 != null) {
final int constant = (int)const1;
if (constant <= Character.MAX_VALUE && constant >= Character.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
}
} else if (sort0 == Sort.INT || sort0 == Sort.INT_OBJ) {
if (sort1 == Sort.BYTE || sort1 == Sort.BYTE_OBJ) {
@ -335,33 +335,33 @@ public final class AnalyzerCaster {
final int constant = (int)const0;
if (constant <= Byte.MAX_VALUE && constant >= Byte.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.SHORT || sort1 == Sort.SHORT_OBJ) {
if (const0 != null) {
final int constant = (int)const0;
if (constant <= Short.MAX_VALUE && constant >= Short.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.CHAR || sort1 == Sort.CHAR_OBJ) {
if (const0 != null) {
final int constant = (int)const0;
if (constant <= Character.MAX_VALUE && constant >= Character.MIN_VALUE) {
return primitive ? Definition.byteType : Definition.byteobjType;
return primitive ? Definition.BYTE_TYPE : Definition.BYTE_OBJ_TYPE;
}
}
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
} else if (sort1 == Sort.INT || sort1 == Sort.INT_OBJ) {
return primitive ? Definition.intType : Definition.intobjType;
return primitive ? Definition.INT_TYPE : Definition.INT_OBJ_TYPE;
}
}
}
@ -371,7 +371,7 @@ public final class AnalyzerCaster {
// to calculate the highest upper bound for the two types and return that.
// However, for now we just return objectType that may require an extra cast.
return Definition.objectType;
return Definition.OBJECT_TYPE;
}
private AnalyzerCaster() {}

View File

@ -43,29 +43,29 @@ public final class Definition {
private static final Definition INSTANCE = new Definition();
/** Some native types as constants: */
public static final Type voidType = getType("void");
public static final Type booleanType = getType("boolean");
public static final Type booleanobjType = getType("Boolean");
public static final Type byteType = getType("byte");
public static final Type byteobjType = getType("Byte");
public static final Type shortType = getType("short");
public static final Type shortobjType = getType("Short");
public static final Type intType = getType("int");
public static final Type intobjType = getType("Integer");
public static final Type longType = getType("long");
public static final Type longobjType = getType("Long");
public static final Type floatType = getType("float");
public static final Type floatobjType = getType("Float");
public static final Type doubleType = getType("double");
public static final Type doubleobjType = getType("Double");
public static final Type charType = getType("char");
public static final Type charobjType = getType("Character");
public static final Type objectType = getType("Object");
public static final Type defType = getType("def");
public static final Type defobjType = getType("Def");
public static final Type stringType = getType("String");
public static final Type exceptionType = getType("Exception");
public static final Type utilityType = getType("Utility");
public static final Type VOID_TYPE = getType("void");
public static final Type BOOLEAN_TYPE = getType("boolean");
public static final Type BOOLEAN_OBJ_TYPE = getType("Boolean");
public static final Type BYTE_TYPE = getType("byte");
public static final Type BYTE_OBJ_TYPE = getType("Byte");
public static final Type SHORT_TYPE = getType("short");
public static final Type SHORT_OBJ_TYPE = getType("Short");
public static final Type INT_TYPE = getType("int");
public static final Type INT_OBJ_TYPE = getType("Integer");
public static final Type LONG_TYPE = getType("long");
public static final Type LONG_OBJ_TYPE = getType("Long");
public static final Type FLOAT_TYPE = getType("float");
public static final Type FLOAT_OBJ_TYPE = getType("Float");
public static final Type DOUBLE_TYPE = getType("double");
public static final Type DOUBLE_OBJ_TYPE = getType("Double");
public static final Type CHAR_TYPE = getType("char");
public static final Type CHAR_OBJ_TYPE = getType("Character");
public static final Type OBJECT_TYPE = getType("Object");
public static final Type DEF_TYPE = getType("def");
public static final Type DEF_UTIL_TYPE = getType("Def");
public static final Type STRING_TYPE = getType("String");
public static final Type EXCEPTION_TYPE = getType("Exception");
public static final Type UTILITY_TYPE = getType("Utility");
public enum Sort {
VOID( void.class , 0 , true , false , false , false ),

View File

@ -212,17 +212,17 @@ public final class MethodWriter extends GeneratorAdapter {
if (sort == Sort.DEF) {
switch (operation) {
case MUL: invokeStatic(Definition.defobjType.type, DEF_MUL_CALL); break;
case DIV: invokeStatic(Definition.defobjType.type, DEF_DIV_CALL); break;
case REM: invokeStatic(Definition.defobjType.type, DEF_REM_CALL); break;
case ADD: invokeStatic(Definition.defobjType.type, DEF_ADD_CALL); break;
case SUB: invokeStatic(Definition.defobjType.type, DEF_SUB_CALL); break;
case LSH: invokeStatic(Definition.defobjType.type, DEF_LSH_CALL); break;
case USH: invokeStatic(Definition.defobjType.type, DEF_RSH_CALL); break;
case RSH: invokeStatic(Definition.defobjType.type, DEF_USH_CALL); break;
case BWAND: invokeStatic(Definition.defobjType.type, DEF_AND_CALL); break;
case XOR: invokeStatic(Definition.defobjType.type, DEF_XOR_CALL); break;
case BWOR: invokeStatic(Definition.defobjType.type, DEF_OR_CALL); break;
case MUL: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_MUL_CALL); break;
case DIV: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_DIV_CALL); break;
case REM: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_REM_CALL); break;
case ADD: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_ADD_CALL); break;
case SUB: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_SUB_CALL); break;
case LSH: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_LSH_CALL); break;
case USH: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_RSH_CALL); break;
case RSH: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_USH_CALL); break;
case BWAND: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_AND_CALL); break;
case XOR: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_XOR_CALL); break;
case BWOR: invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_OR_CALL); break;
default:
throw new IllegalStateException("Error " + location + ": Illegal tree structure.");
}

View File

@ -32,7 +32,7 @@ public final class PainlessPlugin extends Plugin {
// force to pare our definition at startup (not on the user's first script)
static {
Definition.voidType.hashCode();
Definition.VOID_TYPE.hashCode();
}
@Override

View File

@ -284,7 +284,7 @@ public final class EBinary extends AExpression {
}
left.expected = promote;
right.expected = Definition.intType;
right.expected = Definition.INT_TYPE;
right.explicit = true;
left = left.cast(settings, variables);
@ -317,7 +317,7 @@ public final class EBinary extends AExpression {
}
left.expected = promote;
right.expected = Definition.intType;
right.expected = Definition.INT_TYPE;
right.explicit = true;
left = left.cast(settings, variables);
@ -350,7 +350,7 @@ public final class EBinary extends AExpression {
}
left.expected = promote;
right.expected = Definition.intType;
right.expected = Definition.INT_TYPE;
right.explicit = true;
left = left.cast(settings, variables);

View File

@ -45,11 +45,11 @@ public final class EBool extends AExpression {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
left.expected = Definition.booleanType;
left.expected = Definition.BOOLEAN_TYPE;
left.analyze(settings, variables);
left = left.cast(settings, variables);
right.expected = Definition.booleanType;
right.expected = Definition.BOOLEAN_TYPE;
right.analyze(settings, variables);
right = right.cast(settings, variables);
@ -63,7 +63,7 @@ public final class EBool extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
@Override

View File

@ -37,7 +37,7 @@ public final class EBoolean extends AExpression {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
@Override

View File

@ -199,7 +199,7 @@ public final class EChain extends AExpression {
expression.expected = expression.actual;
} else if (operation == Operation.LSH || operation == Operation.RSH || operation == Operation.USH) {
expression.expected = Definition.intType;
expression.expected = Definition.INT_TYPE;
expression.explicit = true;
} else {
expression.expected = promote;
@ -211,7 +211,7 @@ public final class EChain extends AExpression {
back = AnalyzerCaster.getLegalCast(location, promote, last.after, true);
this.statement = true;
this.actual = read ? last.after : Definition.voidType;
this.actual = read ? last.after : Definition.VOID_TYPE;
}
private void analyzeWrite(final CompilerSettings settings, final Variables variables) {
@ -231,7 +231,7 @@ public final class EChain extends AExpression {
expression = expression.cast(settings, variables);
this.statement = true;
this.actual = read ? last.after : Definition.voidType;
this.actual = read ? last.after : Definition.VOID_TYPE;
}
private void analyzeRead() {

View File

@ -119,7 +119,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeEqR(final CompilerSettings settings, final Variables variables) {
@ -161,7 +161,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeNE(final CompilerSettings settings, final Variables variables) {
@ -207,7 +207,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeNER(final CompilerSettings settings, final Variables variables) {
@ -249,7 +249,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeGTE(final CompilerSettings settings, final Variables variables) {
@ -285,7 +285,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeGT(final CompilerSettings settings, final Variables variables) {
@ -321,7 +321,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeLTE(final CompilerSettings settings, final Variables variables) {
@ -357,7 +357,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
private void analyzeLT(final CompilerSettings settings, final Variables variables) {
@ -393,7 +393,7 @@ public final class EComp extends AExpression {
}
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
@Override
@ -456,7 +456,7 @@ public final class EComp extends AExpression {
if (right.isNull) {
adapter.ifNull(jump);
} else if (!left.isNull && operation == Operation.EQ) {
adapter.invokeStatic(Definition.defobjType.type, DEF_EQ_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_EQ_CALL);
} else {
adapter.ifCmp(rtype, MethodWriter.EQ, jump);
}
@ -464,19 +464,19 @@ public final class EComp extends AExpression {
if (right.isNull) {
adapter.ifNonNull(jump);
} else if (!left.isNull && operation == Operation.NE) {
adapter.invokeStatic(Definition.defobjType.type, DEF_EQ_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_EQ_CALL);
adapter.ifZCmp(MethodWriter.EQ, jump);
} else {
adapter.ifCmp(rtype, MethodWriter.NE, jump);
}
} else if (lt) {
adapter.invokeStatic(Definition.defobjType.type, DEF_LT_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_LT_CALL);
} else if (lte) {
adapter.invokeStatic(Definition.defobjType.type, DEF_LTE_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_LTE_CALL);
} else if (gt) {
adapter.invokeStatic(Definition.defobjType.type, DEF_GT_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_GT_CALL);
} else if (gte) {
adapter.invokeStatic(Definition.defobjType.type, DEF_GTE_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_GTE_CALL);
} else {
throw new IllegalStateException(error("Illegal tree structure."));
}
@ -493,7 +493,7 @@ public final class EComp extends AExpression {
if (right.isNull) {
adapter.ifNull(jump);
} else if (operation == Operation.EQ) {
adapter.invokeStatic(Definition.utilityType.type, CHECKEQUALS);
adapter.invokeStatic(Definition.UTILITY_TYPE.type, CHECKEQUALS);
if (branch) {
adapter.ifZCmp(MethodWriter.NE, jump);
@ -507,7 +507,7 @@ public final class EComp extends AExpression {
if (right.isNull) {
adapter.ifNonNull(jump);
} else if (operation == Operation.NE) {
adapter.invokeStatic(Definition.utilityType.type, CHECKEQUALS);
adapter.invokeStatic(Definition.UTILITY_TYPE.type, CHECKEQUALS);
adapter.ifZCmp(MethodWriter.EQ, jump);
} else {
adapter.ifCmp(rtype, MethodWriter.NE, jump);

View File

@ -47,7 +47,7 @@ public final class EConditional extends AExpression {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
condition.expected = Definition.booleanType;
condition.expected = Definition.BOOLEAN_TYPE;
condition.analyze(settings, variables);
condition = condition.cast(settings, variables);

View File

@ -40,23 +40,23 @@ final class EConstant extends AExpression {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
if (constant instanceof String) {
actual = Definition.stringType;
actual = Definition.STRING_TYPE;
} else if (constant instanceof Double) {
actual = Definition.doubleType;
actual = Definition.DOUBLE_TYPE;
} else if (constant instanceof Float) {
actual = Definition.floatType;
actual = Definition.FLOAT_TYPE;
} else if (constant instanceof Long) {
actual = Definition.longType;
actual = Definition.LONG_TYPE;
} else if (constant instanceof Integer) {
actual = Definition.intType;
actual = Definition.INT_TYPE;
} else if (constant instanceof Character) {
actual = Definition.charType;
actual = Definition.CHAR_TYPE;
} else if (constant instanceof Short) {
actual = Definition.shortType;
actual = Definition.SHORT_TYPE;
} else if (constant instanceof Byte) {
actual = Definition.byteType;
actual = Definition.BYTE_TYPE;
} else if (constant instanceof Boolean) {
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
} else {
throw new IllegalStateException(error("Illegal tree structure."));
}

View File

@ -42,14 +42,14 @@ public final class EDecimal extends AExpression {
if (value.endsWith("f") || value.endsWith("F")) {
try {
constant = Float.parseFloat(value.substring(0, value.length() - 1));
actual = Definition.floatType;
actual = Definition.FLOAT_TYPE;
} catch (final NumberFormatException exception) {
throw new IllegalArgumentException(error("Invalid float constant [" + value + "]."));
}
} else {
try {
constant = Double.parseDouble(value);
actual = Definition.doubleType;
actual = Definition.DOUBLE_TYPE;
} catch (final NumberFormatException exception) {
throw new IllegalArgumentException(error("Invalid double constant [" + value + "]."));
}

View File

@ -45,7 +45,7 @@ public final class ENull extends AExpression {
actual = expected;
} else {
actual = Definition.objectType;
actual = Definition.OBJECT_TYPE;
}
}

View File

@ -49,7 +49,7 @@ public final class ENumeric extends AExpression {
try {
constant = Double.parseDouble(value.substring(0, value.length() - 1));
actual = Definition.doubleType;
actual = Definition.DOUBLE_TYPE;
} catch (final NumberFormatException exception) {
throw new IllegalArgumentException(error("Invalid double constant [" + value + "]."));
}
@ -60,14 +60,14 @@ public final class ENumeric extends AExpression {
try {
constant = Float.parseFloat(value.substring(0, value.length() - 1));
actual = Definition.floatType;
actual = Definition.FLOAT_TYPE;
} catch (final NumberFormatException exception) {
throw new IllegalArgumentException(error("Invalid float constant [" + value + "]."));
}
} else if (value.endsWith("l") || value.endsWith("L")) {
try {
constant = Long.parseLong(value.substring(0, value.length() - 1), radix);
actual = Definition.longType;
actual = Definition.LONG_TYPE;
} catch (final NumberFormatException exception) {
throw new IllegalArgumentException(error("Invalid long constant [" + value + "]."));
}
@ -78,16 +78,16 @@ public final class ENumeric extends AExpression {
if (sort == Sort.BYTE && integer >= Byte.MIN_VALUE && integer <= Byte.MAX_VALUE) {
constant = (byte)integer;
actual = Definition.byteType;
actual = Definition.BYTE_TYPE;
} else if (sort == Sort.CHAR && integer >= Character.MIN_VALUE && integer <= Character.MAX_VALUE) {
constant = (char)integer;
actual = Definition.charType;
actual = Definition.CHAR_TYPE;
} else if (sort == Sort.SHORT && integer >= Short.MIN_VALUE && integer <= Short.MAX_VALUE) {
constant = (short)integer;
actual = Definition.shortType;
actual = Definition.SHORT_TYPE;
} else {
constant = integer;
actual = Definition.intType;
actual = Definition.INT_TYPE;
}
} catch (final NumberFormatException exception) {
throw new IllegalArgumentException(error("Invalid int constant [" + value + "]."));

View File

@ -63,7 +63,7 @@ public final class EUnary extends AExpression {
}
void analyzeNot(final CompilerSettings settings, final Variables variables) {
child.expected = Definition.booleanType;
child.expected = Definition.BOOLEAN_TYPE;
child.analyze(settings, variables);
child = child.cast(settings, variables);
@ -71,7 +71,7 @@ public final class EUnary extends AExpression {
constant = !(boolean)child.constant;
}
actual = Definition.booleanType;
actual = Definition.BOOLEAN_TYPE;
}
void analyzeBWNot(final CompilerSettings settings, final Variables variables) {
@ -191,7 +191,7 @@ public final class EUnary extends AExpression {
if (operation == Operation.BWNOT) {
if (sort == Sort.DEF) {
adapter.invokeStatic(Definition.defobjType.type, DEF_NOT_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_NOT_CALL);
} else {
if (sort == Sort.INT) {
adapter.push(-1);
@ -205,7 +205,7 @@ public final class EUnary extends AExpression {
}
} else if (operation == Operation.SUB) {
if (sort == Sort.DEF) {
adapter.invokeStatic(Definition.defobjType.type, DEF_NEG_CALL);
adapter.invokeStatic(Definition.DEF_UTIL_TYPE.type, DEF_NEG_CALL);
} else {
adapter.math(MethodWriter.NEG, type);
}

View File

@ -46,7 +46,7 @@ public final class LArrayLength extends ALink {
throw new IllegalArgumentException(error("Cannot write to read-only array field [length]."));
}
after = Definition.intType;
after = Definition.INT_TYPE;
} else {
throw new IllegalArgumentException(error("Illegal field access [" + value + "]."));
}

View File

@ -50,7 +50,7 @@ public final class LBrace extends ALink {
final Sort sort = before.sort;
if (sort == Sort.ARRAY) {
index.expected = Definition.intType;
index.expected = Definition.INT_TYPE;
index.analyze(settings, variables);
index = index.cast(settings, variables);

View File

@ -47,7 +47,7 @@ final class LDefArray extends ALink implements IDefLink {
index.expected = index.actual;
index = index.cast(settings, variables);
after = Definition.defType;
after = Definition.DEF_TYPE;
return this;
}
@ -59,13 +59,13 @@ final class LDefArray extends ALink implements IDefLink {
@Override
void load(final CompilerSettings settings, final MethodWriter adapter) {
final String desc = Type.getMethodDescriptor(after.type, Definition.defType.type, index.actual.type);
final String desc = Type.getMethodDescriptor(after.type, Definition.DEF_TYPE.type, index.actual.type);
adapter.invokeDynamic("arrayLoad", desc, DEF_BOOTSTRAP_HANDLE, DefBootstrap.ARRAY_LOAD);
}
@Override
void store(final CompilerSettings settings, final MethodWriter adapter) {
final String desc = Type.getMethodDescriptor(Definition.voidType.type, Definition.defType.type,
final String desc = Type.getMethodDescriptor(Definition.VOID_TYPE.type, Definition.DEF_TYPE.type,
index.actual.type, after.type);
adapter.invokeDynamic("arrayStore", desc, DEF_BOOTSTRAP_HANDLE, DefBootstrap.ARRAY_STORE);
}

View File

@ -55,7 +55,7 @@ final class LDefCall extends ALink implements IDefLink {
}
statement = true;
after = Definition.defType;
after = Definition.DEF_TYPE;
return this;
}
@ -71,7 +71,7 @@ final class LDefCall extends ALink implements IDefLink {
signature.append('(');
// first parameter is the receiver, we never know its type: always Object
signature.append(Definition.defType.type.getDescriptor());
signature.append(Definition.DEF_TYPE.type.getDescriptor());
// TODO: remove our explicit conversions and feed more type information for return value,
// it can avoid some unnecessary boxing etc.

View File

@ -44,7 +44,7 @@ final class LDefField extends ALink implements IDefLink {
@Override
ALink analyze(final CompilerSettings settings, final Variables variables) {
after = Definition.defType;
after = Definition.DEF_TYPE;
return this;
}
@ -56,13 +56,13 @@ final class LDefField extends ALink implements IDefLink {
@Override
void load(final CompilerSettings settings, final MethodWriter adapter) {
final String desc = Type.getMethodDescriptor(after.type, Definition.defType.type);
final String desc = Type.getMethodDescriptor(after.type, Definition.DEF_TYPE.type);
adapter.invokeDynamic(value, desc, DEF_BOOTSTRAP_HANDLE, DefBootstrap.LOAD);
}
@Override
void store(final CompilerSettings settings, final MethodWriter adapter) {
final String desc = Type.getMethodDescriptor(Definition.voidType.type, Definition.defType.type, after.type);
final String desc = Type.getMethodDescriptor(Definition.VOID_TYPE.type, Definition.DEF_TYPE.type, after.type);
adapter.invokeDynamic(value, desc, DEF_BOOTSTRAP_HANDLE, DefBootstrap.STORE);
}
}

View File

@ -61,7 +61,7 @@ final class LListShortcut extends ALink {
}
if ((load || store) && (!load || getter != null) && (!store || setter != null)) {
index.expected = Definition.intType;
index.expected = Definition.INT_TYPE;
index.analyze(settings, variables);
index = index.cast(settings, variables);

View File

@ -63,7 +63,7 @@ public final class LNewArray extends ALink {
for (int argument = 0; argument < arguments.size(); ++argument) {
final AExpression expression = arguments.get(argument);
expression.expected = Definition.intType;
expression.expected = Definition.INT_TYPE;
expression.analyze(settings, variables);
arguments.set(argument, expression.cast(settings, variables));
}

View File

@ -45,7 +45,7 @@ public final class LString extends ALink {
throw new IllegalArgumentException(error("Must read String constant [" + string + "]."));
}
after = Definition.stringType;
after = Definition.STRING_TYPE;
return this;
}

View File

@ -53,7 +53,7 @@ public final class SDo extends AStatement {
throw new IllegalArgumentException(error("Extraneous do while loop."));
}
condition.expected = Definition.booleanType;
condition.expected = Definition.BOOLEAN_TYPE;
condition.analyze(settings, variables);
condition = condition.cast(settings, variables);

View File

@ -49,7 +49,7 @@ public final class SExpression extends AStatement {
final boolean rtn = lastSource && expression.actual.sort != Sort.VOID;
expression.expected = rtn ? Definition.objectType : expression.actual;
expression.expected = rtn ? Definition.OBJECT_TYPE : expression.actual;
expression = expression.cast(settings, variables);
methodEscape = rtn;

View File

@ -70,7 +70,7 @@ public final class SFor extends AStatement {
if (condition != null) {
condition.expected = Definition.booleanType;
condition.expected = Definition.BOOLEAN_TYPE;
condition.analyze(settings, variables);
condition = condition.cast(settings, variables);

View File

@ -45,7 +45,7 @@ public final class SIfElse extends AStatement {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
condition.expected = Definition.booleanType;
condition.expected = Definition.BOOLEAN_TYPE;
condition.analyze(settings, variables);
condition = condition.cast(settings, variables);

View File

@ -39,7 +39,7 @@ public final class SReturn extends AStatement {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
expression.expected = Definition.objectType;
expression.expected = Definition.OBJECT_TYPE;
expression.analyze(settings, variables);
expression = expression.cast(settings, variables);

View File

@ -39,7 +39,7 @@ public final class SThrow extends AStatement {
@Override
void analyze(final CompilerSettings settings, final Variables variables) {
expression.expected = Definition.exceptionType;
expression.expected = Definition.EXCEPTION_TYPE;
expression.analyze(settings, variables);
expression = expression.cast(settings, variables);

View File

@ -44,7 +44,7 @@ public final class SWhile extends AStatement {
void analyze(final CompilerSettings settings, final Variables variables) {
variables.incrementScope();
condition.expected = Definition.booleanType;
condition.expected = Definition.BOOLEAN_TYPE;
condition.analyze(settings, variables);
condition = condition.cast(settings, variables);