本文整理汇总了Java中javassist.bytecode.Bytecode.addIstore方法的典型用法代码示例。如果您正苦于以下问题:Java Bytecode.addIstore方法的具体用法?Java Bytecode.addIstore怎么用?Java Bytecode.addIstore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javassist.bytecode.Bytecode
的用法示例。
在下文中一共展示了Bytecode.addIstore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTypeDependDataStore
import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private static void addTypeDependDataStore(Bytecode code, String typeName,
int i) {
if ((typeName.charAt(0) == 'L')
&& (typeName.charAt(typeName.length() - 1) == ';')
|| (typeName.charAt(0) == '[')) {
// reference type
code.addAstore(i);
} else if (typeName.equals("Z") || typeName.equals("B")
|| typeName.equals("C") || typeName.equals("I")
|| typeName.equals("S")) {
// boolean, byte, char, int, short
code.addIstore(i);
} else if (typeName.equals("D")) {
// double
code.addDstore(i);
} else if (typeName.equals("F")) {
// float
code.addFstore(i);
} else if (typeName.equals("J")) {
// long
code.addLstore(i);
} else {
// bad type
throw new RuntimeException("bad type: " + typeName);
}
}
示例2: addTypeDependDataStore
import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private static void addTypeDependDataStore(Bytecode code, String typeName, int i) {
if ( typeName.charAt( 0 ) == 'L'
&& typeName.charAt( typeName.length() - 1 ) == ';'
|| typeName.charAt( 0 ) == '[' ) {
// reference type
code.addAstore( i );
}
else if ( typeName.equals( "Z" )
|| typeName.equals( "B" )
|| typeName.equals( "C" )
|| typeName.equals( "I" )
|| typeName.equals( "S" ) ) {
// boolean, byte, char, int, short
code.addIstore( i );
}
else if ( typeName.equals( "D" ) ) {
// double
code.addDstore( i );
}
else if ( typeName.equals( "F" ) ) {
// float
code.addFstore( i );
}
else if ( typeName.equals( "J" ) ) {
// long
code.addLstore( i );
}
else {
// bad type
throw new RuntimeException( "bad type: " + typeName );
}
}
示例3: delegateNewArray
import javassist.bytecode.Bytecode; //导入方法依赖的package包/类
/**
* Replaces creation of the array with the creation of the <em>KoratArray</em>
* field. Just invokes its constructor with the <code>int</code> parameter
* that represents the length of the array.
*
* @param arrayType -
* type of array in terms of JVM
* @param cit -
* iterator through method's body code
* @param idx -
* current position in the <code>cit</code>
* @throws BadBytecode
*/
private void delegateNewArray(int arrayType, CodeIterator cit, int idx) {
// check how this new array is going to be consumed
if (operandStack.peek().consumedBy != ConsumedByKind.PUTFIELD)
return;
String koratClassName = koratArrayClassNames[arrayType];
int locals = cit.get().getMaxLocals();
int localVar1 = locals + 1;
try {
Bytecode codes = new Bytecode(constPool);
codes.addIstore(localVar1);
codes.addNew(koratClassName);
codes.addOpcode(Opcode.DUP);
codes.addIload(localVar1);
String descr = Descriptor.ofMethod(CtClass.voidType,
new CtClass[] { CtClass.intType });
codes.addInvokespecial(koratClassName, "<init>", descr);
int diff = codes.getSize() - 2;
// -2 because original instruction
// (NEWARRAY) is 2 bytes long.
cit.insertGap(idx, diff);
cit.write(codes.get(), idx);
cit.get().setMaxLocals(localVar1 + 1);
} catch (BadBytecode e) {
throw new RuntimeException(e);
}
}