diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java index 827c268793a..6e38bf2b7a4 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java @@ -47,28 +47,28 @@ public final class Definition { public static final Definition INSTANCE = new Definition(new Definition()); /** Some native types as constants: */ + public static final Type voidType = INSTANCE.getType("void"); public static final Type booleanType = INSTANCE.getType("boolean"); - public static final Type objectType = INSTANCE.getType("Object"); - public static final Type defType = INSTANCE.getType("def"); public static final Type booleanobjType = INSTANCE.getType("Boolean"); public static final Type byteType = INSTANCE.getType("byte"); - public static final Type shortType = INSTANCE.getType("short"); - public static final Type intType = INSTANCE.getType("int"); - public static final Type charType = INSTANCE.getType("char"); - public static final Type longType = INSTANCE.getType("long"); - public static final Type floatType = INSTANCE.getType("float"); - public static final Type doubleType = INSTANCE.getType("double"); - public static final Type numberType = INSTANCE.getType("Number"); public static final Type byteobjType = INSTANCE.getType("Byte"); + public static final Type shortType = INSTANCE.getType("short"); public static final Type shortobjType = INSTANCE.getType("Short"); - public static final Type charobjType = INSTANCE.getType("Character"); + public static final Type intType = INSTANCE.getType("int"); public static final Type intobjType = INSTANCE.getType("Integer"); + public static final Type longType = INSTANCE.getType("long"); public static final Type longobjType = INSTANCE.getType("Long"); + public static final Type floatType = INSTANCE.getType("float"); public static final Type floatobjType = INSTANCE.getType("Float"); + public static final Type doubleType = INSTANCE.getType("double"); public static final Type doubleobjType = INSTANCE.getType("Double"); + public static final Type charType = INSTANCE.getType("char"); + public static final Type charobjType = INSTANCE.getType("Character"); + public static final Type objectType = INSTANCE.getType("Object"); + public static final Type defType = INSTANCE.getType("def"); + public static final Type defobjType = INSTANCE.getType("Def"); public static final Type stringType = INSTANCE.getType("String"); public static final Type exceptionType = INSTANCE.getType("Exception"); - public static final Type voidType = INSTANCE.getType("void"); public enum Sort { VOID( void.class , 0 , true , false , false , false ), diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/MethodWriter.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/MethodWriter.java index cda8c23e3bf..ce1bb531655 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/MethodWriter.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/MethodWriter.java @@ -214,17 +214,17 @@ public final class MethodWriter extends GeneratorAdapter { if (sort == Sort.DEF) { switch (operation) { - case MUL: invokeStatic(definition.getType("Def").type, DEF_MUL_CALL); break; - case DIV: invokeStatic(definition.getType("Def").type, DEF_DIV_CALL); break; - case REM: invokeStatic(definition.getType("Def").type, DEF_REM_CALL); break; - case ADD: invokeStatic(definition.getType("Def").type, DEF_ADD_CALL); break; - case SUB: invokeStatic(definition.getType("Def").type, DEF_SUB_CALL); break; - case LSH: invokeStatic(definition.getType("Def").type, DEF_LSH_CALL); break; - case USH: invokeStatic(definition.getType("Def").type, DEF_RSH_CALL); break; - case RSH: invokeStatic(definition.getType("Def").type, DEF_USH_CALL); break; - case BWAND: invokeStatic(definition.getType("Def").type, DEF_AND_CALL); break; - case XOR: invokeStatic(definition.getType("Def").type, DEF_XOR_CALL); break; - case BWOR: invokeStatic(definition.getType("Def").type, DEF_OR_CALL); break; + 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; default: throw new IllegalStateException("Error " + location + ": Illegal tree structure."); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EComp.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EComp.java index 0d781abf9b7..9d7862e404a 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EComp.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EComp.java @@ -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.getType("Def").type, DEF_EQ_CALL); + adapter.invokeStatic(Definition.defobjType.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.getType("Def").type, DEF_EQ_CALL); + adapter.invokeStatic(Definition.defobjType.type, DEF_EQ_CALL); adapter.ifZCmp(MethodWriter.EQ, jump); } else { adapter.ifCmp(rtype, MethodWriter.NE, jump); } } else if (lt) { - adapter.invokeStatic(definition.getType("Def").type, DEF_LT_CALL); + adapter.invokeStatic(Definition.defobjType.type, DEF_LT_CALL); } else if (lte) { - adapter.invokeStatic(definition.getType("Def").type, DEF_LTE_CALL); + adapter.invokeStatic(Definition.defobjType.type, DEF_LTE_CALL); } else if (gt) { - adapter.invokeStatic(definition.getType("Def").type, DEF_GT_CALL); + adapter.invokeStatic(Definition.defobjType.type, DEF_GT_CALL); } else if (gte) { - adapter.invokeStatic(definition.getType("Def").type, DEF_GTE_CALL); + adapter.invokeStatic(Definition.defobjType.type, DEF_GTE_CALL); } else { throw new IllegalStateException(error("Illegal tree structure.")); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EUnary.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EUnary.java index 11694c344f7..627eb85e968 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EUnary.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EUnary.java @@ -191,7 +191,7 @@ public final class EUnary extends AExpression { if (operation == Operation.BWNOT) { if (sort == Sort.DEF) { - adapter.invokeStatic(definition.getType("Def").type, DEF_NOT_CALL); + adapter.invokeStatic(Definition.defobjType.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.getType("Def").type, DEF_NEG_CALL); + adapter.invokeStatic(Definition.defobjType.type, DEF_NEG_CALL); } else { adapter.math(MethodWriter.NEG, type); }