• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Select类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: visitSelect

import org.apache.bcel.generic.Select; //导入依赖的package包/类
@Override
public void visitSelect(Select ins) {
    isBranch = true;

    // Add non-default switch edges.
    InstructionHandle[] targets = ins.getTargets();
    for (InstructionHandle target : targets) {
        targetList.add(new Target(target, SWITCH_EDGE));
    }

    // Add default switch edge.
    InstructionHandle defaultTarget = ins.getTarget();
    if (defaultTarget == null) {
        throw new IllegalStateException();
    }
    targetList.add(new Target(defaultTarget, SWITCH_DEFAULT_EDGE));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:18,代码来源:TargetEnumeratingVisitor.java


示例2: updateBranchTargets

import org.apache.bcel.generic.Select; //导入依赖的package包/类
private void updateBranchTargets() {
    for (Iterator i = branches.iterator(); i.hasNext();) {
        BranchInstruction bi = (BranchInstruction) i.next();
        BranchHandle bh = (BranchHandle) branch_map.get(bi);
        int pos = bh.getPosition();
        String name = bi.getName() + "_" + pos;
        int t_pos = bh.getTarget().getPosition();
        _out.println("    " + name + ".setTarget(ih_" + t_pos + ");");
        if (bi instanceof Select) {
            InstructionHandle[] ihs = ((Select) bi).getTargets();
            for (int j = 0; j < ihs.length; j++) {
                t_pos = ihs[j].getPosition();
                _out.println("    " + name + ".setTarget(" + j + ", ih_" + t_pos + ");");
            }
        }
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:18,代码来源:BCELFactory.java


示例3: getSuccessors

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


示例4: visitBranchInstruction

import org.apache.bcel.generic.Select; //导入依赖的package包/类
public void visitBranchInstruction( BranchInstruction bi ) {
    BranchHandle bh = (BranchHandle) branch_map.get(bi);
    int pos = bh.getPosition();
    String name = bi.getName() + "_" + pos;
    if (bi instanceof Select) {
        Select s = (Select) bi;
        branches.add(bi);
        StringBuffer args = new StringBuffer("new int[] { ");
        int[] matchs = s.getMatchs();
        for (int i = 0; i < matchs.length; i++) {
            args.append(matchs[i]);
            if (i < matchs.length - 1) {
                args.append(", ");
            }
        }
        args.append(" }");
        _out.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH)
                + "(" + args + ", new InstructionHandle[] { ");
        for (int i = 0; i < matchs.length; i++) {
            _out.print("null");
            if (i < matchs.length - 1) {
                _out.print(", ");
            }
        }
        _out.println(" }, null);");
    } else {
        int t_pos = bh.getTarget().getPosition();
        String target;
        if (pos > t_pos) {
            target = "ih_" + t_pos;
        } else {
            branches.add(bi);
            target = "null";
        }
        _out.println("    BranchInstruction " + name + " = _factory.createBranchInstruction("
                + "Constants." + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target
                + ");");
    }
    if (bh.hasTargeters()) {
        _out.println("    ih_" + pos + " = il.append(" + name + ");");
    } else {
        _out.println("    il.append(" + name + ");");
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:45,代码来源:BCELFactory.java


示例5: visitCode

import org.apache.bcel.generic.Select; //导入依赖的package包/类
public void visitCode(Code code) {
	MethodGen mg = new MethodGen(_method, clazzname, cp);
	InstructionList il = mg.getInstructionList();
	InstructionHandle[] ihs = il.getInstructionHandles();

	LocalVariableGen[] lvs = mg.getLocalVariables();

	CodeExceptionGen[] ehs = mg.getExceptionHandlers();

	for (int i = 0; i < lvs.length; i++) {
		LocalVariableGen l = lvs[i];
		out.println("    // local variable " + l.getIndex() + " is \"" + l.getName()
				+ "\" " + l.getType() + " from "
				+ l.getStart().getPosition() + " to "
				+ l.getEnd().getPosition());
	}

	out.print("\n");

	for (int i = 0; i < ihs.length; i++) {
		InstructionHandle ih = ihs[i];
		Instruction inst = ih.getInstruction();

		out.print("    " + ih.getPosition());

		if (inst instanceof BranchInstruction) {
			if (inst instanceof Select) { // Special cases LOOKUPSWITCH and
										  // TABLESWITCH
				Select s = (Select) inst;
				int[] matchs = s.getMatchs();
				InstructionHandle[] targets = s.getTargets();

				if (s instanceof TABLESWITCH) {
					out.println("  tableswitch " + matchs[0] + " "
							+ matchs[matchs.length - 1]);

					for (int j = 0; j < targets.length; j++)
						out.println("        " + targets[j].getPosition());

				} else { // LOOKUPSWITCH
					out.println("  lookupswitch ");

					for (int j = 0; j < targets.length; j++)
						out.println("        " + matchs[j] + " : "
								+ targets[j].getPosition());
				}

				out.println("        default: " + s.getTarget()); // Applies
																  // for
																  // both
			} else {
				BranchInstruction bi = (BranchInstruction) inst;
				ih = bi.getTarget();
				//str = get(ih);
				out.println("  " + Constants.OPCODE_NAMES[bi.getOpcode()]
						+ " " + ih);
			}
		} else
			out.println("  " + inst.toString(cp.getConstantPool()));
	}

	out.print("\n");

	for (int i = 0; i < ehs.length; i++) {
		CodeExceptionGen c = ehs[i];
		ObjectType caught = c.getCatchType();
		String class_name = (caught == null) ? // catch any exception, used
											   // when compiling finally
				"all" : caught.getClassName().replace('.', '/');

		out.println("    catch " + class_name + " from "
				+ c.getStartPC().getPosition() + " to "
				+ c.getEndPC().getPosition() + " using "
				+ c.getHandlerPC().getPosition());
	}
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:77,代码来源:DecompilingVisitor.java


示例6: getSuccessors

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


示例7: _getSuccessors

import org.apache.bcel.generic.Select; //导入依赖的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.Select类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntsRefBuilder类代码示例发布时间:2022-05-23
下一篇:
Java PutObjectResult类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap