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


Java Frame.getLocal方法代码示例

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


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

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

示例2: getLocalReplacementsInc

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
private Map<String, InsnList> getLocalReplacementsInc(MethodNode mn, String desc,
        IincInsnNode node, Frame frame) {
	Map<String, InsnList> replacements = new HashMap<String, InsnList>();

	int otherNum = -1;
	otherNum = node.var;
	int currentId = mn.instructions.indexOf(node);

	for (Object v : mn.localVariables) {
		LocalVariableNode localVar = (LocalVariableNode) v;
		int startId = mn.instructions.indexOf(localVar.start);
		int endId = mn.instructions.indexOf(localVar.end);
		logger.info("Checking local variable " + localVar.name + " of type "
		        + localVar.desc + " at index " + localVar.index);
		if (!localVar.desc.equals(desc))
			logger.info("- Types do not match: " + localVar.name);
		if (localVar.index == otherNum)
			logger.info("- Replacement = original " + localVar.name);
		if (currentId < startId)
			logger.info("- Out of scope (start) " + localVar.name);
		if (currentId > endId)
			logger.info("- Out of scope (end) " + localVar.name);
		BasicValue newValue = (BasicValue) frame.getLocal(localVar.index);
		if (newValue == BasicValue.UNINITIALIZED_VALUE)
			logger.info("- Not initialized");

		if (localVar.desc.equals(desc) && localVar.index != otherNum
		        && currentId >= startId && currentId <= endId
		        && newValue != BasicValue.UNINITIALIZED_VALUE) {

			logger.info("Adding local variable " + localVar.name + " of type "
			        + localVar.desc + " at index " + localVar.index);
			InsnList list = new InsnList();
			list.add(new IincInsnNode(localVar.index, node.incr));
			replacements.put(localVar.name, list);
		}
	}
	return replacements;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:40,代码来源:ReplaceVariable.java

示例3: getLocalReplacements

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
private Map<String, InsnList> getLocalReplacements(MethodNode mn, String desc,
        AbstractInsnNode node, Frame frame) {
	Map<String, InsnList> replacements = new HashMap<String, InsnList>();

	//if (desc.equals("I"))
	//	return replacements;

	int otherNum = -1;
	if (node instanceof VarInsnNode) {
		VarInsnNode vNode = (VarInsnNode) node;
		otherNum = vNode.var;
	}
	if (otherNum == -1)
		return replacements;

	int currentId = mn.instructions.indexOf(node);
	logger.info("Looking for replacements at position " + currentId + " of variable "
	        + otherNum + " of type " + desc);

	//	return replacements;

	for (Object v : mn.localVariables) {
		LocalVariableNode localVar = (LocalVariableNode) v;
		int startId = mn.instructions.indexOf(localVar.start);
		int endId = mn.instructions.indexOf(localVar.end);
		logger.info("Checking local variable " + localVar.name + " of type "
		        + localVar.desc + " at index " + localVar.index);
		if (!localVar.desc.equals(desc))
			logger.info("- Types do not match");
		if (localVar.index == otherNum)
			logger.info("- Replacement = original");
		if (currentId < startId)
			logger.info("- Out of scope (start)");
		if (currentId > endId)
			logger.info("- Out of scope (end)");
		BasicValue newValue = (BasicValue) frame.getLocal(localVar.index);
		if (newValue == BasicValue.UNINITIALIZED_VALUE)
			logger.info("- Not initialized");

		if (localVar.desc.equals(desc) && localVar.index != otherNum
		        && currentId >= startId && currentId <= endId
		        && newValue != BasicValue.UNINITIALIZED_VALUE) {

			logger.info("Adding local variable " + localVar.name + " of type "
			        + localVar.desc + " at index " + localVar.index + ",  " + startId
			        + "-" + endId + ", " + currentId);
			InsnList list = new InsnList();
			if (node.getOpcode() == Opcodes.GETFIELD) {
				list.add(new InsnNode(Opcodes.POP)); // Remove field owner from stack
			}

			list.add(new VarInsnNode(getLoadOpcode(localVar), localVar.index));
			replacements.put(localVar.name, list);
		}
	}
	return replacements;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:58,代码来源:ReplaceVariable.java

示例4: computeSizes

import org.objectweb.asm.tree.analysis.Frame; //导入方法依赖的package包/类
/**
 * Compute sizes required for the storage arrays that will contain the local variables table at this frame.
 * @param frame frame to compute for
 * @return size required by each storage array
 * @throws NullPointerException if any argument is {@code null}
 */
public static StorageSizes computeSizes(Frame<BasicValue> frame) {
    Validate.notNull(frame);

    // 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 = 0; i < frame.getLocals(); i++) {
        BasicValue basicValue = frame.getLocal(i);
        Type type = basicValue.getType();
        
        // If type == null, basicValue is pointing to uninitialized var -- basicValue.toString() will return '.'. This means that this
        // slot contains nothing to save. So, skip this slot if we encounter it.
        if (type == null) {
            continue;
        }
        
        // 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,代码行数:64,代码来源:LocalsStateGenerators.java


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