List of usage examples for org.objectweb.asm.commons GeneratorAdapter AND
int AND
To view the source code for org.objectweb.asm.commons GeneratorAdapter AND.
Click Source Link
From source file:org.elasticsearch.painless.MethodWriter.java
License:Apache License
/** Writes a static binary instruction */ public void writeBinaryInstruction(Location location, Type type, Operation operation) { final Sort sort = type.sort; if ((sort == Sort.FLOAT || sort == Sort.DOUBLE) && (operation == Operation.LSH || operation == Operation.USH || operation == Operation.RSH || operation == Operation.BWAND || operation == Operation.XOR || operation == Operation.BWOR)) { throw location.createError(new IllegalStateException("Illegal tree structure.")); }/* ww w . j av a2 s. c o m*/ switch (operation) { case MUL: math(GeneratorAdapter.MUL, type.type); break; case DIV: math(GeneratorAdapter.DIV, type.type); break; case REM: math(GeneratorAdapter.REM, type.type); break; case ADD: math(GeneratorAdapter.ADD, type.type); break; case SUB: math(GeneratorAdapter.SUB, type.type); break; case LSH: math(GeneratorAdapter.SHL, type.type); break; case USH: math(GeneratorAdapter.USHR, type.type); break; case RSH: math(GeneratorAdapter.SHR, type.type); break; case BWAND: math(GeneratorAdapter.AND, type.type); break; case XOR: math(GeneratorAdapter.XOR, type.type); break; case BWOR: math(GeneratorAdapter.OR, type.type); break; default: throw location.createError(new IllegalStateException("Illegal tree structure.")); } }
From source file:org.elasticsearch.painless.Writer.java
License:Apache License
private void writeBinaryInstruction(final ParserRuleContext source, final Type type, final int token) { final Sort sort = type.sort; final boolean exact = !settings.getNumericOverflow() && ((sort == Sort.INT || sort == Sort.LONG) && (token == MUL || token == DIV || token == ADD || token == SUB) || (sort == Sort.FLOAT || sort == Sort.DOUBLE) && (token == MUL || token == DIV || token == REM || token == ADD || token == SUB)); // if its a 64-bit shift, fixup the lastSource argument to truncate to 32-bits // note unlike java, this means we still do binary promotion of shifts, // but it keeps things simple -- this check works because we promote shifts. if (sort == Sort.LONG && (token == LSH || token == USH || token == RSH)) { execute.cast(org.objectweb.asm.Type.LONG_TYPE, org.objectweb.asm.Type.INT_TYPE); }/* w ww.jav a 2s. c o m*/ if (exact) { switch (sort) { case INT: switch (token) { case MUL: execute.invokeStatic(definition.mathType.type, MULEXACT_INT); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_INT); break; case ADD: execute.invokeStatic(definition.mathType.type, ADDEXACT_INT); break; case SUB: execute.invokeStatic(definition.mathType.type, SUBEXACT_INT); break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } break; case LONG: switch (token) { case MUL: execute.invokeStatic(definition.mathType.type, MULEXACT_LONG); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_LONG); break; case ADD: execute.invokeStatic(definition.mathType.type, ADDEXACT_LONG); break; case SUB: execute.invokeStatic(definition.mathType.type, SUBEXACT_LONG); break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } break; case FLOAT: switch (token) { case MUL: execute.invokeStatic(definition.utilityType.type, MULWOOVERLOW_FLOAT); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_FLOAT); break; case REM: execute.invokeStatic(definition.utilityType.type, REMWOOVERLOW_FLOAT); break; case ADD: execute.invokeStatic(definition.utilityType.type, ADDWOOVERLOW_FLOAT); break; case SUB: execute.invokeStatic(definition.utilityType.type, SUBWOOVERLOW_FLOAT); break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } break; case DOUBLE: switch (token) { case MUL: execute.invokeStatic(definition.utilityType.type, MULWOOVERLOW_DOUBLE); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_DOUBLE); break; case REM: execute.invokeStatic(definition.utilityType.type, REMWOOVERLOW_DOUBLE); break; case ADD: execute.invokeStatic(definition.utilityType.type, ADDWOOVERLOW_DOUBLE); break; case SUB: execute.invokeStatic(definition.utilityType.type, SUBWOOVERLOW_DOUBLE); break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } } else { if ((sort == Sort.FLOAT || sort == Sort.DOUBLE) && (token == LSH || token == USH || token == RSH || token == BWAND || token == BWXOR || token == BWOR)) { throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } if (sort == Sort.DEF) { switch (token) { case MUL: execute.invokeStatic(definition.defobjType.type, DEF_MUL_CALL); break; case DIV: execute.invokeStatic(definition.defobjType.type, DEF_DIV_CALL); break; case REM: execute.invokeStatic(definition.defobjType.type, DEF_REM_CALL); break; case ADD: execute.invokeStatic(definition.defobjType.type, DEF_ADD_CALL); break; case SUB: execute.invokeStatic(definition.defobjType.type, DEF_SUB_CALL); break; case LSH: execute.invokeStatic(definition.defobjType.type, DEF_LSH_CALL); break; case USH: execute.invokeStatic(definition.defobjType.type, DEF_RSH_CALL); break; case RSH: execute.invokeStatic(definition.defobjType.type, DEF_USH_CALL); break; case BWAND: execute.invokeStatic(definition.defobjType.type, DEF_AND_CALL); break; case BWXOR: execute.invokeStatic(definition.defobjType.type, DEF_XOR_CALL); break; case BWOR: execute.invokeStatic(definition.defobjType.type, DEF_OR_CALL); break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } } else { switch (token) { case MUL: execute.math(GeneratorAdapter.MUL, type.type); break; case DIV: execute.math(GeneratorAdapter.DIV, type.type); break; case REM: execute.math(GeneratorAdapter.REM, type.type); break; case ADD: execute.math(GeneratorAdapter.ADD, type.type); break; case SUB: execute.math(GeneratorAdapter.SUB, type.type); break; case LSH: execute.math(GeneratorAdapter.SHL, type.type); break; case USH: execute.math(GeneratorAdapter.USHR, type.type); break; case RSH: execute.math(GeneratorAdapter.SHR, type.type); break; case BWAND: execute.math(GeneratorAdapter.AND, type.type); break; case BWXOR: execute.math(GeneratorAdapter.XOR, type.type); break; case BWOR: execute.math(GeneratorAdapter.OR, type.type); break; default: throw new IllegalStateException(Metadata.error(source) + "Unexpected writer state."); } } } }
From source file:org.elasticsearch.painless.WriterUtility.java
License:Apache License
void writeBinaryInstruction(final ParserRuleContext source, final Type type, final int token) { final Sort sort = type.sort; final boolean exact = !settings.getNumericOverflow() && ((sort == Sort.INT || sort == Sort.LONG) && (token == MUL || token == DIV || token == ADD || token == SUB) || (sort == Sort.FLOAT || sort == Sort.DOUBLE) && (token == MUL || token == DIV || token == REM || token == ADD || token == SUB)); // If it's a 64-bit shift, fix-up the last argument to truncate to 32-bits. // Note that unlike java, this means we still do binary promotion of shifts, // but it keeps things simple, and this check works because we promote shifts. if (sort == Sort.LONG && (token == LSH || token == USH || token == RSH)) { execute.cast(org.objectweb.asm.Type.LONG_TYPE, org.objectweb.asm.Type.INT_TYPE); }/*from w w w. j a v a 2 s .com*/ if (exact) { switch (sort) { case INT: switch (token) { case MUL: execute.invokeStatic(definition.mathType.type, MULEXACT_INT); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_INT); break; case ADD: execute.invokeStatic(definition.mathType.type, ADDEXACT_INT); break; case SUB: execute.invokeStatic(definition.mathType.type, SUBEXACT_INT); break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } break; case LONG: switch (token) { case MUL: execute.invokeStatic(definition.mathType.type, MULEXACT_LONG); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_LONG); break; case ADD: execute.invokeStatic(definition.mathType.type, ADDEXACT_LONG); break; case SUB: execute.invokeStatic(definition.mathType.type, SUBEXACT_LONG); break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } break; case FLOAT: switch (token) { case MUL: execute.invokeStatic(definition.utilityType.type, MULWOOVERLOW_FLOAT); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_FLOAT); break; case REM: execute.invokeStatic(definition.utilityType.type, REMWOOVERLOW_FLOAT); break; case ADD: execute.invokeStatic(definition.utilityType.type, ADDWOOVERLOW_FLOAT); break; case SUB: execute.invokeStatic(definition.utilityType.type, SUBWOOVERLOW_FLOAT); break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } break; case DOUBLE: switch (token) { case MUL: execute.invokeStatic(definition.utilityType.type, MULWOOVERLOW_DOUBLE); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_DOUBLE); break; case REM: execute.invokeStatic(definition.utilityType.type, REMWOOVERLOW_DOUBLE); break; case ADD: execute.invokeStatic(definition.utilityType.type, ADDWOOVERLOW_DOUBLE); break; case SUB: execute.invokeStatic(definition.utilityType.type, SUBWOOVERLOW_DOUBLE); break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } } else { if ((sort == Sort.FLOAT || sort == Sort.DOUBLE) && (token == LSH || token == USH || token == RSH || token == BWAND || token == BWXOR || token == BWOR)) { throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } if (sort == Sort.DEF) { switch (token) { case MUL: execute.invokeStatic(definition.defobjType.type, DEF_MUL_CALL); break; case DIV: execute.invokeStatic(definition.defobjType.type, DEF_DIV_CALL); break; case REM: execute.invokeStatic(definition.defobjType.type, DEF_REM_CALL); break; case ADD: execute.invokeStatic(definition.defobjType.type, DEF_ADD_CALL); break; case SUB: execute.invokeStatic(definition.defobjType.type, DEF_SUB_CALL); break; case LSH: execute.invokeStatic(definition.defobjType.type, DEF_LSH_CALL); break; case USH: execute.invokeStatic(definition.defobjType.type, DEF_RSH_CALL); break; case RSH: execute.invokeStatic(definition.defobjType.type, DEF_USH_CALL); break; case BWAND: execute.invokeStatic(definition.defobjType.type, DEF_AND_CALL); break; case BWXOR: execute.invokeStatic(definition.defobjType.type, DEF_XOR_CALL); break; case BWOR: execute.invokeStatic(definition.defobjType.type, DEF_OR_CALL); break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } } else { switch (token) { case MUL: execute.math(GeneratorAdapter.MUL, type.type); break; case DIV: execute.math(GeneratorAdapter.DIV, type.type); break; case REM: execute.math(GeneratorAdapter.REM, type.type); break; case ADD: execute.math(GeneratorAdapter.ADD, type.type); break; case SUB: execute.math(GeneratorAdapter.SUB, type.type); break; case LSH: execute.math(GeneratorAdapter.SHL, type.type); break; case USH: execute.math(GeneratorAdapter.USHR, type.type); break; case RSH: execute.math(GeneratorAdapter.SHR, type.type); break; case BWAND: execute.math(GeneratorAdapter.AND, type.type); break; case BWXOR: execute.math(GeneratorAdapter.XOR, type.type); break; case BWOR: execute.math(GeneratorAdapter.OR, type.type); break; default: throw new IllegalStateException(WriterUtility.error(source) + "Unexpected state."); } } } }
From source file:org.elasticsearch.plan.a.Writer.java
License:Apache License
private void writeBinaryInstruction(final ParserRuleContext source, final Type type, final int token) { final Sort sort = type.sort; final boolean exact = !settings.getNumericOverflow() && ((sort == Sort.INT || sort == Sort.LONG) && (token == MUL || token == DIV || token == ADD || token == SUB) || (sort == Sort.FLOAT || sort == Sort.DOUBLE) && (token == MUL || token == DIV || token == REM || token == ADD || token == SUB)); // if its a 64-bit shift, fixup the lastSource argument to truncate to 32-bits // note unlike java, this means we still do binary promotion of shifts, // but it keeps things simple -- this check works because we promote shifts. if (sort == Sort.LONG && (token == LSH || token == USH || token == RSH)) { execute.cast(org.objectweb.asm.Type.LONG_TYPE, org.objectweb.asm.Type.INT_TYPE); }//www .j a v a 2 s. co m if (exact) { switch (sort) { case INT: switch (token) { case MUL: execute.invokeStatic(definition.mathType.type, MULEXACT_INT); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_INT); break; case ADD: execute.invokeStatic(definition.mathType.type, ADDEXACT_INT); break; case SUB: execute.invokeStatic(definition.mathType.type, SUBEXACT_INT); break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } break; case LONG: switch (token) { case MUL: execute.invokeStatic(definition.mathType.type, MULEXACT_LONG); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_LONG); break; case ADD: execute.invokeStatic(definition.mathType.type, ADDEXACT_LONG); break; case SUB: execute.invokeStatic(definition.mathType.type, SUBEXACT_LONG); break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } break; case FLOAT: switch (token) { case MUL: execute.invokeStatic(definition.utilityType.type, MULWOOVERLOW_FLOAT); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_FLOAT); break; case REM: execute.invokeStatic(definition.utilityType.type, REMWOOVERLOW_FLOAT); break; case ADD: execute.invokeStatic(definition.utilityType.type, ADDWOOVERLOW_FLOAT); break; case SUB: execute.invokeStatic(definition.utilityType.type, SUBWOOVERLOW_FLOAT); break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } break; case DOUBLE: switch (token) { case MUL: execute.invokeStatic(definition.utilityType.type, MULWOOVERLOW_DOUBLE); break; case DIV: execute.invokeStatic(definition.utilityType.type, DIVWOOVERLOW_DOUBLE); break; case REM: execute.invokeStatic(definition.utilityType.type, REMWOOVERLOW_DOUBLE); break; case ADD: execute.invokeStatic(definition.utilityType.type, ADDWOOVERLOW_DOUBLE); break; case SUB: execute.invokeStatic(definition.utilityType.type, SUBWOOVERLOW_DOUBLE); break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } } else { if ((sort == Sort.FLOAT || sort == Sort.DOUBLE) && (token == LSH || token == USH || token == RSH || token == BWAND || token == BWXOR || token == BWOR)) { throw new IllegalStateException(error(source) + "Unexpected writer state."); } if (sort == Sort.DEF) { switch (token) { case MUL: execute.invokeStatic(definition.defobjType.type, DEF_MUL_CALL); break; case DIV: execute.invokeStatic(definition.defobjType.type, DEF_DIV_CALL); break; case REM: execute.invokeStatic(definition.defobjType.type, DEF_REM_CALL); break; case ADD: execute.invokeStatic(definition.defobjType.type, DEF_ADD_CALL); break; case SUB: execute.invokeStatic(definition.defobjType.type, DEF_SUB_CALL); break; case LSH: execute.invokeStatic(definition.defobjType.type, DEF_LSH_CALL); break; case USH: execute.invokeStatic(definition.defobjType.type, DEF_RSH_CALL); break; case RSH: execute.invokeStatic(definition.defobjType.type, DEF_USH_CALL); break; case BWAND: execute.invokeStatic(definition.defobjType.type, DEF_AND_CALL); break; case BWXOR: execute.invokeStatic(definition.defobjType.type, DEF_XOR_CALL); break; case BWOR: execute.invokeStatic(definition.defobjType.type, DEF_OR_CALL); break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } } else { switch (token) { case MUL: execute.math(GeneratorAdapter.MUL, type.type); break; case DIV: execute.math(GeneratorAdapter.DIV, type.type); break; case REM: execute.math(GeneratorAdapter.REM, type.type); break; case ADD: execute.math(GeneratorAdapter.ADD, type.type); break; case SUB: execute.math(GeneratorAdapter.SUB, type.type); break; case LSH: execute.math(GeneratorAdapter.SHL, type.type); break; case USH: execute.math(GeneratorAdapter.USHR, type.type); break; case RSH: execute.math(GeneratorAdapter.SHR, type.type); break; case BWAND: execute.math(GeneratorAdapter.AND, type.type); break; case BWXOR: execute.math(GeneratorAdapter.XOR, type.type); break; case BWOR: execute.math(GeneratorAdapter.OR, type.type); break; default: throw new IllegalStateException(error(source) + "Unexpected writer state."); } } } }