本文整理了Java中javassist.bytecode.Bytecode.growStack()
方法的一些代码示例,展示了Bytecode.growStack()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.growStack()
方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:growStack
[英]Increases the current stack depth. It also updates max_stack
if the current stack depth is the deepest so far.
[中]增加当前堆栈深度。如果当前堆栈深度是目前为止最深的,它也会更新max_stack
。
代码示例来源:origin: redisson/redisson
/**
* Appends an 8bit opcode to the end of the bytecode sequence.
* The current stack depth is updated.
* <code>max_stack</code> is updated if the current stack depth
* is the deepest so far.
*
* <p>Note: some instructions such as INVOKEVIRTUAL does not
* update the current stack depth since the increment depends
* on the method signature.
* <code>growStack()</code> must be explicitly called.
*/
public void addOpcode(int code) {
add(code);
growStack(STACK_GROW[code]);
}
代码示例来源:origin: redisson/redisson
/**
* Appends MULTINEWARRAY.
*
* @param clazz the array type.
* @param dimensions the sizes of all dimensions.
* @return the length of <code>dimensions</code>.
*/
public int addMultiNewarray(CtClass clazz, int[] dimensions) {
int len = dimensions.length;
for (int i = 0; i < len; ++i)
addIconst(dimensions[i]);
growStack(len);
return addMultiNewarray(clazz, len);
}
代码示例来源:origin: redisson/redisson
/**
* Appends INVOKESPECIAL.
*
* @param index the index of <code>CONSTANT_Methodref_info</code>
* or <code>CONSTANT_InterfaceMethodref_info</code>
* @param desc the descriptor of the method signature.
*
* @see Descriptor#ofMethod(CtClass,CtClass[])
* @see Descriptor#ofConstructor(CtClass[])
*/
public void addInvokespecial(int index, String desc) {
add(INVOKESPECIAL);
addIndex(index);
growStack(Descriptor.dataSize(desc) - 1);
}
代码示例来源:origin: redisson/redisson
/**
* Appends MULTINEWARRAY.
*
* @param desc the type descriptor of the created array.
* @param dim dimensions.
* @return the value of <code>dim</code>.
*/
public int addMultiNewarray(String desc, int dim) {
add(MULTIANEWARRAY);
addIndex(constPool.addClassInfo(desc));
add(dim);
growStack(1 - dim);
return dim;
}
代码示例来源:origin: redisson/redisson
/**
* Appends MULTINEWARRAY. The size of every dimension must have been
* already pushed on the stack.
*
* @param clazz the array type.
* @param dim the number of the dimensions.
* @return the value of <code>dim</code>.
*/
public int addMultiNewarray(CtClass clazz, int dim) {
add(MULTIANEWARRAY);
addIndex(constPool.addClassInfo(clazz));
add(dim);
growStack(1 - dim);
return dim;
}
代码示例来源:origin: redisson/redisson
private void addInvokestatic(int clazz, String name, String desc,
boolean isInterface) {
add(INVOKESTATIC);
int index;
if (isInterface)
index = constPool.addInterfaceMethodrefInfo(clazz, name, desc);
else
index = constPool.addMethodrefInfo(clazz, name, desc);
addIndex(index);
growStack(Descriptor.dataSize(desc));
}
代码示例来源:origin: redisson/redisson
/**
* Appends INVOKEVIRTUAL.
*
* <p>The specified method must not be an inherited method.
* It must be directly declared in the class specified
* by <code>clazz</code>.
*
* @param clazz the index of <code>CONSTANT_Class_info</code>
* structure.
* @param name the method name
* @param desc the descriptor of the method signature.
*
* @see Descriptor#ofMethod(CtClass,CtClass[])
*/
public void addInvokevirtual(int clazz, String name, String desc) {
add(INVOKEVIRTUAL);
addIndex(constPool.addMethodrefInfo(clazz, name, desc));
growStack(Descriptor.dataSize(desc) - 1);
}
代码示例来源:origin: redisson/redisson
/**
* Appends GETFIELD.
*
* @param c the class.
* @param name the field name.
* @param type the descriptor of the field type.
*
* @see Descriptor#of(CtClass)
*/
public void addGetfield(CtClass c, String name, String type) {
add(GETFIELD);
int ci = constPool.addClassInfo(c);
addIndex(constPool.addFieldrefInfo(ci, name, type));
growStack(Descriptor.dataSize(type) - 1);
}
代码示例来源:origin: redisson/redisson
/**
* Appends GETSTATIC.
*
* @param c the class
* @param name the field name
* @param type the descriptor of the field type.
*
* @see Descriptor#of(CtClass)
*/
public void addGetstatic(CtClass c, String name, String type) {
add(GETSTATIC);
int ci = constPool.addClassInfo(c);
addIndex(constPool.addFieldrefInfo(ci, name, type));
growStack(Descriptor.dataSize(type));
}
代码示例来源:origin: redisson/redisson
/**
* Appends GETFIELD.
*
* @param c the fully-qualified class name.
* @param name the field name.
* @param type the descriptor of the field type.
*
* @see Descriptor#of(CtClass)
*/
public void addGetfield(String c, String name, String type) {
add(GETFIELD);
int ci = constPool.addClassInfo(c);
addIndex(constPool.addFieldrefInfo(ci, name, type));
growStack(Descriptor.dataSize(type) - 1);
}
代码示例来源:origin: redisson/redisson
/**
* Appends GETSTATIC.
*
* @param c the fully-qualified class name
* @param name the field name
* @param type the descriptor of the field type.
*
* @see Descriptor#of(CtClass)
*/
public void addGetstatic(String c, String name, String type) {
add(GETSTATIC);
int ci = constPool.addClassInfo(c);
addIndex(constPool.addFieldrefInfo(ci, name, type));
growStack(Descriptor.dataSize(type));
}
代码示例来源:origin: redisson/redisson
private void addPutstatic0(CtClass target, String classname,
String fieldName, String desc) {
add(PUTSTATIC);
// target is null if it represents THIS.
int ci = classname == null ? constPool.addClassInfo(target)
: constPool.addClassInfo(classname);
addIndex(constPool.addFieldrefInfo(ci, fieldName, desc));
growStack(-Descriptor.dataSize(desc));
}
代码示例来源:origin: redisson/redisson
private void addPutfield0(CtClass target, String classname,
String name, String desc) {
add(PUTFIELD);
// target is null if it represents THIS.
int ci = classname == null ? constPool.addClassInfo(target)
: constPool.addClassInfo(classname);
addIndex(constPool.addFieldrefInfo(ci, name, desc));
growStack(-1 - Descriptor.dataSize(desc));
}
代码示例来源:origin: org.javassist/javassist
private void addInvokestatic(int clazz, String name, String desc,
boolean isInterface) {
add(INVOKESTATIC);
int index;
if (isInterface)
index = constPool.addInterfaceMethodrefInfo(clazz, name, desc);
else
index = constPool.addMethodrefInfo(clazz, name, desc);
addIndex(index);
growStack(Descriptor.dataSize(desc));
}
代码示例来源:origin: redisson/redisson
/**
* Appends INVOKEDYNAMIC.
*
* @param bootstrap an index into the <code>bootstrap_methods</code> array
* of the bootstrap method table.
* @param name the method name.
* @param desc the method descriptor.
* @see Descriptor#ofMethod(CtClass,CtClass[])
* @since 3.17
*/
public void addInvokedynamic(int bootstrap, String name, String desc) {
int nt = constPool.addNameAndTypeInfo(name, desc);
int dyn = constPool.addInvokeDynamicInfo(bootstrap, nt);
add(INVOKEDYNAMIC);
addIndex(dyn);
add(0, 0);
growStack(Descriptor.dataSize(desc)); // assume ConstPool#REF_invokeStatic
}
代码示例来源:origin: redisson/redisson
/**
* Appends INVOKEINTERFACE.
*
* @param clazz the index of <code>CONSTANT_Class_info</code>
* structure.
* @param name the method name
* @param desc the descriptor of the method signature.
* @param count the count operand of the instruction.
*
* @see Descriptor#ofMethod(CtClass,CtClass[])
*/
public void addInvokeinterface(int clazz, String name,
String desc, int count) {
add(INVOKEINTERFACE);
addIndex(constPool.addInterfaceMethodrefInfo(clazz, name, desc));
add(count);
add(0);
growStack(Descriptor.dataSize(desc) - 1);
}
代码示例来源:origin: org.javassist/javassist
private void addPutfield0(CtClass target, String classname,
String name, String desc) {
add(PUTFIELD);
// target is null if it represents THIS.
int ci = classname == null ? constPool.addClassInfo(target)
: constPool.addClassInfo(classname);
addIndex(constPool.addFieldrefInfo(ci, name, desc));
growStack(-1 - Descriptor.dataSize(desc));
}
代码示例来源:origin: org.javassist/javassist
private void addPutstatic0(CtClass target, String classname,
String fieldName, String desc) {
add(PUTSTATIC);
// target is null if it represents THIS.
int ci = classname == null ? constPool.addClassInfo(target)
: constPool.addClassInfo(classname);
addIndex(constPool.addFieldrefInfo(ci, fieldName, desc));
growStack(-Descriptor.dataSize(desc));
}
代码示例来源:origin: redisson/redisson
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
throws CompileError
{
if (args != null && !gen.isParamListName(args))
throw new CompileError(Javac.proceedName
+ "() cannot take a parameter for field reading");
int stack;
if (isStatic(opcode))
stack = 0;
else {
stack = -1;
bytecode.addAload(targetVar);
}
if (fieldType instanceof CtPrimitiveType)
stack += ((CtPrimitiveType)fieldType).getDataSize();
else
++stack;
bytecode.add(opcode);
bytecode.addIndex(index);
bytecode.growStack(stack);
gen.setType(fieldType);
}
代码示例来源:origin: redisson/redisson
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
throws CompileError
{
int num = gen.getMethodArgsLength(args);
if (num != dimension)
throw new CompileError(Javac.proceedName
+ "() with a wrong number of parameters");
gen.atMethodArgs(args, new int[num],
new int[num], new String[num]);
bytecode.addOpcode(opcode);
if (opcode == Opcode.ANEWARRAY)
bytecode.addIndex(index);
else if (opcode == Opcode.NEWARRAY)
bytecode.add(index);
else /* if (opcode == Opcode.MULTIANEWARRAY) */ {
bytecode.addIndex(index);
bytecode.add(dimension);
bytecode.growStack(1 - dimension);
}
gen.setType(arrayType);
}
内容来源于网络,如有侵权,请联系作者删除!