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


Java ReturnInstruction类代码示例

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


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

示例1: transferInstruction

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, LockSet fact)
        throws DataflowAnalysisException {

	Instruction ins = handle.getInstruction();
	short opcode = ins.getOpcode();
	if (opcode == Constants.MONITORENTER || opcode == Constants.MONITOREXIT) {
		ValueNumberFrame frame = vnaDataflow.getFactAtLocation(new Location(handle, basicBlock));

		// NOTE: if the CFG is pruned, there may be unreachable instructions,
		// so make sure frame is valid.
		if (frame.isValid()) {
			int lockNumber = frame.getTopValue().getNumber();
			lockOp(fact, lockNumber, opcode == Constants.MONITORENTER ? 1 : -1);
		}
	} else if ((ins instanceof ReturnInstruction) && isSynchronized && !isStatic) {
		lockOp(fact, vna.getThisValue().getNumber(), -1);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:LockAnalysis.java

示例2: isThrower

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
public static boolean isThrower(BasicBlock target) {
    InstructionHandle ins = target.getFirstInstruction();
    int maxCount = 7;
    while (ins != null) {
        if (maxCount-- <= 0)
            break;
        Instruction i = ins.getInstruction();
        if (i instanceof ATHROW) {
            return true;
        }
        if (i instanceof InstructionTargeter || i instanceof ReturnInstruction)
            return false;
        ins = ins.getNext();
    }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:NoiseNullDeref.java

示例3: registerInstructionSinks

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
private void registerInstructionSinks() throws DataflowAnalysisException {
    TypeQualifierAnnotation returnValueAnnotation = null;
    if (!xmethod.getSignature().endsWith(")V")) {
        returnValueAnnotation = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, typeQualifierValue);
    }

    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
        Location location = i.next();

        Instruction ins = location.getHandle().getInstruction();

        if (ins instanceof ReturnInstruction && !(ins instanceof RETURN)) {
            // Return instruction which returns a value
            modelReturn(returnValueAnnotation, location);
        } else {
            short opcode = ins.getOpcode();

            if (opcode == Constants.PUTFIELD || opcode == Constants.PUTSTATIC) {
                modelFieldStore(location);
            } else if (location.getHandle().getInstruction() instanceof InvokeInstruction) {
                modelArguments(location);
            }
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:BackwardTypeQualifierDataflowAnalysis.java

示例4: isPEI

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
/**
 * Return whether or not the given instruction can throw exceptions.
 *
 * @param handle
 *            the instruction
 * @return true if the instruction can throw an exception, false otherwise
 */
private boolean isPEI(InstructionHandle handle) {
    Instruction ins = handle.getInstruction();

    if (!(ins instanceof ExceptionThrower))
        return false;

    if (ins instanceof NEW)
        return false;
    // if (ins instanceof ATHROW) return false;
    if (ins instanceof GETSTATIC)
        return false;
    if (ins instanceof PUTSTATIC)
        return false;
    if (ins instanceof ReturnInstruction)
        return false;
    if (ins instanceof INSTANCEOF)
        return false;
    if (ins instanceof MONITOREXIT)
        return false;
    if (ins instanceof LDC)
        return false;
    return true;

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:BetterCFGBuilder2.java

示例5: insertAllDeleteLocalRecords

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
void insertAllDeleteLocalRecords(MethodGen m) {
    int maxLocals = m.getMaxLocals();
    InstructionList il = m.getInstructionList();

    for (InstructionHandle i = il.getStart(); i != null; i = i.getNext()) {
        Instruction ins = i.getInstruction();
        if (ins instanceof ReturnInstruction) {
            i = insertDeleteLocalRecord(m, il, i, maxLocals);
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:12,代码来源:Cashmerec.java

示例6: potentialInitialization

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
/**
 * @param nextHandle
 * @return
 */
private boolean potentialInitialization(InstructionHandle nextHandle) {
    if (nextHandle == null)
        return true;
    Instruction instruction = nextHandle.getInstruction();
    if (instruction instanceof ReturnInstruction)
        return false;
    if (instruction instanceof IfInstruction)
        return false;
    return true;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:LazyInit.java

示例7: visitInstruction

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
private boolean visitInstruction( Instruction i ) {
    short opcode = i.getOpcode();
    if ((InstructionConstants.INSTRUCTIONS[opcode] != null)
            && !(i instanceof ConstantPushInstruction) && !(i instanceof ReturnInstruction)) { // Handled below
        _out.println("il.append(InstructionConstants."
                + i.getName().toUpperCase(Locale.ENGLISH) + ");");
        return true;
    }
    return false;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:11,代码来源:BCELFactory.java

示例8: getAndRemoveStoreIns

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的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

示例9: isEndInstruction

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
private boolean isEndInstruction(InstructionContext context) {
return context.getInstruction().getInstruction() 
    instanceof ReturnInstruction ||
    context.getInstruction().getInstruction() 
    instanceof ATHROW;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:7,代码来源:BasicBlockGraph.java

示例10: isEndInstruction

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
boolean isEndInstruction(InstructionContext context) {
return context.getInstruction().getInstruction() 
    instanceof ReturnInstruction ||
    context.getInstruction().getInstruction() 
    instanceof ATHROW;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:7,代码来源:ControlFlowViewer.java

示例11: visitReturnInstruction

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
@Override
public void visitReturnInstruction(ReturnInstruction ins) {
    isReturn = true;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:5,代码来源:TargetEnumeratingVisitor.java

示例12: pass3StaticInstructionChecks

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
/**
 * These are the checks if constraints are satisfied which are described in the
 * Java Virtual Machine Specification, Second Edition as Static Constraints on
 * the instructions of Java Virtual Machine Code (chapter 4.8.1).
 *
 * @throws StaticCodeConstraintException if the verification fails.
 */
private void pass3StaticInstructionChecks(){
	
	// Code array must not be empty:
	// Enforced in pass 2 (also stated in the static constraints of the Code
	// array in vmspec2), together with pass 1 (reading code_length bytes and
	// interpreting them as code[]). So this must not be checked again here.

	if (! (code.getCode().length < 65536)){// contradicts vmspec2 page 152 ("Limitations"), but is on page 134.
		throw new StaticCodeInstructionConstraintException("Code array in code attribute '"+code+"' too big: must be smaller than 65536 bytes.");
	}

	// First opcode at offset 0: okay, that's clear. Nothing to do.
	
	// Only instances of the instructions documented in Section 6.4 may appear in
	// the code array.
	
	// For BCEL's sake, we cannot handle WIDE stuff, but hopefully BCEL does its job right :)
	
	// The last byte of the last instruction in the code array must be the byte at index
	// code_length-1 : See the do_verify() comments. We actually don't iterate through the
	// byte array, but use an InstructionList so we cannot check for this. But BCEL does
	// things right, so it's implicitly okay.
	
	// TODO: Check how BCEL handles (and will handle) instructions like IMPDEP1, IMPDEP2,
	//       BREAKPOINT... that BCEL knows about but which are illegal anyway.
	//       We currently go the safe way here.
	InstructionHandle ih = instructionList.getStart();
	while (ih != null){
		Instruction i = ih.getInstruction();
		if (i instanceof IMPDEP1){
			throw new StaticCodeInstructionConstraintException("IMPDEP1 must not be in the code, it is an illegal instruction for _internal_ JVM use!");
		}
		if (i instanceof IMPDEP2){
			throw new StaticCodeInstructionConstraintException("IMPDEP2 must not be in the code, it is an illegal instruction for _internal_ JVM use!");
		}
		if (i instanceof BREAKPOINT){
			throw new StaticCodeInstructionConstraintException("BREAKPOINT must not be in the code, it is an illegal instruction for _internal_ JVM use!");
		}
		ih = ih.getNext();
	}
	
	// The original verifier seems to do this check here, too.
	// An unreachable last instruction may also not fall through the
	// end of the code, which is stupid -- but with the original
	// verifier's subroutine semantics one cannot predict reachability.
	Instruction last = instructionList.getEnd().getInstruction();
	if (! ((last instanceof ReturnInstruction)	||
				(last instanceof RET)    							||
				(last instanceof GotoInstruction)			||
				(last instanceof ATHROW) )) {
           throw new StaticCodeInstructionConstraintException("Execution must not fall off the bottom of the code array. This constraint is enforced statically as some existing verifiers do - so it may be a false alarm if the last instruction is not reachable.");
       }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:61,代码来源:Pass3aVerifier.java

示例13: getSuccessors

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
/**
 * A utility method that calculates the successors of a given InstructionHandle
 * <B>in the same subroutine</B>. That means, a RET does not have any successors
 * as defined here. A JsrInstruction has its physical successor as its successor
 * (opposed to its target) as defined here.
 */
private static InstructionHandle[] getSuccessors(InstructionHandle instruction){
	final InstructionHandle[] empty = new InstructionHandle[0];
	final InstructionHandle[] single = new InstructionHandle[1];
	final InstructionHandle[] pair = new InstructionHandle[2];
	
	Instruction inst = instruction.getInstruction();
	
	if (inst instanceof RET){
		return empty;
	}
	
	// Terminates method normally.
	if (inst instanceof ReturnInstruction){
		return empty;
	}
	
	// Terminates method abnormally, because JustIce mandates
	// subroutines not to be protected by exception handlers.
	if (inst instanceof ATHROW){
		return empty;
	}
	
	// See method comment.
	if (inst instanceof JsrInstruction){
		single[0] = instruction.getNext();
		return single;
	}

	if (inst instanceof GotoInstruction){
		single[0] = ((GotoInstruction) inst).getTarget();
		return single;
	}

	if (inst instanceof BranchInstruction){
		if (inst instanceof Select){
			// BCEL's getTargets() returns only the non-default targets,
			// thanks to Eli Tilevich for reporting.
			InstructionHandle[] matchTargets = ((Select) inst).getTargets();
			InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
			ret[0] = ((Select) inst).getTarget();
			System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
			return ret;
		}
		else{
			pair[0] = instruction.getNext();
			pair[1] = ((BranchInstruction) inst).getTarget();
			return pair;
		}
	}

	// default case: Fall through.		
	single[0] = instruction.getNext();
	return single;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:61,代码来源:Subroutines.java

示例14: visitReturnInstruction

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
public void visitReturnInstruction( ReturnInstruction i ) {
    Type type = i.getType(_cp);
    _out.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));");
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:5,代码来源:BCELFactory.java

示例15: getSuccessors

import org.apache.bcel.generic.ReturnInstruction; //导入依赖的package包/类
/**
 * A utility method that calculates the successors of a given InstructionHandle
 * <B>in the same subroutine</B>. That means, a RET does not have any successors
 * as defined here. A JsrInstruction has its physical successor as its successor
 * (opposed to its target) as defined here.
 */
private static InstructionHandle[] getSuccessors(InstructionHandle instruction){
	Instruction inst = instruction.getInstruction();

       if (inst instanceof RET){
		return empty;
	}

	// Terminates method normally.
	if (inst instanceof ReturnInstruction){
		return empty;
	}

	// Terminates method abnormally, because JustIce mandates
	// subroutines not to be protected by exception handlers.
	if (inst instanceof ATHROW){
		return empty;
	}

       final InstructionHandle[] single = new InstructionHandle[1];

       // See method comment.
	if (inst instanceof JsrInstruction){
		single[0] = instruction.getNext();
		return single;
	}

	if (inst instanceof GotoInstruction){
		single[0] = ((GotoInstruction) inst).getTarget();
		return single;
	}

	if (inst instanceof BranchInstruction){
		if (inst instanceof Select){
			// BCEL's getTargets() returns only the non-default targets,
			// thanks to Eli Tilevich for reporting.
			InstructionHandle[] matchTargets = ((Select) inst).getTargets();
			InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
			ret[0] = ((Select) inst).getTarget();
			System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
			return ret;
		}
		else{
               final InstructionHandle[] pair = new InstructionHandle[2];
			pair[0] = instruction.getNext();
			pair[1] = ((BranchInstruction) inst).getTarget();
			return pair;
		}
	}

	// default case: Fall through.
	single[0] = instruction.getNext();
	return single;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:60,代码来源:Subroutines.java


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