Java Code Examples for org.apache.bcel.generic.InstructionList#getStart()
The following examples show how to use
org.apache.bcel.generic.InstructionList#getStart() .
These examples are extracted from open source projects.
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 Project: spotbugs File: BetterCFGBuilder2.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void build() throws CFGBuilderException { InstructionList instructionList = methodGen.getInstructionList(); optimize(instructionList); topLevelSubroutine = new Subroutine(instructionList.getStart()); subroutineWorkList.add(topLevelSubroutine); // Build top level subroutine and all JSR subroutines while (!subroutineWorkList.isEmpty()) { Subroutine subroutine = subroutineWorkList.removeFirst(); if (DEBUG) { System.out.println("Starting subroutine " + subroutine.getStartInstruction()); } build(subroutine); } // Inline everything into the top level subroutine cfg = inlineAll(); // Add a NOP instruction to the entry block. // This allows analyses to construct a Location // representing the entry to the method. BasicBlock entryBlock = cfg.getEntry(); InstructionList il = new InstructionList(); entryBlock.addInstruction(il.append(new NOP())); cfg.checkIntegrity(); }
Example 2
Source Project: annotation-tools File: BCELPerfTest.java License: MIT License | 5 votes |
byte[] nullAdaptClass(final InputStream is, final String name) throws Exception { JavaClass jc = new ClassParser(is, name + ".class").parse(); ClassGen cg = new ClassGen(jc); ConstantPoolGen cp = cg.getConstantPool(); Method[] ms = cg.getMethods(); for (int j = 0; j < ms.length; ++j) { MethodGen mg = new MethodGen(ms[j], cg.getClassName(), cp); boolean lv = ms[j].getLocalVariableTable() == null; boolean ln = ms[j].getLineNumberTable() == null; if (lv) { mg.removeLocalVariables(); } if (ln) { mg.removeLineNumbers(); } mg.stripAttributes(skipDebug); InstructionList il = mg.getInstructionList(); if (il != null) { InstructionHandle ih = il.getStart(); while (ih != null) { ih = ih.getNext(); } if (compute) { mg.setMaxStack(); mg.setMaxLocals(); } } cg.replaceMethod(ms[j], mg.getMethod()); } return cg.getJavaClass().getBytes(); }
Example 3
Source Project: annotation-tools File: BCELPerfTest.java License: MIT License | 5 votes |
byte[] nullAdaptClass(final InputStream is, final String name) throws Exception { JavaClass jc = new ClassParser(is, name + ".class").parse(); ClassGen cg = new ClassGen(jc); ConstantPoolGen cp = cg.getConstantPool(); Method[] ms = cg.getMethods(); for (int j = 0; j < ms.length; ++j) { MethodGen mg = new MethodGen(ms[j], cg.getClassName(), cp); boolean lv = ms[j].getLocalVariableTable() == null; boolean ln = ms[j].getLineNumberTable() == null; if (lv) { mg.removeLocalVariables(); } if (ln) { mg.removeLineNumbers(); } mg.stripAttributes(skipDebug); InstructionList il = mg.getInstructionList(); if (il != null) { InstructionHandle ih = il.getStart(); while (ih != null) { ih = ih.getNext(); } if (compute) { mg.setMaxStack(); mg.setMaxLocals(); } } cg.replaceMethod(ms[j], mg.getMethod()); } return cg.getJavaClass().getBytes(); }
Example 4
Source Project: commons-bcel File: ASTLetExpr.java License: Apache License 2.0 | 5 votes |
/** * Fifth pass, produce Java byte code. */ @Override public void byte_code(final InstructionList il, final MethodGen method, final ConstantPoolGen cp) { final int size = idents.length; final LocalVariableGen[] l = new LocalVariableGen[size]; for(int i=0; i < size; i++) { final String ident = idents[i].getName(); final Variable entry = (Variable)env.get(ident); final Type t = BasicType.getType((byte)idents[i].getType()); final LocalVariableGen lg = method.addLocalVariable(ident, t, null, null); final int slot = lg.getIndex(); entry.setLocalVariable(lg); InstructionHandle start = il.getEnd(); exprs[i].byte_code(il, method, cp); start = (start == null)? il.getStart() : start.getNext(); lg.setStart(start); il.append(new ISTORE(slot)); ASTFunDecl.pop(); l[i] = lg; } body.byte_code(il, method, cp); final InstructionHandle end = il.getEnd(); for(int i=0; i < size; i++) { l[i].setEnd(end); } }