Java Code Examples for jdk.internal.org.objectweb.asm.type#CHAR_TYPE

The following examples show how to use jdk.internal.org.objectweb.asm.type#CHAR_TYPE . 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: ASMToolkit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Type toType(ValueDescriptor v) {
    String typeName = v.getTypeName();

    switch (typeName) {
    case "byte":
        return Type.BYTE_TYPE;
    case "short":
        return Type.SHORT_TYPE;
    case "int":
        return Type.INT_TYPE;
    case "long":
        return Type.LONG_TYPE;
    case "double":
        return Type.DOUBLE_TYPE;
    case "float":
        return Type.FLOAT_TYPE;
    case "char":
        return Type.CHAR_TYPE;
    case "boolean":
        return Type.BOOLEAN_TYPE;
    case "java.lang.String":
        return TYPE_STRING;
    case "java.lang.Thread":
        return Type_THREAD;
    case "java.lang.Class":
        return TYPE_CLASS;
    }
    // Add support for SettingControl?
   throw new Error("Not a valid type " + v.getTypeName());
}
 
Example 2
Source File: ASMToolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static Type toType(ValueDescriptor v) {
    String typeName = v.getTypeName();

    switch (typeName) {
    case "byte":
        return Type.BYTE_TYPE;
    case "short":
        return Type.SHORT_TYPE;
    case "int":
        return Type.INT_TYPE;
    case "long":
        return Type.LONG_TYPE;
    case "double":
        return Type.DOUBLE_TYPE;
    case "float":
        return Type.FLOAT_TYPE;
    case "char":
        return Type.CHAR_TYPE;
    case "boolean":
        return Type.BOOLEAN_TYPE;
    case "java.lang.String":
        return TYPE_STRING;
    case "java.lang.Thread":
        return Type_THREAD;
    case "java.lang.Class":
        return TYPE_CLASS;
    }
    // Add support for SettingControl?
   throw new Error("Not a valid type " + v.getTypeName());
}
 
Example 3
Source File: GeneratorAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 4
Source File: InstructionAdapter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 5
Source File: GeneratorAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 6
Source File: InstructionAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 7
Source File: GeneratorAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 8
Source File: GeneratorAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 9
Source File: GeneratorAdapter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
  * Generates the instructions to cast a numerical value from one type to another.
  *
  * @param from the type of the top stack value
  * @param to the type into which this value must be cast.
  */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from.getSort() < Type.BOOLEAN
                || from.getSort() > Type.DOUBLE
                || to.getSort() < Type.BOOLEAN
                || to.getSort() > Type.DOUBLE) {
            throw new IllegalArgumentException("Cannot cast from " + from + " to " + to);
        }
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 10
Source File: InstructionAdapter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
  * Generates the instruction to cast from the first given type to the other.
  *
  * @param from a Type.
  * @param to a Type.
  */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 11
Source File: InstructionAdapter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 12
Source File: InstructionAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 13
Source File: GeneratorAdapter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 14
Source File: GeneratorAdapter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 15
Source File: GeneratorAdapter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 16
Source File: InstructionAdapter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 17
Source File: InstructionAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 18
Source File: InstructionAdapter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 19
Source File: GeneratorAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from
 *            the type of the top stack value
 * @param to
 *            the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}
 
Example 20
Source File: GeneratorAdapter.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to cast a numerical value from one type to
 * another.
 *
 * @param from the type of the top stack value
 * @param to the type into which this value must be cast.
 */
public void cast(final Type from, final Type to) {
    if (from != to) {
        if (from == Type.DOUBLE_TYPE) {
            if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.D2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.D2L);
            } else {
                mv.visitInsn(Opcodes.D2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.FLOAT_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.F2D);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.F2L);
            } else {
                mv.visitInsn(Opcodes.F2I);
                cast(Type.INT_TYPE, to);
            }
        } else if (from == Type.LONG_TYPE) {
            if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.L2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.L2F);
            } else {
                mv.visitInsn(Opcodes.L2I);
                cast(Type.INT_TYPE, to);
            }
        } else {
            if (to == Type.BYTE_TYPE) {
                mv.visitInsn(Opcodes.I2B);
            } else if (to == Type.CHAR_TYPE) {
                mv.visitInsn(Opcodes.I2C);
            } else if (to == Type.DOUBLE_TYPE) {
                mv.visitInsn(Opcodes.I2D);
            } else if (to == Type.FLOAT_TYPE) {
                mv.visitInsn(Opcodes.I2F);
            } else if (to == Type.LONG_TYPE) {
                mv.visitInsn(Opcodes.I2L);
            } else if (to == Type.SHORT_TYPE) {
                mv.visitInsn(Opcodes.I2S);
            }
        }
    }
}