com.sun.tools.javac.jvm.ByteCodes Java Examples

The following examples show how to use com.sun.tools.javac.jvm.ByteCodes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Symtab.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/** Enter a binary operation, as above but with two opcodes,
 *  which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
 *  @param opcode1     First opcode.
 *  @param opcode2     Second opcode.
 */
private void enterBinop(String name,
                        Type left, Type right, Type res,
                        int opcode1, int opcode2) {
    enterBinop(
        name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
}
 
Example #2
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 *  Check for division by integer constant zero
 *  @param pos           Position for error reporting.
 *  @param operator      The operator for the expression
 *  @param operand       The right hand operand for the expression
 */
void checkDivZero(final DiagnosticPosition pos, Symbol operator, Type operand) {
    if (operand.constValue() != null
        && operand.getTag().isSubRangeOf(LONG)
        && ((Number) (operand.constValue())).longValue() == 0) {
        int opc = ((OperatorSymbol)operator).opcode;
        if (opc == ByteCodes.idiv || opc == ByteCodes.imod
            || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) {
            deferredLintHandler.report(() -> warnDivZero(pos));
        }
    }
}
 
Example #3
Source File: Lower.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Return tree tag for assignment operation corresponding
 *  to given binary operator.
 */
private static JCTree.Tag treeTag(OperatorSymbol operator) {
    switch (operator.opcode) {
    case ByteCodes.ior: case ByteCodes.lor:
        return BITOR_ASG;
    case ByteCodes.ixor: case ByteCodes.lxor:
        return BITXOR_ASG;
    case ByteCodes.iand: case ByteCodes.land:
        return BITAND_ASG;
    case ByteCodes.ishl: case ByteCodes.lshl:
    case ByteCodes.ishll: case ByteCodes.lshll:
        return SL_ASG;
    case ByteCodes.ishr: case ByteCodes.lshr:
    case ByteCodes.ishrl: case ByteCodes.lshrl:
        return SR_ASG;
    case ByteCodes.iushr: case ByteCodes.lushr:
    case ByteCodes.iushrl: case ByteCodes.lushrl:
        return USR_ASG;
    case ByteCodes.iadd: case ByteCodes.ladd:
    case ByteCodes.fadd: case ByteCodes.dadd:
    case ByteCodes.string_add:
        return PLUS_ASG;
    case ByteCodes.isub: case ByteCodes.lsub:
    case ByteCodes.fsub: case ByteCodes.dsub:
        return MINUS_ASG;
    case ByteCodes.imul: case ByteCodes.lmul:
    case ByteCodes.fmul: case ByteCodes.dmul:
        return MUL_ASG;
    case ByteCodes.idiv: case ByteCodes.ldiv:
    case ByteCodes.fdiv: case ByteCodes.ddiv:
        return DIV_ASG;
    case ByteCodes.imod: case ByteCodes.lmod:
    case ByteCodes.fmod: case ByteCodes.dmod:
        return MOD_ASG;
    default:
        throw new AssertionError();
    }
}
 
Example #4
Source File: Operators.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Fold two opcodes in a single int value (if required).
 */
private int mergeOpcodes(int... opcodes) {
    int opcodesLen = opcodes.length;
    Assert.check(opcodesLen == 1 || opcodesLen == 2);
    return (opcodesLen == 1) ?
            opcodes[0] :
            ((opcodes[0] << ByteCodes.preShift) | opcodes[1]);
}
 
Example #5
Source File: Symtab.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/** Enter a binary operation, as above but with two opcodes,
 *  which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
 *  @param opcode1     First opcode.
 *  @param opcode2     Second opcode.
 */
private void enterBinop(String name,
                        Type left, Type right, Type res,
                        int opcode1, int opcode2) {
    enterBinop(
        name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
}
 
Example #6
Source File: Operators.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fold two opcodes in a single int value (if required).
 */
private int mergeOpcodes(int... opcodes) {
    int opcodesLen = opcodes.length;
    Assert.check(opcodesLen == 1 || opcodesLen == 2);
    return (opcodesLen == 1) ?
            opcodes[0] :
            ((opcodes[0] << ByteCodes.preShift) | opcodes[1]);
}
 
Example #7
Source File: OverloadOperatorSymbol.java    From manifold with Apache License 2.0 5 votes vote down vote up
OverloadOperatorSymbol( MethodSymbol m, boolean swapped )
{
  super( m.name, m.type, ByteCodes.nop, m.owner );
  ReflectUtil.field( this, "flags_field" ).set( m.flags() );
  _methodSymbol = m;
  _swapped = swapped;
}
 
Example #8
Source File: OverloadOperatorSymbol.java    From manifold with Apache License 2.0 5 votes vote down vote up
OverloadOperatorSymbol( MethodSymbol m, Type.MethodType fakeType, boolean swapped )
{
  super( m.name, fakeType, ByteCodes.nop, m.owner );
  ReflectUtil.field( this, "flags_field" ).set( m.flags() );
  _methodSymbol = m;
  _swapped = swapped;
}