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


Java GeneratorAdapter.checkCast方法代碼示例

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


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

示例1: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	if(targetClass != null && field != null)
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.checkCast(getType(targetClass));
		gen.getField(getType(targetClass), fieldName, Type.getType(field.getType()));
		//if(context != C.STATEMENT)
		HostExpr.emitBoxReturn(objx, gen, field.getType());
		if(context == C.STATEMENT)
			{
			gen.pop();
			}
		}
	else
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.push(fieldName);
		gen.push(requireField);
		gen.invokeStatic(REFLECTOR_TYPE, invokeNoArgInstanceMember);
		if(context == C.STATEMENT)
			gen.pop();
		}
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:26,代碼來源:Compiler.java

示例2: emitConstants

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
void emitConstants(GeneratorAdapter clinitgen){
	try
		{
		Var.pushThreadBindings(RT.map(RT.PRINT_DUP, RT.T));

		for(int i = 0; i < constants.count(); i++)
			{
               if(usedConstants.contains(i))
                   {
                   emitValue(constants.nth(i), clinitgen);
                   clinitgen.checkCast(constantType(i));
                   clinitgen.putStatic(objtype, constantName(i), constantType(i));
                   }
			}
		}
	finally
		{
		Var.popThreadBindings();
		}
}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:21,代碼來源:Compiler.java

示例3: emitLetFnInits

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitLetFnInits(GeneratorAdapter gen, ObjExpr objx, IPersistentSet letFnLocals){
	//objx arg is enclosing objx, not this
	gen.checkCast(objtype);

	for(ISeq s = RT.keys(closes); s != null; s = s.next())
		{
		LocalBinding lb = (LocalBinding) s.first();
		if(letFnLocals.contains(lb))
			{
			Class primc = lb.getPrimitiveType();
			gen.dup();
			if(primc != null)
				{
				objx.emitUnboxedLocal(gen, lb);
				gen.putField(objtype, lb.name, Type.getType(primc));
				}
			else
				{
				objx.emitLocal(gen, lb, false);
				gen.putField(objtype, lb.name, OBJECT_TYPE);
				}
			}
		}
	gen.pop();

}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:27,代碼來源:Compiler.java

示例4: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	if(isProtocol)
		{
		gen.visitLineNumber(line, gen.mark());
		emitProto(context,objx,gen);
		}

	else
		{
		fexpr.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.checkCast(IFN_TYPE);
		emitArgsAndCall(0, context,objx,gen);
		}
	if(context == C.STATEMENT)
		gen.pop();		
}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:18,代碼來源:Compiler.java

示例5: emitAssign

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
                       Expr val){
	if(targetClass != null && field != null)
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.checkCast(getType(targetClass));
		val.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.dupX1();
		HostExpr.emitUnboxArg(objx, gen, field.getType());
		gen.putField(getType(targetClass), fieldName, Type.getType(field.getType()));
		}
	else
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.push(fieldName);
		val.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.invokeStatic(REFLECTOR_TYPE, setInstanceFieldMethod);
		}
	if(context == C.STATEMENT)
		gen.pop();
}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:24,代碼來源:Compiler.java

示例6: unbox

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
 * Generates unboxing bytecode for the passed type. An {@link Object} is expected to be on the
 * stack when these bytecodes are inserted.
 *
 * ASM takes a short cut when dealing with short/byte types and convert them into int rather
 * than short/byte types. This is not an issue on the jvm nor Android's ART but it is an issue
 * on Dalvik.
 *
 * @param mv the {@link GeneratorAdapter} generating a method implementation.
 * @param type the expected un-boxed type.
 */
public static void unbox(GeneratorAdapter mv, Type type) {
    if (type.equals(Type.SHORT_TYPE)) {
        mv.checkCast(NUMBER_TYPE);
        mv.invokeVirtual(NUMBER_TYPE, SHORT_VALUE);
    } else if (type.equals(Type.BYTE_TYPE)) {
        mv.checkCast(NUMBER_TYPE);
        mv.invokeVirtual(NUMBER_TYPE, BYTE_VALUE);
    } else {
        mv.unbox(type);
    }
}
 
開發者ID:Idtk,項目名稱:Hotfix,代碼行數:23,代碼來源:ByteCodeUtils.java

示例7: 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

示例8: emitUnboxed

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){
	if(targetClass != null && field != null)
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.checkCast(getType(targetClass));
		gen.getField(getType(targetClass), fieldName, Type.getType(field.getType()));
		}
	else
		throw new UnsupportedOperationException("Unboxed emit of unknown member");
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:12,代碼來源:Compiler.java

示例9: 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:skejserjensen,項目名稱:eclojure,代碼行數:32,代碼來源:Compiler.java

示例10: emitUnboxArg

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void emitUnboxArg(ObjExpr objx, GeneratorAdapter gen, Class paramType){
		if(paramType.isPrimitive())
			{
			if(paramType == boolean.class)
				{
				gen.checkCast(BOOLEAN_TYPE);
				gen.invokeVirtual(BOOLEAN_TYPE, booleanValueMethod);
//				Label falseLabel = gen.newLabel();
//				Label endLabel = gen.newLabel();
//				gen.ifNull(falseLabel);
//				gen.push(1);
//				gen.goTo(endLabel);
//				gen.mark(falseLabel);
//				gen.push(0);
//				gen.mark(endLabel);
				}
			else if(paramType == char.class)
				{
				gen.checkCast(CHAR_TYPE);
				gen.invokeVirtual(CHAR_TYPE, charValueMethod);
				}
			else
				{
//				System.out.println("NOT fnexpr for defn var: " + var + "init: " + init.getClass());
				Method m = null;
				gen.checkCast(NUMBER_TYPE);
				if(RT.booleanCast(RT.UNCHECKED_MATH.deref()))
					{
					if(paramType == int.class)
						m = Method.getMethod("int uncheckedIntCast(Object)");
					else if(paramType == float.class)
						m = Method.getMethod("float uncheckedFloatCast(Object)");
					else if(paramType == double.class)
						m = Method.getMethod("double uncheckedDoubleCast(Object)");
					else if(paramType == long.class)
						m = Method.getMethod("long uncheckedLongCast(Object)");
					else if(paramType == byte.class)
						m = Method.getMethod("byte uncheckedByteCast(Object)");
					else if(paramType == short.class)
						m = Method.getMethod("short uncheckedShortCast(Object)");					
					}
				else
					{
					if(paramType == int.class)
						m = Method.getMethod("int intCast(Object)");
					else if(paramType == float.class)
						m = Method.getMethod("float floatCast(Object)");
					else if(paramType == double.class)
						m = Method.getMethod("double doubleCast(Object)");
					else if(paramType == long.class)
						m = Method.getMethod("long longCast(Object)");
					else if(paramType == byte.class)
						m = Method.getMethod("byte byteCast(Object)");
					else if(paramType == short.class)
						m = Method.getMethod("short shortCast(Object)");
					}
				gen.invokeStatic(RT_TYPE, m);
				}
			}
		else
			{
			gen.checkCast(Type.getType(paramType));
			}
	}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:65,代碼來源:Compiler.java


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