本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.push方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.push方法的具體用法?Java GeneratorAdapter.push怎麽用?Java GeneratorAdapter.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.push方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createClassArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private static void createClassArray(GeneratorAdapter mv, List<Type> args) {
// create an array of objects capable of containing all the parameters and optionally the "this"
createLocals(mv, args);
// we need to maintain the stack index when loading parameters from, as for long and double
// values, it uses 2 stack elements, all others use only 1 stack element.
int stackIndex = 0;
for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
Type arg = args.get(arrayIndex);
// duplicate the array of objects reference, it will be used to store the value in.
mv.dup();
// index in the array of objects to store the boxed parameter.
mv.push(arrayIndex);
// Pushes the appropriate local variable on the stack
redirectLocal(mv, arg);
// mv.visitLdcInsn(Type.getType(arg.getDescriptor()));
// potentially box up intrinsic types.
// mv.box(arg);
mv.arrayStore(Type.getType(Class.class));
// stack index must progress according to the parameter type we just processed.
// stackIndex += arg.getSize();
}
}
示例2: visitEnd
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void visitEnd() {
if (! doneAddField) {
doneAddField = true;
super.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, CLASS_FIELD, Type.getDescriptor(Agent.class), null, null);
}
if (! doneAddMethod) {
doneAddMethod = true;
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, new Method(LOG_CLASS_METHOD, LOG_CLASS_SIGNATURE), LOG_CLASS_SIGNATURE, new Type[] {}, this);
Label target = mg.newLabel();
mg.getStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
mg.ifNull(target);
mg.push(LOG_INTERNAL_TYPE);
mg.putStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
mg.mark(target);
mg.getStatic(JAVA_LANG_SYSTEM_TYPE, CLASS_FIELD, JAVA_LANG_CLASS_TYPE);
mg.returnValue();
}
super.visitEnd();
}
示例3: visitEnd
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void visitEnd() {
if (!foundClinit && instrument()) {
// didn't find <clinit> so lets make one
try {
GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, new Method(CLINIT_NAME, CLINIT_SIGNATURE), CLINIT_SIGNATURE, new Type[] {}, this);
Label start = mg.mark();
mg.push(className);
mg.invokeStatic(LOG_INTERNAL_TYPE, Method.getMethod(LOG_INTERNAL_CLASS.getMethod(LOG_METHOD_NAME, String.class)));
Label end = mg.mark();
mg.returnValue();
mg.catchException(start, end, JAVA_LANG_THROWABLE_TYPE);
mg.returnValue();
mg.endMethod();
} catch (NoSuchMethodException nsme) {
System.out.println("Unable to find Agent.reportClass method");
}
}
super.visitEnd();
}
示例4: loadVariableArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Given an array on the stack, it loads it with the values of the given variables stating at
* offset.
*/
static void loadVariableArray(
GeneratorAdapter mv,
List<LocalVariable> variables, int offset) {
// we need to maintain the stack index when loading parameters from, as for long and double
// values, it uses 2 stack elements, all others use only 1 stack element.
for (int i = offset; i < variables.size(); i++) {
LocalVariable variable = variables.get(i);
// duplicate the array of objects reference, it will be used to store the value in.
mv.dup();
// index in the array of objects to store the boxed parameter.
mv.push(i);
// Pushes the appropriate local variable on the stack
mv.visitVarInsn(variable.type.getOpcode(Opcodes.ILOAD), variable.var);
// potentially box up intrinsic types.
mv.box(variable.type);
// store it in the array
mv.arrayStore(Type.getType(Object.class));
}
}
示例5: establishCallback
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void establishCallback(ClassNode cn, MethodNode mn) {
if (!mn.desc.startsWith("()")) {
MethodNode blank = new MethodNode();
Method method = new Method(mn.name, mn.desc);
GeneratorAdapter adapter = new GeneratorAdapter(mn.access, method, blank);
adapter.visitCode();
adapter.push(cn.name + "." + mn.name + " " + mn.desc);
adapter.loadArgArray();
adapter.invokeStatic(Type.getType(CallFactory.class), new Method("testInvoke",
"(Ljava/lang/String;[Ljava/lang/Object;)V"));
for (AbstractInsnNode ain : mn.instructions.toArray()) {
if (ain instanceof VarInsnNode) {
mn.instructions.insertBefore(ain, blank.instructions);
return;
}
}
}
}
示例6: emit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
if(targetClass != null && field != null)
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.checkCast(getType(targetClass));
gen.getField(getType(targetClass), fieldName, Type.getType(field.getType()));
//if(context != C.STATEMENT)
HostExpr.emitBoxReturn(objx, gen, field.getType());
if(context == C.STATEMENT)
{
gen.pop();
}
}
else
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.push(fieldName);
gen.push(requireField);
gen.invokeStatic(REFLECTOR_TYPE, invokeNoArgInstanceMember);
if(context == C.STATEMENT)
gen.pop();
}
}
示例7: emitMethods
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
protected void emitMethods(ClassVisitor cv){
//override of invoke/doInvoke for each method
for(ISeq s = RT.seq(methods); s != null; s = s.next())
{
ObjMethod method = (ObjMethod) s.first();
method.emit(this, cv);
}
if(isVariadic())
{
GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC,
Method.getMethod("int getRequiredArity()"),
null,
null,
cv);
gen.visitCode();
gen.push(variadicMethod.reqParms.count());
gen.returnValue();
gen.endMethod();
}
}
示例8: prepareMethodParameters
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private static void prepareMethodParameters(GeneratorAdapter mv, String className, List<Type> args, Type returnType, boolean isStatic, int methodId) {
//第一個參數:new Object[]{...};,如果方法沒有參數直接傳入new Object[0]
if (args.size() == 0) {
mv.visitInsn(Opcodes.ICONST_0);
mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
} else {
createObjectArray(mv, args, isStatic);
}
//第二個參數:this,如果方法是static的話就直接傳入null
if (isStatic) {
mv.visitInsn(Opcodes.ACONST_NULL);
} else {
mv.visitVarInsn(Opcodes.ALOAD, 0);
}
//第三個參數:changeQuickRedirect
mv.visitFieldInsn(Opcodes.GETSTATIC,
className,
REDIRECTFIELD_NAME,
REDIRECTCLASSNAME);
//第四個參數:false,標誌是否為static
mv.visitInsn(isStatic ? Opcodes.ICONST_1 : Opcodes.ICONST_0);
//第五個參數:
mv.push(methodId);
//第六個參數:參數class數組
createClassArray(mv, args);
//第七個參數:返回值類型class
createReturnClass(mv, returnType);
}
示例9: writeMissingMessageWithHash
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
void writeMissingMessageWithHash(GeneratorAdapter mv, String visitedClassName) {
mv.newInstance(INSTANT_RELOAD_EXCEPTION_TYPE);
mv.dup();
mv.push("int switch could not find %d in %s");
mv.push(3);
mv.newArray(OBJECT_TYPE);
mv.dup();
mv.push(0);
visitInt();
mv.visitMethodInsn(
Opcodes.INVOKESTATIC,
"java/lang/Integer",
"valueOf",
"(I)Ljava/lang/Integer;", false);
mv.arrayStore(OBJECT_TYPE);
mv.dup();
mv.push(2);
mv.push(visitedClassName);
mv.arrayStore(OBJECT_TYPE);
mv.visitMethodInsn(
Opcodes.INVOKESTATIC,
"java/lang/String",
"format",
"(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);
mv.invokeConstructor(INSTANT_RELOAD_EXCEPTION_TYPE,
Method.getMethod("void <init> (String)"));
mv.throwException();
}
示例10: newVariableArray
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Pushes an array on the stack that contains the value of all the given variables.
*/
static void newVariableArray(
GeneratorAdapter mv,
List<LocalVariable> variables) {
mv.push(variables.size());
mv.newArray(Type.getType(Object.class));
loadVariableArray(mv, variables, 0);
}
示例11: doRedirect
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
protected void doRedirect( GeneratorAdapter mv, int change) {
mv.loadLocal(change);
mv.push(AcesoProguardMap.instance().getMtdIndex(visitedClassName, IncrementalTool.getMtdSig(mtdName,mtdDesc)));
ByteCodeUtils.newVariableArray(mv, ByteCodeUtils.toLocalVariables(types));
// now invoke the generic dispatch method.
mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(int, Object[])"));
}
示例12: writeMissingMessageWithHash
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Generates a standard error exception with message similar to:
*
* String switch could not find 'equals.(Ljava/lang/Object;)Z' with hashcode 0
* in com/example/basic/GrandChild
*
* @param mv The generator adaptor used to emit the lookup switch code.
* @param visitedClassName The abstract string trie structure.
*/
void writeMissingMessageWithHash(GeneratorAdapter mv, String visitedClassName) {
mv.newInstance(INSTANT_RELOAD_EXCEPTION_TYPE);
mv.dup();
mv.push("String switch could not find '%s' with hashcode %s in %s");
mv.push(3);
mv.newArray(OBJECT_TYPE);
mv.dup();
mv.push(0);
visitString();
mv.arrayStore(OBJECT_TYPE);
mv.dup();
mv.push(1);
visitString();
visitHashMethod(mv);
mv.visitMethodInsn(
Opcodes.INVOKESTATIC,
"java/lang/Integer",
"valueOf",
"(I)Ljava/lang/Integer;", false);
mv.arrayStore(OBJECT_TYPE);
mv.dup();
mv.push(2);
mv.push(visitedClassName);
mv.arrayStore(OBJECT_TYPE);
mv.visitMethodInsn(
Opcodes.INVOKESTATIC,
"java/lang/String",
"format",
"(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);
mv.invokeConstructor(INSTANT_RELOAD_EXCEPTION_TYPE,
Method.getMethod("void <init> (String)"));
mv.throwException();
}
示例13: trace
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
protected static void trace(GeneratorAdapter mv, String s1,
String s2, String s3) {
mv.push(s1);
mv.push(s2);
mv.push(s3);
mv.invokeStatic(Type.getType(PACKAGE + ".AndroidInstantRuntime"),
Method.getMethod("void trace(String, String, String)"));
}
示例14: emitUnboxed
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){
if(n instanceof Integer)
gen.push(n.longValue());
else if(n instanceof Double)
gen.push(n.doubleValue());
else if(n instanceof Long)
gen.push(n.longValue());
}
示例15: emitShiftMask
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitShiftMask(GeneratorAdapter gen){
if (isShiftMasked())
{
gen.push(shift);
gen.visitInsn(ISHR);
gen.push(mask);
gen.visitInsn(IAND);
}
}