本文整理了Java中javassist.bytecode.Bytecode.addIconst()
方法的一些代码示例,展示了Bytecode.addIconst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.addIconst()
方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:addIconst
[英]Appends ICONST or ICONST_<n>
[中]附加ICONST或ICONST\un>
代码示例来源:origin: redisson/redisson
int compile(Bytecode code) throws CannotCompileException {
code.addIconst(param);
return 1;
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(Bytecode code) throws CannotCompileException {
code.addIconst(param);
return 1;
}
代码示例来源:origin: redisson/redisson
/**
* Appends NEWARRAY for primitive types.
*
* @param atype <code>T_BOOLEAN</code>, <code>T_CHAR</code>, ...
* @see Opcode
*/
public void addNewarray(int atype, int length) {
addIconst(length);
addOpcode(NEWARRAY);
add(atype);
}
代码示例来源:origin: redisson/redisson
int compileIfStatic(CtClass type, String name, Bytecode code,
Javac drv) throws CannotCompileException
{
code.addIconst(value);
code.addPutstatic(Bytecode.THIS, name, Descriptor.of(type));
return 1; // stack size
}
代码示例来源: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
protected final int compileStringParameter(Bytecode code)
throws CannotCompileException
{
int nparam = stringParams.length;
code.addIconst(nparam);
code.addAnewarray(javaLangString);
for (int j = 0; j < nparam; ++j) {
code.add(Bytecode.DUP); // dup
code.addIconst(j); // iconst_<j>
code.addLdc(stringParams[j]); // ldc ...
code.add(Bytecode.AASTORE); // aastore
}
return 4;
}
代码示例来源:origin: redisson/redisson
private static void makeParameterList(Bytecode code, Class[] params) {
int regno = 1;
int n = params.length;
code.addIconst(n);
code.addAnewarray("java/lang/Object");
for (int i = 0; i < n; i++) {
code.addOpcode(Opcode.DUP);
code.addIconst(i);
Class type = params[i];
if (type.isPrimitive())
regno = makeWrapper(code, type, regno);
else {
code.addAload(regno);
regno++;
}
code.addOpcode(Opcode.AASTORE);
}
}
代码示例来源:origin: org.javassist/javassist
/**
* Appends NEWARRAY for primitive types.
*
* @param atype <code>T_BOOLEAN</code>, <code>T_CHAR</code>, ...
* @see Opcode
*/
public void addNewarray(int atype, int length) {
addIconst(length);
addOpcode(NEWARRAY);
add(atype);
}
代码示例来源:origin: org.javassist/javassist
@Override
int compileIfStatic(CtClass type, String name, Bytecode code,
Javac drv) throws CannotCompileException
{
code.addIconst(value);
code.addPutstatic(Bytecode.THIS, name, Descriptor.of(type));
return 1; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addIconst(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源: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
public void atIntConst(IntConst i) throws CompileError {
arrayDim = 0;
long value = i.get();
int type = i.getType();
if (type == IntConstant || type == CharConstant) {
exprType = (type == IntConstant ? INT : CHAR);
bytecode.addIconst((int)value);
}
else {
exprType = LONG;
bytecode.addLconst(value);
}
}
代码示例来源:origin: org.javassist/javassist
protected final int compileStringParameter(Bytecode code)
throws CannotCompileException
{
int nparam = stringParams.length;
code.addIconst(nparam);
code.addAnewarray(javaLangString);
for (int j = 0; j < nparam; ++j) {
code.add(Bytecode.DUP); // dup
code.addIconst(j); // iconst_<j>
code.addLdc(stringParams[j]); // ldc ...
code.add(Bytecode.AASTORE); // aastore
}
return 4;
}
代码示例来源:origin: org.javassist/javassist
/**
* 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: org.javassist/javassist
/**
* 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: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addIconst(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
public void atIntConst(IntConst i) throws CompileError {
arrayDim = 0;
long value = i.get();
int type = i.getType();
if (type == IntConstant || type == CharConstant) {
exprType = (type == IntConstant ? INT : CHAR);
bytecode.addIconst((int)value);
}
else {
exprType = LONG;
bytecode.addLconst(value);
}
}
代码示例来源:origin: redisson/redisson
/**
* @param thisMethod might be null.
*/
private static void callFind2Methods(Bytecode code, String superMethod, String thisMethod,
int index, String desc, int classVar, int arrayVar) {
String findClass = RuntimeSupport.class.getName();
String findDesc
= "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/reflect/Method;)V";
code.addAload(classVar);
code.addLdc(superMethod);
if (thisMethod == null)
code.addOpcode(Opcode.ACONST_NULL);
else
code.addLdc(thisMethod);
code.addIconst(index);
code.addLdc(desc);
code.addAload(arrayVar);
code.addInvokestatic(findClass, "find2Methods", findDesc);
}
代码示例来源:origin: redisson/redisson
protected void atAssignParamList(CtClass[] params, Bytecode code)
throws CompileError
{
if (params == null)
return;
int varNo = indexOfParam1();
int n = params.length;
for (int i = 0; i < n; ++i) {
code.addOpcode(DUP);
code.addIconst(i);
code.addOpcode(AALOAD);
compileUnwrapValue(params[i], code);
code.addStore(varNo, params[i]);
varNo += is2word(exprType, arrayDim) ? 2 : 1;
}
}
代码示例来源:origin: redisson/redisson
protected void atPlusPlusCore(int dup_code, boolean doDup,
int token, boolean isPost,
Expr expr) throws CompileError
{
int t = exprType;
if (doDup && isPost)
bytecode.addOpcode(dup_code);
if (t == INT || t == BYTE || t == CHAR || t == SHORT) {
bytecode.addIconst(1);
bytecode.addOpcode(token == PLUSPLUS ? IADD : ISUB);
exprType = INT;
}
else if (t == LONG) {
bytecode.addLconst((long)1);
bytecode.addOpcode(token == PLUSPLUS ? LADD : LSUB);
}
else if (t == FLOAT) {
bytecode.addFconst(1.0f);
bytecode.addOpcode(token == PLUSPLUS ? FADD : FSUB);
}
else if (t == DOUBLE) {
bytecode.addDconst(1.0);
bytecode.addOpcode(token == PLUSPLUS ? DADD : DSUB);
}
else
badType(expr);
if (doDup && !isPost)
bytecode.addOpcode(dup_code);
}
内容来源于网络,如有侵权,请联系作者删除!