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


Java Frame.getStack方法代码示例

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


在下文中一共展示了Frame.getStack方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSource

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
private AbstractInsnNode getSource(MethodNode methodNode, Frame<SourceValue>[] frames, AbstractInsnNode now, int... wants) {
    Frame<SourceValue> currentFrame = frames[methodNode.instructions.indexOf(now)];
    SourceValue currentValue;

    for (int want : wants)
        if (want == now.getOpcode()) return now;
    switch (now.getOpcode()) {
        case ALOAD: {
            currentValue = currentFrame.getLocal(((VarInsnNode) now).var);
            break;
        }
        case ASTORE: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        case DUP: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        case PUTSTATIC: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        case SWAP: {
            currentValue = currentFrame.getStack(currentFrame.getStackSize() - 1);
            break;
        }
        default: {
            oops("Unexpected opcode {}", now.getOpcode());
            return null;
        }
    }

    if (currentValue.insns.size() != 1) {
        oops("Expected 1 source insn, found {}", TransformerHelper.insnsToString(currentValue.insns));
        return null;
    }

    return getSource(methodNode, frames, currentValue.insns.iterator().next(), wants);
}
 
开发者ID:java-deobfuscator,项目名称:deobfuscator,代码行数:41,代码来源:SimpleStringEncryptionTransformer.java

示例3: isBooleanOnStack

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
public boolean isBooleanOnStack(MethodNode mn, AbstractInsnNode node, int position) {
	int insnPosition = mn.instructions.indexOf(node);
	if (insnPosition >= currentFrames.length) {
		logger.info("Trying to access frame out of scope: " + insnPosition + "/"
		        + currentFrames.length);
		return false;
	}
	Frame frame = currentFrames[insnPosition];
	return frame.getStack(frame.getStackSize() - 1 - position) == BooleanValueInterpreter.BOOLEAN_VALUE;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:11,代码来源:BooleanTestabilityTransformation.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: 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

示例7: 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

示例8: computeSizes

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
/**
 * Compute sizes required for the storage arrays that will contain the operand stack at this frame.
 * @param frame frame to compute for
 * @param offset the position within the operand stack to start calculating
 * @param length the number of stack items to include in calculation
 * @return size required by each storage array
 * @throws NullPointerException if any argument is {@code null}
 * @throws IllegalArgumentException if any numeric argument is negative, or if {@code offset + length} is larger than the size of the
 * operand stack
 */
public static StorageSizes computeSizes(Frame<BasicValue> frame, int offset, int length) {
    Validate.notNull(frame);
    Validate.isTrue(offset >= 0);
    Validate.isTrue(length >= 0);
    Validate.isTrue(offset < frame.getStackSize());
    Validate.isTrue(offset + length <= frame.getStackSize());
    
    // Count size required for each storage array
    int intsSize = 0;
    int longsSize = 0;
    int floatsSize = 0;
    int doublesSize = 0;
    int objectsSize = 0;
    for (int i = offset + length - 1; i >= offset; i--) {
        BasicValue basicValue = frame.getStack(i);
        Type type = basicValue.getType();
        
        // If type is 'Lnull;', this means that the slot has been assigned null and that "there has been no merge yet that would 'raise'
        // the type toward some class or interface type" (from ASM mailing list). We know this slot will always contain null at this
        // point in the code so we can avoid saving it. When we load it back up, we can simply push a null in to that slot, thereby
        // keeping the same 'Lnull;' type.
        if ("Lnull;".equals(type.getDescriptor())) {
            continue;
        }
        
        switch (type.getSort()) {
            case Type.BOOLEAN:
            case Type.BYTE:
            case Type.SHORT:
            case Type.CHAR:
            case Type.INT:
                intsSize++;
                break;
            case Type.FLOAT:
                floatsSize++;
                break;
            case Type.LONG:
                longsSize++;
                break;
            case Type.DOUBLE:
                doublesSize++;
                break;
            case Type.ARRAY:
            case Type.OBJECT:
                objectsSize++;
                break;
            case Type.METHOD:
            case Type.VOID:
            default:
                throw new IllegalStateException();
        }
    }
    
    return new StorageSizes(intsSize, longsSize, floatsSize, doublesSize, objectsSize);
}
 
开发者ID:offbynull,项目名称:coroutines,代码行数:66,代码来源:OperandStackStateGenerators.java

示例9: getStackByIndex

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
public static <T extends Value> T getStackByIndex(Frame<T> frame, int index) {
    return frame.getStack(frame.getStackSize() - 1 - index);
}
 
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:4,代码来源:FrameHelper.java

示例10: peekFromTop

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
/**
 * Peek at a value in the current frame's stack, counting down from the top.
 *
 * @param depth how far down to peek; 0 is the top of the stack, 1 is the
 *   first element down, etc
 * @return the value on the stack, or null if it isn't a ReplacingBasciValue
 */
private ReplacingBasicValue peekFromTop(final int depth) {
  Preconditions.checkArgument(depth >= 0);
  final Frame<BasicValue> frame = list.currentFrame;
  final BasicValue basicValue = frame.getStack((frame.getStackSize() - 1) - depth);
  return filterReplacement(basicValue);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:InstructionModifier.java

示例11: 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

示例12: getStack

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
public static <T extends Value> T getStack(Frame<T> frame, int depth) {

        int index = 0;

        while (depth > 0) {

            depth -= frame.getStack(frame.getStackSize() - 1 - index).getSize();
            index++;
        }

        return frame.getStack(frame.getStackSize() - 1 - index);
    }
 
开发者ID:mur47x111,项目名称:svm-fasttagging,代码行数:13,代码来源:FrameHelper.java

示例13: getFunctionReturn

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
/**
 * Get the value of a function return if it is a ReplacingBasicValue.
 *
 * <p>Assumes that we're in the middle of processing an INVOKExxx instruction.
 *
 * @return the value that will be on the top of the stack after the function returns
 */
private ReplacingBasicValue getFunctionReturn() {
  final Frame<BasicValue> nextFrame = list.nextFrame;
  final BasicValue basicValue = nextFrame.getStack(nextFrame.getStackSize() - 1);
  return filterReplacement(basicValue);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:13,代码来源:InstructionModifier.java


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