当前位置: 首页>>代码示例>>Java>>正文


Java Frame.getStackSize方法代码示例

本文整理汇总了Java中org.objectweb.asm.tree.analysis.Frame.getStackSize方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.getStackSize方法的具体用法?Java Frame.getStackSize怎么用?Java Frame.getStackSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.tree.analysis.Frame的用法示例。


在下文中一共展示了Frame.getStackSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformTypeInsnNode

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
@Override
protected AbstractInsnNode transformTypeInsnNode(MethodNode mn,
        TypeInsnNode typeNode) {
	if (frames == null)
		return typeNode;

	if (typeNode.getOpcode() == Opcodes.CHECKCAST) {
		Frame current = frames[mn.instructions.indexOf(typeNode)];
		int size = current.getStackSize();
		if (current.getStack(size - 1) == BooleanArrayInterpreter.INT_ARRAY) {
			BooleanTestabilityTransformation.logger.info("Array is of boolean type, changing CHECKCAST to [I");
			TypeInsnNode replacement = new TypeInsnNode(Opcodes.CHECKCAST, "[I");
			mn.instructions.insertBefore(typeNode, replacement);
			mn.instructions.remove(typeNode);
			return replacement;
		}
	}
	return typeNode;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:20,代码来源:BooleanArrayIndexTransformer.java

示例2: printAnalyzerResult

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
static void printAnalyzerResult(MethodNode method, Analyzer<BasicValue> a,
        final PrintWriter pw) {
    Frame<BasicValue>[] frames = a.getFrames();
    Textifier t = new Textifier();
    TraceMethodVisitor mv = new TraceMethodVisitor(t);

    pw.println(method.name + method.desc);
    for (int j = 0; j < method.instructions.size(); ++j) {
        method.instructions.get(j).accept(mv);

        StringBuilder sb = new StringBuilder();
        Frame<BasicValue> f = frames[j];
        if (f == null) {
            sb.append('?');
        } else {
            for (int k = 0; k < f.getLocals(); ++k) {
                sb.append(getShortName(f.getLocal(k).toString()))
                        .append(' ');
            }
            sb.append(" : ");
            for (int k = 0; k < f.getStackSize(); ++k) {
                sb.append(getShortName(f.getStack(k).toString()))
                        .append(' ');
            }
        }
        while (sb.length() < method.maxStack + method.maxLocals + 1) {
            sb.append(' ');
        }
        pw.print(Integer.toString(j + 100000).substring(1));
        pw.print(" " + sb + " : " + t.text.get(t.text.size() - 1));
    }
    for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
        method.tryCatchBlocks.get(j).accept(mv);
        pw.print(" " + t.text.get(t.text.size() - 1));
    }
    pw.println();
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:38,代码来源:CheckClassAdapter.java

示例3: printAnalyzerResult

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
static void printAnalyzerResult(MethodNode method, Analyzer<BasicValue> a,
        final PrintWriter pw) {
    Frame<BasicValue>[] frames = a.getFrames();
    Textifier t = new Textifier();
    TraceMethodVisitor mv = new TraceMethodVisitor(t);

    pw.println(method.name + method.desc);
    for (int j = 0; j < method.instructions.size(); ++j) {
        method.instructions.get(j).accept(mv);

        StringBuffer s = new StringBuffer();
        Frame<BasicValue> f = frames[j];
        if (f == null) {
            s.append('?');
        } else {
            for (int k = 0; k < f.getLocals(); ++k) {
                s.append(getShortName(f.getLocal(k).toString()))
                        .append(' ');
            }
            s.append(" : ");
            for (int k = 0; k < f.getStackSize(); ++k) {
                s.append(getShortName(f.getStack(k).toString()))
                        .append(' ');
            }
        }
        while (s.length() < method.maxStack + method.maxLocals + 1) {
            s.append(' ');
        }
        pw.print(Integer.toString(j + 100000).substring(1));
        pw.print(" " + s + " : " + t.text.get(t.text.size() - 1));
    }
    for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
        method.tryCatchBlocks.get(j).accept(mv);
        pw.print(" " + t.text.get(t.text.size() - 1));
    }
    pw.println();
}
 
开发者ID:bcleenders,项目名称:Bramspr,代码行数:38,代码来源:CheckClassAdapter.java

示例4: getOffset

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
public static int getOffset(Frame<BasicValue> frame) {
    int offset = 0;

    for (int i = frame.getStackSize() - 1; i >= 0; i--) {

        BasicValue v = frame.getStack(i);
        offset += v.getSize();
    }

    return offset;
}
 
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:12,代码来源:FrameHelper.java

示例5: exit

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
public static InsnList exit(Frame<BasicValue> frame, int offset) {
    InsnList ilst = new InsnList();
    ilst.add(new LabelNode());

    for (int i = frame.getStackSize() - 1; i >= 0; i--) {

        BasicValue v = frame.getStack(i);

        ilst.insertBefore(ilst.getFirst(), new VarInsnNode(v.getType()
                .getOpcode(Opcodes.ILOAD), offset));
        offset += v.getSize();
    }

    return ilst;
}
 
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:16,代码来源:FrameHelper.java

