當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneratorAdapter.cast方法代碼示例

本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.cast方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.cast方法的具體用法?Java GeneratorAdapter.cast怎麽用?Java GeneratorAdapter.cast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.commons.GeneratorAdapter的用法示例。


在下文中一共展示了GeneratorAdapter.cast方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadArguments

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null, !null -> fail")
private static void loadArguments(GeneratorAdapter ga, Type[] interfaceTypes, Type[] targetTypes, boolean isTargetPublic) {
    Ensure.ensureCondition(interfaceTypes.length == targetTypes.length,
            "Interface and target parameter count don't match!");
    /* Iterate through all types */
    for(int i = 0; i < interfaceTypes.length; i++) {
        Type interfaceType = interfaceTypes[i];
        Type targetType = targetTypes[i];

        ga.loadArg(i);

        /* Do not do boxing/unboxing if MethodHandle.invoke is used, it handles them on its own */
        if(!isTargetPublic) continue;

        if(isPrimitive(interfaceType)) {
            if(!isPrimitive(targetType)) {
                ga.box(targetType);
            }
        } else {
            if(isPrimitive(targetType)) {
                ga.unbox(targetType);
            } else {
                if(interfaceType.equals(OBJECT)) {
                    ga.checkCast(targetType);
                    ga.cast(interfaceType, targetType);
                }
            }
        }
    }
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:31,代碼來源:MethodGenerator.java

示例2: emitExprForInts

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitExprForInts(ObjExpr objx, GeneratorAdapter gen, Type exprType, Label defaultLabel){
    if (exprType == null)
        {
        if(RT.booleanCast(RT.WARN_ON_REFLECTION.deref()))
            {
            RT.errPrintWriter()
              .format("Performance warning, %s:%d:%d - case has int tests, but tested expression is not primitive.\n",
                      SOURCE_PATH.deref(), line, column);
            }
        expr.emit(C.EXPRESSION, objx, gen);
        gen.instanceOf(NUMBER_TYPE);
        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
        expr.emit(C.EXPRESSION, objx, gen);
        gen.checkCast(NUMBER_TYPE);
        gen.invokeVirtual(NUMBER_TYPE, intValueMethod);
        emitShiftMask(gen);
        }
    else if (exprType == Type.LONG_TYPE
            || exprType == Type.INT_TYPE
            || exprType == Type.SHORT_TYPE
            || exprType == Type.BYTE_TYPE)
        {
        expr.emitUnboxed(C.EXPRESSION, objx, gen);
        gen.cast(exprType, Type.INT_TYPE);
        emitShiftMask(gen);
        }
    else
        {
        gen.goTo(defaultLabel);
        }
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:32,代碼來源:Compiler.java

示例3: emitThenForInts

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitThenForInts(ObjExpr objx, GeneratorAdapter gen, Type exprType, Expr test, Expr then, Label defaultLabel, boolean emitUnboxed){
    if (exprType == null)
        {
        expr.emit(C.EXPRESSION, objx, gen);
        test.emit(C.EXPRESSION, objx, gen);
        gen.invokeStatic(UTIL_TYPE, equivMethod);
        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
        emitExpr(objx, gen, then, emitUnboxed);
        }
    else if (exprType == Type.LONG_TYPE)
        {
        ((NumberExpr)test).emitUnboxed(C.EXPRESSION, objx, gen);
        expr.emitUnboxed(C.EXPRESSION, objx, gen);
        gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);
        emitExpr(objx, gen, then, emitUnboxed);
        }
    else if (exprType == Type.INT_TYPE
            || exprType == Type.SHORT_TYPE
            || exprType == Type.BYTE_TYPE)
        {
        if (isShiftMasked())
            {
            ((NumberExpr)test).emitUnboxed(C.EXPRESSION, objx, gen);
            expr.emitUnboxed(C.EXPRESSION, objx, gen);
            gen.cast(exprType, Type.LONG_TYPE);
            gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);
            }
        // else direct match
        emitExpr(objx, gen, then, emitUnboxed);
        }
    else
        {
        gen.goTo(defaultLabel);
        }
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:36,代碼來源:Compiler.java


注:本文中的org.objectweb.asm.commons.GeneratorAdapter.cast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。