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


Java POP类代码示例

本文整理汇总了Java中org.apache.bcel.generic.POP的典型用法代码示例。如果您正苦于以下问题:Java POP类的具体用法?Java POP怎么用?Java POP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: rewriteStore

import org.apache.bcel.generic.POP; //导入依赖的package包/类
InstructionHandle rewriteStore(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals, String localClassName) {
    LocalVariableInstruction curr = (LocalVariableInstruction) (i
        .getInstruction());
    Type type = mtab.getLocalType(m, curr, i.getPosition());
    if (type == null) {
        return i;
    }
    String name = mtab.getLocalName(m, curr, i.getPosition());
    String fieldName = MethodTable.generatedLocalName(type, name);

    i.setInstruction(new ALOAD(maxLocals));
    i = i.getNext();

    if (type.equals(Type.LONG) || type.equals(Type.DOUBLE)) {
        il.insert(i, new DUP_X2());
        il.insert(i, new POP());
    } else {
        il.insert(i, new SWAP());
    }

    i = il.insert(i, ins_f.createFieldAccess(localClassName, fieldName,
        type, Constants.PUTFIELD));
    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:26,代码来源:Cashmerec.java

示例2: removeUnusedLocals

import org.apache.bcel.generic.POP; //导入依赖的package包/类
void removeUnusedLocals(Method mOrig, MethodGen m) {
    InstructionList il = m.getInstructionList();
    InstructionHandle[] ins = il.getInstructionHandles();
    for (int i = 0; i < ins.length; i++) {
        Instruction in = ins[i].getInstruction();

        if (in instanceof LocalVariableInstruction) {
            LocalVariableInstruction curr = (LocalVariableInstruction) in;
            if (mtab.getLocal(m, curr, ins[i].getPosition()) != null
                && curr.getIndex() < m.getMaxLocals() - 5
                && !mtab.isLocalUsedInInlet(mOrig, curr.getIndex())) {
                if (curr instanceof IINC) {
                    ins[i].setInstruction(new NOP());
                } else if (curr instanceof LSTORE || curr instanceof DSTORE) {
                    ins[i].setInstruction(new POP2());
                } else if (curr instanceof StoreInstruction) {
                    ins[i].setInstruction(new POP());
                } else if (curr instanceof ALOAD) {
                    ins[i].setInstruction(new ACONST_NULL());
                } else if (curr instanceof FLOAD) {
                    ins[i].setInstruction(new FCONST((float) 0.0));
                } else if (curr instanceof ILOAD) {
                    ins[i].setInstruction(new ICONST(0));
                } else if (curr instanceof DLOAD) {
                    ins[i].setInstruction(new DCONST(0.0));
                } else if (curr instanceof LLOAD) {
                    ins[i].setInstruction(new LCONST(0L));
                } else {
                    System.out.println("unhandled ins in "
                        + "removeUnusedLocals: " + curr);
                    System.exit(1);
                }
            }
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:37,代码来源:Cashmerec.java

示例3: insertReturnPop

import org.apache.bcel.generic.POP; //导入依赖的package包/类
void insertReturnPop(Method m, InstructionList il) {
    Type returnType = m.getReturnType();

    if (returnType.equals(Type.DOUBLE) || returnType.equals(Type.LONG)) {
        il.append(new POP2());
    } else if (returnType.equals(Type.VOID)) {
        // do nothing
    } else {
        il.append(new POP());
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:12,代码来源:Cashmerec.java

示例4: getAndRemoveStoreIns

import org.apache.bcel.generic.POP; //导入依赖的package包/类
InstructionList getAndRemoveStoreIns(InstructionList il, InstructionHandle i) {

        int netto_stack_inc = 0;
        InstructionHandle storeStart = i;

        do {
            if (i == null) {
                // Could not find store sequence.
                return null;
            }
            int inc = i.getInstruction().produceStack(cpg)
                - i.getInstruction().consumeStack(cpg);
            netto_stack_inc += inc;
            i = i.getNext();
        } while (netto_stack_inc >= 0);

        if (i == null) {
            // may happen if the result is used like, for instance:
            // return f().clone();
            // No store sequence, so this is wrong as well.
            return null;
        }
        
        Instruction store = i.getPrev().getInstruction();
        
        if (store instanceof ReturnInstruction) {
            return null;
        }
        if (store instanceof POP || store instanceof POP2) {
            return null;
        }
        
        InstructionList result = new InstructionList();
        InstructionHandle ip = storeStart;

        do {
            result.append(ip.getInstruction());
            ip = ip.getNext();
        } while (ip != i);

        deleteIns(il, storeStart, ip.getPrev(), ip);

        return result;
    }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:45,代码来源:Cashmerec.java

示例5: createInstructionPop

import org.apache.bcel.generic.POP; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionPop(Element inst) throws IllegalXMLVMException {
    return new POP();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:JavaByteCodeOutputProcess.java

示例6: generate

import org.apache.bcel.generic.POP; //导入依赖的package包/类
/**
 * <<GET_IMODEL(THIS)>> 
	 * ALOAD !!#receptor_variable!!
    * LDC <<featureName>>
 * INVOKEINTERFACE getFeature
 */	 
@Override
public void generate(GenScope scope) {
	InstructionList il       = scope.getInstructionList();
	InstructionFactory ifact = scope.getInstructionFactory();
	ConstantPoolGen cpg      = scope.getConstantPool();

	Variable realReceptor = scope.getRealVariable(this.receptor);

	LocalVariableGen lvg = scope.newLocalVariable(this, Type.OBJECT);

	// generate model access
	scope.generateGetModel(realReceptor);
	il.append(new DUP()); // for later calls of get/method calls (problem if I put the generateGetModel directly, not using the dup optimize, why?)
	
	
	// push receptor
	// push featureName
	scope.loadVariable(realReceptor, il);
	lvg.setStart(il.append(new LDC(cpg.addString(featureName))));
	
	if ( kind == GetKind.PLAIN_GET ) {
		appendGetFeature(il, ifact);
		il.append(InstructionFactory.SWAP);
		il.append(InstructionFactory.POP);
		// I should swap, and then pop...
		// il.append(new POP());
	} else {
		BranchInstruction branchToCall = InstructionFactory
				.createBranchInstruction(Constants.IFEQ, null);
		BranchInstruction branchToEnd = InstructionFactory
				.createBranchInstruction(Constants.GOTO, null);
		
		// hasFeature(f)
		// ifeq (jump if value == 0)
		appendHasFeature(il, ifact);
		lvg.setStart(il.append(branchToCall));

		// push receptor
		// push featureName
		// get & jump to the end
		/*
		scope.loadVariable(realReceptor, il);
		lvg.setStart(il.append(new LDC(cpg.addString(featureName))));
		*/
		if ( isStreamingMode(scope) ) {
			appendContinuableGetFeature(scope, realReceptor, il, ifact, cpg);
		} else {
			scope.loadVariable(realReceptor, il);
			il.append(new LDC(cpg.addString(featureName)));
			appendGetFeature(il, ifact);
			// branchToEnd.setTarget(appendGetFeature(il, ifact));
		}
		il.append(branchToEnd);
		
		// push receptor
		// push featureName
		// methodCall
		branchToCall.setTarget( il.append(InstructionConstants.NOP) ); // label for this part
		//scope.loadVariable(realReceptor, il);
		// lvg.setStart(il.append(new LDC(cpg.addString(featureName))));			
		lvg.setStart(il.append(InstructionConstants.POP)); // remove IModel
		appendMethodCall(scope, il, ifact);

		// NOP-end
		branchToEnd.setTarget( il.append(InstructionConstants.NOP) );
	}
	
	// store result
	il.append(new ASTORE( lvg.getIndex() ));
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:77,代码来源:GetJVMGen.java


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