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


Java GeneratorAdapter.getStatic方法代碼示例

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


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

示例1: visitEnd

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void visitEnd() {
	if (! doneAddField) {
		doneAddField = true;
		
		super.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, CLASS_FIELD, Type.getDescriptor(Agent.class), null, null);
	}
	
	if (! doneAddMethod) {
		doneAddMethod = true;

		GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, new Method(LOG_CLASS_METHOD, LOG_CLASS_SIGNATURE), LOG_CLASS_SIGNATURE, new Type[] {}, this);

		Label target = mg.newLabel();
		mg.getStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
		mg.ifNull(target);
		mg.push(LOG_INTERNAL_TYPE);
		mg.putStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
		mg.mark(target);
		mg.getStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
		mg.returnValue();
	}
	
	super.visitEnd();
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:25,代碼來源:SystemInstrument.java

示例2: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	if(coll instanceof IPersistentList)
		gen.getStatic(LIST_TYPE, "EMPTY", EMPTY_LIST_TYPE);
	else if(coll instanceof IPersistentVector)
		gen.getStatic(VECTOR_TYPE, "EMPTY", VECTOR_TYPE);
	else if(coll instanceof IPersistentMap)
			gen.getStatic(HASHMAP_TYPE, "EMPTY", HASHMAP_TYPE);
		else if(coll instanceof IPersistentSet)
				gen.getStatic(HASHSET_TYPE, "EMPTY", HASHSET_TYPE);
			else
				throw new UnsupportedOperationException("Unknown Collection type");
	if(context == C.STATEMENT)
		{
		gen.pop();
		}
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:17,代碼來源:Compiler.java

示例3: doEmit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void doEmit(C context, ObjExpr objx, GeneratorAdapter gen, boolean emitUnboxed){
	Label nullLabel = gen.newLabel();
	Label falseLabel = gen.newLabel();
	Label endLabel = gen.newLabel();

	gen.visitLineNumber(line, gen.mark());

	if(testExpr instanceof StaticMethodExpr && ((StaticMethodExpr)testExpr).canEmitIntrinsicPredicate())
		{
		((StaticMethodExpr) testExpr).emitIntrinsicPredicate(C.EXPRESSION, objx, gen, falseLabel);
		}
	else if(maybePrimitiveType(testExpr) == boolean.class)
		{
		((MaybePrimitiveExpr) testExpr).emitUnboxed(C.EXPRESSION, objx, gen);
		gen.ifZCmp(gen.EQ, falseLabel);
		}
	else
		{
		testExpr.emit(C.EXPRESSION, objx, gen);
		gen.dup();
		gen.ifNull(nullLabel);
		gen.getStatic(BOOLEAN_OBJECT_TYPE, "FALSE", BOOLEAN_OBJECT_TYPE);
		gen.visitJumpInsn(IF_ACMPEQ, falseLabel);
		}
	if(emitUnboxed)
		((MaybePrimitiveExpr)thenExpr).emitUnboxed(context, objx, gen);
	else
		thenExpr.emit(context, objx, gen);
	gen.goTo(endLabel);
	gen.mark(nullLabel);
	gen.pop();
	gen.mark(falseLabel);
	if(emitUnboxed)
		((MaybePrimitiveExpr)elseExpr).emitUnboxed(context, objx, gen);
	else
		elseExpr.emit(context, objx, gen);
	gen.mark(endLabel);
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:39,代碼來源:Compiler.java

示例4: generateFieldReadMethod

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null, null, null, null, _, _ -> fail")
static void generateFieldReadMethod(ClassVisitor cv, Method interfaceMethod,
                                    Type reflectorClass, Type targetClass, Type fieldType, String fieldName,
                                    int flags, int mhIndex) {
    String methodName = interfaceMethod.getName();
    String methodDesc = Type.getMethodDescriptor(interfaceMethod);
    MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, methodName, methodDesc, null, null);
    GeneratorAdapter adapter = new GeneratorAdapter(mv, ACC_PUBLIC, methodName, methodDesc);
    adapter.visitCode();

    /* Load MethodHandle, if required */
    loadMH(adapter, reflectorClass, flags, mhIndex);

    /* Load instance, if required */
    loadInstance(adapter, reflectorClass, targetClass, flags);

    if((flags & Magic.REFLECTOR_METHOD_USE_METHODHANDLE) != 0) {
        /* Build MethodHandle descriptor */
        String mhDescriptor = newDescriptor()
                .accepts((flags & Magic.REFLECTOR_METHOD_USE_INSTANCE) != 0 ? ((flags & Magic.TARGET_CLASS_VISIBILITY_PUBLIC) != 0 ? targetClass : OBJECT).getDescriptor() : "")
                .returns(fieldType.getDescriptor())
                .toString();

        /* Select right MethodHandle invoker */
        String mhInvoker = (flags & Magic.TARGET_CLASS_VISIBILITY_PUBLIC) != 0 && (flags & Magic.RETURN_TYPE_PUBLIC) != 0 ? "invokeExact" : "invoke";

        /* Invoke MethodHandle */
        adapter.visitMethodInsn(INVOKEVIRTUAL, MH.getInternalName(), mhInvoker, mhDescriptor, false);
    } else {
        if((flags & Magic.REFLECTOR_METHOD_USE_INSTANCE) != 0)
            adapter.getField(targetClass, fieldName, fieldType);
        else
            adapter.getStatic(targetClass, fieldName, fieldType);
    }

    /* Return */
    handleReturn(adapter, interfaceMethod, fieldType);
    adapter.returnValue();

    /* End method */
    adapter.endMethod();
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:43,代碼來源:MethodGenerator.java

示例5: emitBoxReturn

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void emitBoxReturn(ObjExpr objx, GeneratorAdapter gen, Class returnType){
		if(returnType.isPrimitive())
			{
			if(returnType == boolean.class)
				{
				Label falseLabel = gen.newLabel();
				Label endLabel = gen.newLabel();
				gen.ifZCmp(GeneratorAdapter.EQ, falseLabel);
				gen.getStatic(BOOLEAN_OBJECT_TYPE, "TRUE", BOOLEAN_OBJECT_TYPE);
				gen.goTo(endLabel);
				gen.mark(falseLabel);
				gen.getStatic(BOOLEAN_OBJECT_TYPE, "FALSE", BOOLEAN_OBJECT_TYPE);
//				NIL_EXPR.emit(C.EXPRESSION, fn, gen);
				gen.mark(endLabel);
				}
			else if(returnType == void.class)
				{
				NIL_EXPR.emit(C.EXPRESSION, objx, gen);
				}
			else if(returnType == char.class)
					{
					gen.invokeStatic(CHAR_TYPE, charValueOfMethod);
					}
				else
					{
					if(returnType == int.class)
						{
						gen.invokeStatic(INTEGER_TYPE, intValueOfMethod);
//						gen.visitInsn(I2L);
//						gen.invokeStatic(NUMBERS_TYPE, Method.getMethod("Number num(long)"));
						}
					else if(returnType == float.class)
						{
						gen.invokeStatic(FLOAT_TYPE, floatValueOfMethod);

//						gen.visitInsn(F2D);
//						gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);
						}
					else if(returnType == double.class)
							gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);
					else if(returnType == long.class)
							gen.invokeStatic(NUMBERS_TYPE, Method.getMethod("Number num(long)"));
					else if(returnType == byte.class)
							gen.invokeStatic(BYTE_TYPE, byteValueOfMethod);
					else if(returnType == short.class)
							gen.invokeStatic(SHORT_TYPE, shortValueOfMethod);
					}
			}
	}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:50,代碼來源:Compiler.java

示例6: emitUnboxed

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){
	gen.visitLineNumber(line, gen.mark());
	gen.getStatic(Type.getType(c), fieldName, Type.getType(field.getType()));
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:5,代碼來源:Compiler.java

示例7: emitProto

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitProto(C context, ObjExpr objx, GeneratorAdapter gen){
	Label onLabel = gen.newLabel();
	Label callLabel = gen.newLabel();
	Label endLabel = gen.newLabel();

	Var v = ((VarExpr)fexpr).var;

	Expr e = (Expr) args.nth(0);
	e.emit(C.EXPRESSION, objx, gen);
	gen.dup(); //target, target
	gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class
	gen.getStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target,class,cached-class
	gen.visitJumpInsn(IF_ACMPEQ, callLabel); //target
	if(protocolOn != null)
		{
		gen.dup(); //target, target			
		gen.instanceOf(Type.getType(protocolOn));
		gen.ifZCmp(GeneratorAdapter.NE, onLabel);
		}

	gen.dup(); //target, target
	gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class
	gen.putStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target

	gen.mark(callLabel); //target
	objx.emitVar(gen, v);
	gen.invokeVirtual(VAR_TYPE, Method.getMethod("Object getRawRoot()")); //target, proto-fn
	gen.swap();
	emitArgsAndCall(1, context,objx,gen);
	gen.goTo(endLabel);

	gen.mark(onLabel); //target
	if(protocolOn != null)
		{
		MethodExpr.emitTypedArgs(objx, gen, onMethod.getParameterTypes(), RT.subvec(args,1,args.count()));
		if(context == C.RETURN)
			{
			ObjMethod method = (ObjMethod) METHOD.deref();
			method.emitClearLocals(gen);
			}
		Method m = new Method(onMethod.getName(), Type.getReturnType(onMethod), Type.getArgumentTypes(onMethod));
		gen.invokeInterface(Type.getType(protocolOn), m);
		HostExpr.emitBoxReturn(objx, gen, onMethod.getReturnType());
		}
	gen.mark(endLabel);
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:47,代碼來源:Compiler.java

示例8: emitConstant

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitConstant(GeneratorAdapter gen, int id){
       usedConstants = (IPersistentSet) usedConstants.cons(id);
	gen.getStatic(objtype, constantName(id), constantType(id));
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:5,代碼來源:Compiler.java


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