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


Java JsrInstruction类代码示例

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


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

示例1: addEnteringJsrInstruction

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
/**
 * Adds a new JSR or JSR_W that has this subroutine as its target.
 */
public void addEnteringJsrInstruction(InstructionHandle jsrInst){
	if ( (jsrInst == null) || (! (jsrInst.getInstruction() instanceof JsrInstruction))){
		throw new AssertionViolatedException("Expecting JsrInstruction InstructionHandle.");
	}
	if (localVariable == UNSET){
		throw new AssertionViolatedException("Set the localVariable first!");
	}
	else{
		// Something is wrong when an ASTORE is targeted that does not operate on the same local variable than the rest of the
		// JsrInstruction-targets and the RET.
		// (We don't know out leader here so we cannot check if we're really targeted!)
		if (localVariable != ((ASTORE) (((JsrInstruction) jsrInst.getInstruction()).getTarget().getInstruction())).getIndex()){
			throw new AssertionViolatedException("Setting a wrong JsrInstruction.");
		}
	}
	theJSRs.add(jsrInst);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:21,代码来源:Subroutines.java

示例2: lastExecutionJSR

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
/**
 * Returns the InstructionContextImpl with an JSR/JSR_W
 * that was last in the ExecutionChain, without
 * a corresponding RET, i.e.
 * we were called by this one.
 * Returns null if we were called from the top level.
 */
private InstructionContextImpl lastExecutionJSR(){
	
	int size = executionPredecessors.size();
	int retcount = 0;
	
	for (int i=size-1; i>=0; i--){
		InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i));
		Instruction currentlast = current.getInstruction().getInstruction();
		if (currentlast instanceof RET) {
                  retcount++;
              }
		if (currentlast instanceof JsrInstruction){
			retcount--;
			if (retcount == -1) {
                      return current;
                  }
		}
	}
	return null;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:28,代码来源:ControlFlowGraph.java

示例3: lastExecutionJSR

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
/**
 * Returns the InstructionContextImpl with an JSR/JSR_W
 * that was last in the ExecutionChain, without
 * a corresponding RET, i.e.
 * we were called by this one.
 * Returns null if we were called from the top level.
 */
