private void jsrJmp(Bytecode b) { b.addOpcode(Opcode.GOTO); jsrList.add(new int[] {b.currentPc(), var}); b.addIndex(0); }
private void atBreakStmnt(Stmnt st, boolean notCont) throws CompileError { if (st.head() != null) throw new CompileError( "sorry, not support labeled break or continue"); bytecode.addOpcode(Opcode.GOTO); Integer pc = new Integer(bytecode.currentPc()); bytecode.addIndex(0); if (notCont) breakList.add(pc); else continueList.add(pc); }
private void jsrJmp(Bytecode b) { b.addOpcode(Opcode.GOTO); jsrList.add(new int[] {b.currentPc(), var}); b.addIndex(0); }
protected void atClassObject2(String cname) throws CompileError { int start = bytecode.currentPc(); bytecode.addLdc(cname); bytecode.addInvokestatic("java.lang.Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;"); int end = bytecode.currentPc(); bytecode.addOpcode(Opcode.GOTO); int pc = bytecode.currentPc(); bytecode.addIndex(0); // correct later bytecode.addExceptionHandler(start, end, bytecode.currentPc(), "java.lang.ClassNotFoundException"); + "Ljava/lang/NoClassDefFoundError;"); bytecode.addOpcode(ATHROW); bytecode.write16bit(pc, bytecode.currentPc() - pc + 1);
/** * Adds a finally clause for earch return statement. */ private void addFinally(ArrayList returnList, Stmnt finallyBlock) throws CompileError { Bytecode bc = bytecode; int n = returnList.size(); for (int i = 0; i < n; ++i) { final int[] ret = (int[])returnList.get(i); int pc = ret[0]; bc.write16bit(pc, bc.currentPc() - pc + 1); ReturnHook hook = new JsrHook2(this, ret); finallyBlock.accept(this); hook.remove(this); if (!hasReturned) { bc.addOpcode(Opcode.GOTO); bc.addIndex(pc + 3 - bc.currentPc()); } } }
if (notDo) { bytecode.addOpcode(Opcode.GOTO); pc = bytecode.currentPc(); bytecode.addIndex(0); int pc2 = bytecode.currentPc(); if (body != null) body.accept(this); int pc3 = bytecode.currentPc(); if (notDo) bytecode.write16bit(pc, pc3 - pc + 1); bytecode.addIndex(pc2 - bytecode.currentPc() + 1); patchGoto(breakList, bytecode.currentPc()); patchGoto(continueList, pc3); continueList = prevContList;
private void atBreakStmnt(Stmnt st, boolean notCont) throws CompileError { if (st.head() != null) throw new CompileError( "sorry, not support labeled break or continue"); bytecode.addOpcode(Opcode.GOTO); Integer pc = Integer.valueOf(bytecode.currentPc()); bytecode.addIndex(0); if (notCont) breakList.add(pc); else continueList.add(pc); }
public void atCondExpr(CondExpr expr) throws CompileError { if (booleanExpr(false, expr.condExpr())) expr.elseExpr().accept(this); else { int pc = bytecode.currentPc(); bytecode.addIndex(0); // correct later expr.thenExpr().accept(this); int dim1 = arrayDim; bytecode.addOpcode(Opcode.GOTO); int pc2 = bytecode.currentPc(); bytecode.addIndex(0); bytecode.write16bit(pc, bytecode.currentPc() - pc + 1); expr.elseExpr().accept(this); if (dim1 != arrayDim) throw new CompileError("type mismatch in ?:"); bytecode.write16bit(pc2, bytecode.currentPc() - pc2 + 1); } }
init.accept(this); int pc = bytecode.currentPc(); int pc2 = 0; if (expr != null) { pc2 = bytecode.currentPc(); bytecode.addIndex(0); body.accept(this); int pc3 = bytecode.currentPc(); if (update != null) update.accept(this); bytecode.addIndex(pc - bytecode.currentPc() + 1); int pc4 = bytecode.currentPc(); if (expr != null) bytecode.write16bit(pc2, pc4 - pc2 + 1);
/** * Adds a finally clause for earch return statement. */ private void addFinally(List<int[]> returnList, Stmnt finallyBlock) throws CompileError { Bytecode bc = bytecode; for (final int[] ret:returnList) { int pc = ret[0]; bc.write16bit(pc, bc.currentPc() - pc + 1); ReturnHook hook = new JsrHook2(this, ret); finallyBlock.accept(this); hook.remove(this); if (!hasReturned) { bc.addOpcode(Opcode.GOTO); bc.addIndex(pc + 3 - bc.currentPc()); } } }
int pc = bytecode.currentPc(); int pc2 = 0; bytecode.addIndex(0); // correct later pc2 = bytecode.currentPc(); bytecode.addIndex(0); bytecode.write16bit(pc, bytecode.currentPc() - pc + 1); if (elsep != null) { elsep.accept(this); if (!thenHasReturned) bytecode.write16bit(pc2, bytecode.currentPc() - pc2 + 1);
@Override public void atCondExpr(CondExpr expr) throws CompileError { if (booleanExpr(false, expr.condExpr())) expr.elseExpr().accept(this); else { int pc = bytecode.currentPc(); bytecode.addIndex(0); // correct later expr.thenExpr().accept(this); int dim1 = arrayDim; bytecode.addOpcode(Opcode.GOTO); int pc2 = bytecode.currentPc(); bytecode.addIndex(0); bytecode.write16bit(pc, bytecode.currentPc() - pc + 1); expr.elseExpr().accept(this); if (dim1 != arrayDim) throw new CompileError("type mismatch in ?:"); bytecode.write16bit(pc2, bytecode.currentPc() - pc2 + 1); } }
int opcodePc = bytecode.currentPc(); bytecode.addOpcode(LOOKUPSWITCH); int npads = 3 - (opcodePc & 3); int opcodePc2 = bytecode.currentPc(); bytecode.addGap(4); bytecode.add32bit(npairs); int op = label.getOperator(); if (op == DEFAULT) defaultPc = bytecode.currentPc(); else if (op != CASE) fatal(); pairs[ipairs++] = ((long)computeLabel(label.head()) << 32) + ((long)(bytecode.currentPc() - opcodePc) & 0xffffffff); hasReturned = false; int endPc = bytecode.currentPc(); if (defaultPc < 0) defaultPc = endPc;
protected boolean doit(Bytecode b, int opcode) { switch (opcode) { case Opcode.RETURN : break; case ARETURN : b.addAstore(var); break; case IRETURN : b.addIstore(var); break; case LRETURN : b.addLstore(var); break; case DRETURN : b.addDstore(var); break; case FRETURN : b.addFstore(var); break; default : throw new RuntimeException("fatal"); } b.addOpcode(Opcode.GOTO); b.addIndex(target - b.currentPc() + 3); return true; } }
int pc = bc.currentPc(); Stmnt body = (Stmnt)st.tail(); if (body != null) body.accept(this); int pc2 = bc.currentPc(); int pc3 = 0; if (!hasReturned) { rh.doit(bc, 0); // the 2nd arg is ignored. bc.addOpcode(Opcode.GOTO); pc3 = bc.currentPc(); bc.addIndex(0); int pc4 = bc.currentPc(); rh.doit(bc, 0); // the 2nd arg is ignored. bc.addOpcode(ATHROW); bc.write16bit(pc3, bc.currentPc() - pc3 + 1);
private int insertAfterAdvice(Bytecode code, Javac jv, String src, ConstPool cp, CtClass rtype, int varNo) throws CompileError { int pc = code.currentPc(); if (rtype == CtClass.voidType) { code.addOpcode(Opcode.ACONST_NULL); code.addAstore(varNo); jv.compileStmnt(src); code.addOpcode(Opcode.RETURN); if (code.getMaxLocals() < 1) code.setMaxLocals(1); } else { code.addStore(varNo, rtype); jv.compileStmnt(src); code.addLoad(varNo, rtype); if (rtype.isPrimitive()) code.addOpcode(((CtPrimitiveType)rtype).getReturnOp()); else code.addOpcode(Opcode.ARETURN); } return code.currentPc() - pc; }
code.addGetstatic(NULL_INTERCEPTOR_HOLDER, DEFAULT_INTERCEPTOR, HANDLER_TYPE); code.addPutfield(thisClassName, HANDLER, HANDLER_TYPE); int pc = code.currentPc();
b.addOpcode(Opcode.GOTO); b.addIndex(oldHandler - iterator.getCodeLength() - b.currentPc() + 1);