com.sun.org.apache.bcel.internal.generic.Select Java Examples
The following examples show how to use
com.sun.org.apache.bcel.internal.generic.Select.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BCELFactory.java From Bytecoder with Apache License 2.0 | 6 votes |
private void updateBranchTargets() { for (final BranchInstruction bi : branches) { final BranchHandle bh = (BranchHandle) branch_map.get(bi); final int pos = bh.getPosition(); final String name = bi.getName() + "_" + pos; int t_pos = bh.getTarget().getPosition(); _out.println(" " + name + ".setTarget(ih_" + t_pos + ");"); if (bi instanceof Select) { final 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 + ");"); } } } }
Example #2
Source File: BCELFactory.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override public void visitBranchInstruction( final BranchInstruction bi ) { final BranchHandle bh = (BranchHandle) branch_map.get(bi); final int pos = bh.getPosition(); final String name = bi.getName() + "_" + pos; if (bi instanceof Select) { final Select s = (Select) bi; branches.add(bi); final StringBuilder args = new StringBuilder("new int[] { "); final 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 { final 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(" + CONSTANT_PREFIX + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target + ");"); } if (bh.hasTargeters()) { _out.println(" ih_" + pos + " = il.append(" + name + ");"); } else { _out.println(" il.append(" + name + ");"); } }