当前位置: 首页>>代码示例>>Java>>正文


Java Bytecode.addAstore方法代码示例

本文整理汇总了Java中javassist.bytecode.Bytecode.addAstore方法的典型用法代码示例。如果您正苦于以下问题:Java Bytecode.addAstore方法的具体用法?Java Bytecode.addAstore怎么用?Java Bytecode.addAstore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javassist.bytecode.Bytecode的用法示例。


在下文中一共展示了Bytecode.addAstore方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTypeDependDataStore

import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private static void addTypeDependDataStore(Bytecode code, String typeName,
                                           int i) {
	if ((typeName.charAt(0) == 'L')
	    && (typeName.charAt(typeName.length() - 1) == ';')
	    || (typeName.charAt(0) == '[')) {
		// reference type
		code.addAstore(i);
	} else if (typeName.equals("Z") || typeName.equals("B")
	           || typeName.equals("C") || typeName.equals("I")
	           || typeName.equals("S")) {
		// boolean, byte, char, int, short
		code.addIstore(i);
	} else if (typeName.equals("D")) {
		// double
		code.addDstore(i);
	} else if (typeName.equals("F")) {
		// float
		code.addFstore(i);
	} else if (typeName.equals("J")) {
		// long
		code.addLstore(i);
	} else {
		// bad type
		throw new RuntimeException("bad type: " + typeName);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:FieldTransformer.java

示例2: addTypeDependDataStore

import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private static void addTypeDependDataStore(Bytecode code, String typeName, int i) {
	if ( typeName.charAt( 0 ) == 'L'
			&& typeName.charAt( typeName.length() - 1 ) == ';'
			|| typeName.charAt( 0 ) == '[' ) {
		// reference type
		code.addAstore( i );
	}
	else if ( typeName.equals( "Z" )
			|| typeName.equals( "B" )
			|| typeName.equals( "C" )
			|| typeName.equals( "I" )
			|| typeName.equals( "S" ) ) {
		// boolean, byte, char, int, short
		code.addIstore( i );
	}
	else if ( typeName.equals( "D" ) ) {
		// double
		code.addDstore( i );
	}
	else if ( typeName.equals( "F" ) ) {
		// float
		code.addFstore( i );
	}
	else if ( typeName.equals( "J" ) ) {
		// long
		code.addLstore( i );
	}
	else {
		// bad type
		throw new RuntimeException( "bad type: " + typeName );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:FieldTransformer.java

示例3: storeStack

import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
static final void storeStack(CtClass[] params, boolean isStaticCall,
        int regno, Bytecode bytecode) {
    storeStack0(0, params.length, params, regno + 1, bytecode);
    if (isStaticCall)
        bytecode.addOpcode(ACONST_NULL);

    bytecode.addAstore(regno);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:9,代码来源:Expr.java

示例4: addGetter

import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private void addGetter(ClassFile classfile, final Method[] getters) throws CannotCompileException {
	ConstPool cp = classfile.getConstPool();
	int target_type_index = cp.addClassInfo( this.targetBean.getName() );
	String desc = GET_SETTER_DESC;
	MethodInfo mi = new MethodInfo( cp, GENERATED_GETTER_NAME, desc );

	Bytecode code = new Bytecode( cp, 6, 4 );
	/* | this | bean | args | raw bean | */
	if ( getters.length >= 0 ) {
		// aload_1 // load bean
		code.addAload( 1 );
		// checkcast // cast bean
		code.addCheckcast( this.targetBean.getName() );
		// astore_3 // store bean
		code.addAstore( 3 );
		for ( int i = 0; i < getters.length; ++i ) {
			if ( getters[i] != null ) {
				Method getter = getters[i];
				// aload_2 // args
				code.addAload( 2 );
				// iconst_i // continue to aastore
				code.addIconst( i ); // growing stack is 1
				Class returnType = getter.getReturnType();
				int typeIndex = -1;
				if ( returnType.isPrimitive() ) {
					typeIndex = FactoryHelper.typeIndex( returnType );
					// new
					code.addNew( FactoryHelper.wrapperTypes[typeIndex] );
					// dup
					code.addOpcode( Opcode.DUP );
				}

				// aload_3 // load the raw bean
				code.addAload( 3 );
				String getter_desc = RuntimeSupport.makeDescriptor( getter );
				String getterName = getter.getName();
				if ( this.targetBean.isInterface() ) {
					// invokeinterface
					code.addInvokeinterface( target_type_index, getterName, getter_desc, 1 );
				}
				else {
					// invokevirtual
					code.addInvokevirtual( target_type_index, getterName, getter_desc );
				}

				if ( typeIndex >= 0 ) {       // is a primitive type
					// invokespecial
					code.addInvokespecial(
							FactoryHelper.wrapperTypes[typeIndex],
					        MethodInfo.nameInit,
					        FactoryHelper.wrapperDesc[typeIndex]
					);
				}

				// aastore // args
				code.add( Opcode.AASTORE );
				code.growStack( -3 );
			}
		}
	}
	// return
	code.addOpcode( Opcode.RETURN );

	mi.setCodeAttribute( code.toCodeAttribute() );
	mi.setAccessFlags( AccessFlag.PUBLIC );
	classfile.addMethod( mi );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:68,代码来源:BulkAccessorFactory.java

示例5: addGetter

import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private void addGetter(ClassFile classfile, final Method[] getters) throws CannotCompileException {
	final ConstPool constPool = classfile.getConstPool();
	final int targetBeanConstPoolIndex = constPool.addClassInfo( this.targetBean.getName() );
	final String desc = GET_SETTER_DESC;
	final MethodInfo getterMethodInfo = new MethodInfo( constPool, GENERATED_GETTER_NAME, desc );

	final Bytecode code = new Bytecode( constPool, 6, 4 );
	/* | this | bean | args | raw bean | */
	if ( getters.length >= 0 ) {
		// aload_1 // load bean
		code.addAload( 1 );
		// checkcast // cast bean
		code.addCheckcast( this.targetBean.getName() );
		// astore_3 // store bean
		code.addAstore( 3 );
		for ( int i = 0; i < getters.length; ++i ) {
			if ( getters[i] != null ) {
				final Method getter = getters[i];
				// aload_2 // args
				code.addAload( 2 );
				// iconst_i // continue to aastore
				// growing stack is 1
				code.addIconst( i );
				final Class returnType = getter.getReturnType();
				int typeIndex = -1;
				if ( returnType.isPrimitive() ) {
					typeIndex = FactoryHelper.typeIndex( returnType );
					// new
					code.addNew( FactoryHelper.wrapperTypes[typeIndex] );
					// dup
					code.addOpcode( Opcode.DUP );
				}

				// aload_3 // load the raw bean
				code.addAload( 3 );
				final String getterSignature = RuntimeSupport.makeDescriptor( getter );
				final String getterName = getter.getName();
				if ( this.targetBean.isInterface() ) {
					// invokeinterface
					code.addInvokeinterface( targetBeanConstPoolIndex, getterName, getterSignature, 1 );
				}
				else {
					// invokevirtual
					code.addInvokevirtual( targetBeanConstPoolIndex, getterName, getterSignature );
				}

				if ( typeIndex >= 0 ) {
					// is a primitive type
					// invokespecial
					code.addInvokespecial(
							FactoryHelper.wrapperTypes[typeIndex],
							MethodInfo.nameInit,
							FactoryHelper.wrapperDesc[typeIndex]
					);
				}

				// aastore // args
				code.add( Opcode.AASTORE );
				code.growStack( -3 );
			}
		}
	}
	// return
	code.addOpcode( Opcode.RETURN );

	getterMethodInfo.setCodeAttribute( code.toCodeAttribute() );
	getterMethodInfo.setAccessFlags( AccessFlag.PUBLIC );
	classfile.addMethod( getterMethodInfo );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:70,代码来源:BulkAccessorFactory.java


注:本文中的javassist.bytecode.Bytecode.addAstore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。