public InstructionContext lastExecutionJSR(){
    int retcount = 0;

    for( ExecutionPath ptr = this; ptr!=EMPTY; ptr=ptr.prev) {
        Instruction i = ptr.last.getInstruction().getInstruction();
        if (i instanceof RET) retcount++;
        if (i instanceof JsrInstruction){
            retcount--;
            if (retcount == -1)
                return ptr.last;
        }
    }

    return null;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:23,代码来源:ExecutionPath.java

示例4: subSubs

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
public Subroutine[] subSubs(){
	Set h = new HashSet();

	Iterator i = instructions.iterator();
	while (i.hasNext()){
		Instruction inst = ((InstructionHandle) i.next()).getInstruction();
		if (inst instanceof JsrInstruction){
			InstructionHandle targ = ((JsrInstruction) inst).getTarget();
			h.add(getSubroutine(targ));
		}
	}
	Subroutine[] ret = new Subroutine[h.size()];
	return (Subroutine[]) h.toArray(ret);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:15,代码来源:Subroutines.java

示例5: subSubs

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
public Subroutine[] subSubs(){
	final Set<Subroutine> h = new HashSet<Subroutine>();
	for (final InstructionHandle ih : instructions){
		final Instruction inst = ih.getInstruction();
		if (inst instanceof JsrInstruction){
			InstructionHandle targ = ((JsrInstruction) inst).getTarget();
			h.add(getSubroutine(targ));
		}
	}
	final Subroutine[] ret = new Subroutine[h.size()];
	return h.toArray(ret);
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:13,代码来源:Subroutines.java

示例6: pass3StaticInstructionOperandsChecks

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
/**
 * These are the checks for the satisfaction of constraints which are described in the
 * Java Virtual Machine Specification, Second Edition as Static Constraints on
 * the operands of instructions of Java Virtual Machine Code (chapter 4.8.1).
 * BCEL parses the code array to create an InstructionList and therefore has to check
 * some of these constraints. Additional checks are also implemented here.
 *
 * @throws StaticCodeConstraintException if the verification fails.
 */
private void pass3StaticInstructionOperandsChecks(){
    try {
	// When building up the InstructionList, BCEL has already done all those checks
	// mentioned in The Java Virtual Machine Specification, Second Edition, as
	// "static constraints on the operands of instructions in the code array".
	// TODO: see the do_verify() comments. Maybe we should really work on the
	//       byte array first to give more comprehensive messages.
	// TODO: Review Exception API, possibly build in some "offending instruction" thing
	//       when we're ready to insulate the offending instruction by doing the
	//       above thing.

	// TODO: Implement as much as possible here. BCEL does _not_ check everything.

	ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(myOwner.getClassName()).getConstantPool());
	InstOperandConstraintVisitor v = new InstOperandConstraintVisitor(cpg);

	// Checks for the things BCEL does _not_ handle itself.
	InstructionHandle ih = instructionList.getStart();
	while (ih != null){
		Instruction i = ih.getInstruction();
		
		// An "own" constraint, due to JustIce's new definition of what "subroutine" means.
		if (i instanceof JsrInstruction){
			InstructionHandle target = ((JsrInstruction) i).getTarget();
			if (target == instructionList.getStart()){
				throw new StaticCodeInstructionOperandConstraintException("Due to JustIce's clear definition of subroutines, no JSR or JSR_W may have a top-level instruction (such as the very first instruction, which is targeted by instruction '"+ih+"' as its target.");
			}
			if (!(target.getInstruction() instanceof ASTORE)){
				throw new StaticCodeInstructionOperandConstraintException("Due to JustIce's clear definition of subroutines, no JSR or JSR_W may target anything else than an ASTORE instruction. Instruction '"+ih+"' targets '"+target+"'.");
			}
		}
		
		// vmspec2, page 134-137
		ih.accept(v);
		
		ih = ih.getNext();
	}

    } catch (ClassNotFoundException e) {
	// FIXME: maybe not the best way to handle this
	throw new AssertionViolatedException("Missing class: " + e.toString());
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:53,代码来源:Pass3aVerifier.java

示例7: getSuccessors

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

示例8: getSuccessors

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

示例9: _getSuccessors

import org.apache.bcel.generic.JsrInstruction; //导入依赖的package包/类
/**
		 * A utility method that calculates the successors of a given InstructionHandle
		 * That means, a RET does have successors as defined here.
		 * A JsrInstruction has its target as its successor
		 * (opposed to its physical successor) as defined here.
		 */
// TODO: implement caching!
		private InstructionHandle[] _getSuccessors(){
			final InstructionHandle[] empty = new InstructionHandle[0];
			final InstructionHandle[] single = new InstructionHandle[1];
			final InstructionHandle[] pair = new InstructionHandle[2];
		
			Instruction inst = getInstruction().getInstruction();
		
			if (inst instanceof RET){
				Subroutine s = subroutines.subroutineOf(getInstruction());
				if (s==null){ //return empty; // RET in dead code. "empty" would be the correct answer, but we know something about the surrounding project...
					throw new AssertionViolatedException("Asking for successors of a RET in dead code?!");
				}
//TODO: remove
throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS?");
/*
				InstructionHandle[] jsrs = s.getEnteringJsrInstructions();
				InstructionHandle[] ret = new InstructionHandle[jsrs.length];
				for (int i=0; i<jsrs.length; i++){
					ret[i] = jsrs[i].getNext();
				}
				return ret;
*/
			}
		
			// 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] = ((JsrInstruction) inst).getTarget();
				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] = getInstruction().getNext();
					pair[1] = ((BranchInstruction) inst).getTarget();
					return pair;
				}
			}

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


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