本文整理了Java中javassist.bytecode.Bytecode.currentPc()
方法的一些代码示例,展示了Bytecode.currentPc()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.currentPc()
方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:currentPc
[英]Returns the length of bytecode sequence that have been added so far.
[中]返回到目前为止已添加的字节码序列的长度。
代码示例来源:origin: redisson/redisson
private void jsrJmp(Bytecode b) {
b.addOpcode(Opcode.GOTO);
jsrList.add(new int[] {b.currentPc(), var});
b.addIndex(0);
}
代码示例来源:origin: redisson/redisson
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);
}
代码示例来源:origin: org.javassist/javassist
private void jsrJmp(Bytecode b) {
b.addOpcode(Opcode.GOTO);
jsrList.add(new int[] {b.currentPc(), var});
b.addIndex(0);
}
代码示例来源:origin: redisson/redisson
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);
代码示例来源:origin: redisson/redisson
/**
* 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());
}
}
}
代码示例来源:origin: redisson/redisson
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;
代码示例来源:origin: org.javassist/javassist
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);
}
代码示例来源:origin: redisson/redisson
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);
}
}
代码示例来源:origin: redisson/redisson
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);
代码示例来源:origin: org.javassist/javassist
/**
* 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());
}
}
}
代码示例来源:origin: redisson/redisson
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);
代码示例来源:origin: org.javassist/javassist
@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);
}
}
代码示例来源:origin: redisson/redisson
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;
代码示例来源:origin: redisson/redisson
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;
}
}
代码示例来源:origin: redisson/redisson
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);
代码示例来源:origin: redisson/redisson
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;
}
代码示例来源:origin: redisson/redisson
int pc = bytecode.currentPc();
bytecode.addIndex(0); // correct later
if (booleanExpr(isAndAnd, bexpr.oprand2()))
bytecode.addOpcode(Opcode.GOTO);
bytecode.write16bit(pc, bytecode.currentPc() - pc + 3);
if (branchIf != isAndAnd) {
bytecode.addIndex(6); // skip GOTO instruction
代码示例来源:origin: redisson/redisson
int pc = b.currentPc();
b.addAload(var);
b.addOpcode(Opcode.ATHROW);
return b.currentPc() - pc;
代码示例来源:origin: redisson/redisson
code.addGetstatic(NULL_INTERCEPTOR_HOLDER, DEFAULT_INTERCEPTOR, HANDLER_TYPE);
code.addPutfield(thisClassName, HANDLER, HANDLER_TYPE);
int pc = code.currentPc();
代码示例来源:origin: redisson/redisson
b.addOpcode(Opcode.GOTO);
b.addIndex(oldHandler - iterator.getCodeLength()
- b.currentPc() + 1);
内容来源于网络,如有侵权,请联系作者删除!