本文整理了Java中javassist.bytecode.Bytecode.addOpcode()
方法的一些代码示例,展示了Bytecode.addOpcode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.addOpcode()
方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:addOpcode
[英]Appends an 8bit opcode to the end of the bytecode sequence. The current stack depth is updated. max_stack
is updated if the current stack depth is the deepest so far.
Note: some instructions such as INVOKEVIRTUAL does not update the current stack depth since the increment depends on the method signature. growStack()
must be explicitly called.
[中]将8位操作码追加到字节码序列的末尾。将更新当前堆栈深度。如果当前堆栈深度是迄今为止最深的,则更新max_stack
。
注意:某些指令(如INVOKEVIRTUAL)不会更新当前堆栈深度,因为增量取决于方法签名。必须显式调用growStack()
。
代码示例来源:origin: redisson/redisson
public void addNullIfVoid() {
if (exprType == VOID) {
bytecode.addOpcode(ACONST_NULL);
exprType = CLASS;
arrayDim = 0;
className = jvmJavaLangObject;
}
}
代码示例来源:origin: redisson/redisson
/**
* Appends DCONST or DCONST_<n>
*
* @param d the pushed double constant.
*/
public void addDconst(double d) {
if (d == 0.0 || d == 1.0)
addOpcode(14 + (int)d); // dconst_<n>
else
addLdc2w(d);
}
代码示例来源:origin: redisson/redisson
private void atArrayLength(ASTree expr) throws CompileError {
if (arrayDim == 0)
throw new CompileError(".length applied to a non array");
bytecode.addOpcode(ARRAYLENGTH);
exprType = INT;
arrayDim = 0;
}
代码示例来源:origin: redisson/redisson
/**
* Appends LCONST or LCONST_<n>
*
* @param n the pushed long integer constant.
*/
public void addLconst(long n) {
if (n == 0 || n == 1)
addOpcode(9 + (int)n); // lconst_<n>
else
addLdc2w(n);
}
代码示例来源:origin: redisson/redisson
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
throws CompileError
{
bytecode.addOpcode(NEW);
bytecode.addIndex(newIndex);
bytecode.addOpcode(DUP);
gen.atMethodCallCore(newType, MethodInfo.nameInit, args,
false, true, -1, null);
gen.setType(newType);
}
代码示例来源: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
/**
* Appends CHECKCAST.
*
* @param classname a fully-qualified class name.
*/
public void addCheckcast(String classname) {
addOpcode(CHECKCAST);
addIndex(constPool.addClassInfo(classname));
}
代码示例来源:origin: redisson/redisson
/**
* Appends ANEWARRAY.
*
* @param classname the qualified class name of the element type.
*/
public void addAnewarray(String classname) {
addOpcode(ANEWARRAY);
addIndex(constPool.addClassInfo(classname));
}
代码示例来源:origin: redisson/redisson
protected void atReturnStmnt(Stmnt st) throws CompileError {
ASTree result = st.getLeft();
if (result != null && returnType == CtClass.voidType) {
compileExpr(result);
if (is2word(exprType, arrayDim))
bytecode.addOpcode(POP2);
else if (exprType != VOID)
bytecode.addOpcode(POP);
result = null;
}
atReturnStmnt2(result);
}
代码示例来源:origin: redisson/redisson
public void atArrayRead(ASTree array, ASTree index)
throws CompileError
{
arrayAccess(array, index);
bytecode.addOpcode(getArrayReadOp(exprType, arrayDim));
}
代码示例来源:origin: redisson/redisson
/**
* Appends CHECKCAST.
*
* @param c the type.
*/
public void addCheckcast(CtClass c) {
addOpcode(CHECKCAST);
addIndex(constPool.addClassInfo(c));
}
代码示例来源:origin: redisson/redisson
/**
* Appends INSTANCEOF.
*
* @param classname the class name.
*/
public void addInstanceof(String classname) {
addOpcode(INSTANCEOF);
addIndex(constPool.addClassInfo(classname));
}
代码示例来源:origin: redisson/redisson
/**
* Appends NEW.
*
* @param clazz the class of the created instance.
*/
public void addNew(CtClass clazz) {
addOpcode(NEW);
addIndex(constPool.addClassInfo(clazz));
}
代码示例来源:origin: redisson/redisson
static final void storeStack(CtClass[] params, boolean isStaticCall,
int regno, Bytecode bytecode) {
storeStack0(0, params.length, params, regno + 1, bytecode);
if (isStaticCall)
bytecode.addOpcode(ACONST_NULL);
bytecode.addAstore(regno);
}
代码示例来源:origin: redisson/redisson
/**
* Appends FCONST or FCONST_<n>
*
* @param f the pushed float constant.
*/
public void addFconst(float f) {
if (f == 0.0f || f == 1.0f || f == 2.0f)
addOpcode(11 + (int)f); // fconst_<n>
else
addLdc(constPool.addFloatInfo(f));
}
代码示例来源:origin: redisson/redisson
/**
* Appends LDC2_W. The pushed item is a double value.
*/
public void addLdc2w(double d) {
addOpcode(LDC2_W);
addIndex(constPool.addDoubleInfo(d));
}
代码示例来源:origin: redisson/redisson
private void atThrowStmnt(Stmnt st) throws CompileError {
ASTree e = st.getLeft();
compileExpr(e);
if (exprType != CLASS || arrayDim > 0)
throw new CompileError("bad throw statement");
bytecode.addOpcode(ATHROW);
hasReturned = true;
}
代码示例来源:origin: redisson/redisson
/**
* Appends ICONST and ANEWARRAY.
*
* @param clazz the elememnt type.
* @param length the array length.
*/
public void addAnewarray(CtClass clazz, int length) {
addIconst(length);
addOpcode(ANEWARRAY);
addIndex(constPool.addClassInfo(clazz));
}
代码示例来源:origin: redisson/redisson
private static int makeWrapper(Bytecode code, Class type, int regno) {
int index = FactoryHelper.typeIndex(type);
String wrapper = FactoryHelper.wrapperTypes[index];
code.addNew(wrapper);
code.addOpcode(Opcode.DUP);
addLoad(code, regno, type);
code.addInvokespecial(wrapper, "<init>",
FactoryHelper.wrapperDesc[index]);
return regno + FactoryHelper.dataSize[index];
}
代码示例来源:origin: redisson/redisson
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
throws CompileError
{
if (gen.getMethodArgsLength(args) != 1)
throw new CompileError(Javac.proceedName
+ "() cannot take more than one parameter "
+ "for cast");
gen.atMethodArgs(args, new int[1], new int[1], new String[1]);
bytecode.addOpcode(Opcode.CHECKCAST);
bytecode.addIndex(index);
gen.setType(retType);
}
内容来源于网络,如有侵权,请联系作者删除!