示例6: printMethod

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
private static void printMethod(final Analyzer a, final PrintStream out, final MethodNode method) {
    final Frame[] frames = a.getFrames();

    final Textifier textifier = new Textifier();
    final TraceMethodVisitor mv = new TraceMethodVisitor(textifier);

    out.println(method.name + method.desc);
    for (int j = 0; j < method.instructions.size(); ++j) {
        method.instructions.get(j).accept(mv);

        final StringBuffer s = new StringBuffer();
        final Frame f = frames[j];
        if (f == null) {
            s.append('?');
        } else {
            for (int k = 0; k < f.getLocals(); ++k) {
                s.append(getShortName(f.getLocal(k).toString())).append(' ');
            }
            s.append(" : ");
            for (int k = 0; k < f.getStackSize(); ++k) {
                s.append(getShortName(f.getStack(k).toString())).append(' ');
            }
        }
        while (s.length() < method.maxStack + method.maxLocals + 1) {
            s.append(' ');
        }
        out.print(Integer.toString(j + 100000).substring(1));
        out.print(" " + s + " : " + textifier.text.get(j));
    }
    for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
        ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
        out.print(" " + textifier.text.get(method.instructions.size()+j));
    }
    out.println(" MAXSTACK " + method.maxStack);
    out.println(" MAXLOCALS " + method.maxLocals);
    out.println();
}
 
开发者ID:hammacher,项目名称:javaslicer,代码行数:38,代码来源:Transformer.java

示例7: printAnalyzerResult

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
static void printAnalyzerResult(
    MethodNode method,
    Analyzer<BasicValue> a,
    final PrintWriter pw)
{
    Frame<BasicValue>[] frames = a.getFrames();
    Textifier t = new Textifier();
    TraceMethodVisitor mv = new TraceMethodVisitor(t);

    pw.println(method.name + method.desc);
    for (int j = 0; j < method.instructions.size(); ++j) {
        method.instructions.get(j).accept(mv);

        StringBuffer s = new StringBuffer();
        Frame<BasicValue> f = frames[j];
        if (f == null) {
            s.append('?');
        } else {
            for (int k = 0; k < f.getLocals(); ++k) {
                s.append(getShortName(f.getLocal(k).toString()))
                        .append(' ');
            }
            s.append(" : ");
            for (int k = 0; k < f.getStackSize(); ++k) {
                s.append(getShortName(f.getStack(k).toString()))
                        .append(' ');
            }
        }
        while (s.length() < method.maxStack + method.maxLocals + 1) {
            s.append(' ');
        }
        pw.print(Integer.toString(j + 100000).substring(1));
        pw.print(" " + s + " : " + t.text.get(t.text.size() - 1));
    }
    for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
        method.tryCatchBlocks.get(j).accept(mv);
        pw.print(" " + t.text.get(t.text.size() - 1));
    }
    pw.println();
}
 
开发者ID:nxmatic,项目名称:objectweb-asm-4.0,代码行数:41,代码来源:CheckClassAdapter.java

示例8: getStackValue

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
private static BasicValue getStackValue(Frame<BasicValue> f, MethodInsnNode methodInsn, int index) {
    int relIndex = Type.getArgumentTypes(methodInsn.desc).length - 1 - index;
    int top = f.getStackSize() - 1;
    return relIndex <= top ? f.getStack(top - relIndex) : null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:ESLoggerUsageChecker.java

示例9: dumpCodeBlock

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
private void dumpCodeBlock(MethodVisitor mv, int idx, int skip) {
    int start = codeBlocks[idx].endInstruction;
    int end = codeBlocks[idx+1].endInstruction;

    for(int i=start+skip ; i<end ; i++) {
        AbstractInsnNode ins = mn.instructions.get(i);
        switch(ins.getOpcode()) {
        case Opcodes.RETURN:
        case Opcodes.ARETURN:
        case Opcodes.IRETURN:
        case Opcodes.LRETURN:
        case Opcodes.FRETURN:
        case Opcodes.DRETURN:
            emitPopMethod(mv);
            break;

        case Opcodes.MONITORENTER:
        case Opcodes.MONITOREXIT:
            if(!db.isAllowMonitors()) {
                throw new UnableToInstrumentException("synchronisation", className, mn.name, mn.desc);
            } else if(!warnedAboutMonitors) {
                warnedAboutMonitors = true;
                db.log(LogLevel.WARNING, "Method %s#%s%s contains synchronisation", className, mn.name, mn.desc);
            }
            break;

        case Opcodes.INVOKESPECIAL:
            MethodInsnNode min = (MethodInsnNode)ins;
            if("<init>".equals(min.name)) {
                int argSize = TypeAnalyzer.getNumArguments(min.desc);
                Frame frame = frames[i];
                int stackIndex = frame.getStackSize() - argSize - 1;
                Value thisValue = frame.getStack(stackIndex);
                if(stackIndex >= 1 &&
                        isNewValue(thisValue, true) &&
                        isNewValue(frame.getStack(stackIndex-1), false)) {
                    NewValue newValue = (NewValue)thisValue;
                    if(newValue.omitted) {
                        emitNewAndDup(mv, frame, stackIndex, min);
                    }
                } else {
                    db.log(LogLevel.WARNING, "Expected to find a NewValue on stack index %d: %s", stackIndex, frame);
                }
            }
            break;
        }
        ins.accept(mv);
    }
}
 
开发者ID:oltolm,项目名称:continuations,代码行数:50,代码来源:InstrumentMethod.java

示例10: verify

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
/**
 * Checks a given class
 *
 * @param cr a <code>ClassReader</code> that contains bytecode for the analysis.
 * @param dump true if bytecode should be printed out not only when errors are found.
 * @param pw write where results going to be printed
 */
public static void verify(ClassReader cr, boolean dump, PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn), true);

    List methods = cn.methods;
    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = (MethodNode) methods.get(i);
        if (method.instructions.size() > 0) {
            Analyzer a = new Analyzer(new SimpleVerifier(Type.getType("L"
                    + cn.name + ";"),
                    Type.getType("L" + cn.superName + ";"),
                    (cn.access & Opcodes.ACC_INTERFACE) != 0));
            try {
                a.analyze(cn.name, method);
                if (!dump) {
                    continue;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            Frame[] frames = a.getFrames();

            TraceMethodVisitor mv = new TraceMethodVisitor();

            pw.println(method.name + method.desc);
            for (int j = 0; j < method.instructions.size(); ++j) {
                ((AbstractInsnNode) method.instructions.get(j)).accept(mv);

                StringBuffer s = new StringBuffer();
                Frame f = frames[j];
                if (f == null) {
                    s.append('?');
                } else {
                    for (int k = 0; k < f.getLocals(); ++k) {
                        s.append(getShortName(f.getLocal(k).toString()))
                                .append(' ');
                    }
                    s.append(" : ");
                    for (int k = 0; k < f.getStackSize(); ++k) {
                        s.append(getShortName(f.getStack(k).toString()))
                                .append(' ');
                    }
                }
                while (s.length() < method.maxStack + method.maxLocals + 1)
                {
                    s.append(' ');
                }
                pw.print(Integer.toString(j + 100000).substring(1));
                pw.print(" " + s + " : " + mv.buf); // mv.text.get(j));
            }
            for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
                ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
                pw.print(" " + mv.buf);
            }
            pw.println();
        }
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:66,代码来源:CheckClassAdapter.java

示例11: verify

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
/**
 * Checks a given class
 * 
 * @param cr a <code>ClassReader</code> that contains bytecode for the analysis. 
 * @param dump true if bytecode should be printed out not only when errors are found.
 * @param pw write where results going to be printed
 */
public static void verify(ClassReader cr, boolean dump, PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn), true);

    List methods = cn.methods;
    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = (MethodNode) methods.get(i);
        if (method.instructions.size() > 0) {
            Analyzer a = new Analyzer(new SimpleVerifier(Type.getType("L"
                    + cn.name + ";"),
                    Type.getType("L" + cn.superName + ";"),
                    (cn.access & Opcodes.ACC_INTERFACE) != 0));
            try {
                a.analyze(cn.name, method);
                if (!dump) {
                    continue;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            Frame[] frames = a.getFrames();

            TraceMethodVisitor mv = new TraceMethodVisitor();

            pw.println(method.name + method.desc);
            for (int j = 0; j < method.instructions.size(); ++j) {
                ((AbstractInsnNode) method.instructions.get(j)).accept(mv);
                
                StringBuffer s = new StringBuffer();
                Frame f = frames[j];
                if (f == null) {
                    s.append('?');
                } else {
                    for (int k = 0; k < f.getLocals(); ++k) {
                        s.append(getShortName(f.getLocal(k).toString()))
                                .append(' ');
                    }
                    s.append(" : ");
                    for (int k = 0; k < f.getStackSize(); ++k) {
                        s.append(getShortName(f.getStack(k).toString()))
                                .append(' ');
                    }
                }
                while (s.length() < method.maxStack + method.maxLocals + 1)
                {
                    s.append(' ');
                }
                pw.print(Integer.toString(j + 100000).substring(1));
                pw.print(" " + s + " : " + mv.buf); // mv.text.get(j));
            }
            for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
                ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
                pw.print(" " + mv.buf);
            }
            pw.println();
        }
    }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:66,代码来源:CheckClassAdapter.java

示例12: enter

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
public static InsnList enter(Frame<BasicValue> frame, int offset) {

        InsnList ilst = new InsnList();

        for (int i = frame.getStackSize() - 1; i >= 0; i--) {

            BasicValue v = frame.getStack(i);

            ilst.add(new VarInsnNode(v.getType().getOpcode(Opcodes.ISTORE),
                    offset));
            offset += v.getSize();
        }

        return ilst;
    }
 
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:16,代码来源:FrameHelper.java


注:本文中的org.objectweb.asm.tree.analysis.Frame.getStackSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。