本文整理汇总了Java中org.objectweb.asm.tree.FrameNode类的典型用法代码示例。如果您正苦于以下问题:Java FrameNode类的具体用法?Java FrameNode怎么用?Java FrameNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FrameNode类属于org.objectweb.asm.tree包,在下文中一共展示了FrameNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
@Override
public void visit(Branch.Condition.Nil cond) {
assert (destLabel != null);
il.add(new VarInsnNode(ALOAD, slot(cond.addr())));
if (!isSub() || resolver.isLocalLabel(destLabel)) {
// local jump
il.add(new JumpInsnNode(IFNULL, l(destLabel)));
} else {
// non-local jump
LabelNode l_nojump = new LabelNode();
il.add(new JumpInsnNode(IFNONNULL, l_nojump));
il.add(_nonLocalGoto(destLabel));
il.add(l_nojump);
il.add(new FrameNode(F_SAME, 0, null, 0, null));
}
}
示例2: transformDamageItem
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
private void transformDamageItem(MethodNode method) {
InsnList postEvent = new InsnList();
LabelNode label = new LabelNode(new Label());
postEvent.add(new TypeInsnNode(Opcodes.NEW, DAMAGE_ITEM_EVENT.getInternalName()));
postEvent.add(new InsnNode(Opcodes.DUP));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 2));
postEvent.add(new VarInsnNode(Opcodes.ILOAD, 1));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 0));
postEvent.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, DAMAGE_ITEM_EVENT_INIT.getOwnerInternalName(), DAMAGE_ITEM_EVENT_INIT.getEnvName(), DAMAGE_ITEM_EVENT_INIT.getDesc(), false));
postEvent.add(new VarInsnNode(Opcodes.ASTORE, 3));
postEvent.add(new FieldInsnNode(Opcodes.GETSTATIC, EVENTHANDLER_DAMAGE_ITEM.getOwnerInternalName(), EVENTHANDLER_DAMAGE_ITEM.getEnvName(), EVENTHANDLER_DAMAGE_ITEM.getDesc()));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 3));
postEvent.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, POST.getOwnerInternalName(), POST.getEnvName(), POST.getDesc(), false));
postEvent.add(new JumpInsnNode(Opcodes.IFEQ, label));
postEvent.add(new InsnNode(Opcodes.RETURN));
postEvent.add(label);
postEvent.add(new FrameNode(Opcodes.F_APPEND, 1, new Object[] {DAMAGE_ITEM_EVENT.getInternalName()}, 0, null));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 3));
postEvent.add(new FieldInsnNode(Opcodes.GETFIELD, DAMAGE.getOwnerInternalName(), DAMAGE.getEnvName(), DAMAGE.getDesc()));
postEvent.add(new VarInsnNode(Opcodes.ISTORE, 1));
method.instructions.insert(postEvent);
}
示例3: updateFrames
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
private void updateFrames(int implVarIndex) {
AbstractInsnNode next = instructions.getFirst();
while (next != null) {
AbstractInsnNode node = next;
next = next.getNext();
if (node instanceof FrameNode) {
FrameNode frameNode = (FrameNode) node;
Collection<Object> locals = new ArrayList<>();
for (Object value : frameNode.local) {
locals.add(value);
if (isLong(value)) {
locals.add(TOP);
}
}
Object[] locals1 = convertValues(appendValue(ensureSize(locals.toArray(), implVarIndex),
"org/jephyr/continuation/easyflow/ContinuationImpl"));
List<Object> stack = frameNode.stack;
instructions.set(node, new FrameNode(F_NEW, locals1.length, locals1, stack.size(), stack.toArray()));
}
}
}
示例4: frame_same
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
/**
* adds a compressed frame to the stack
*
* @param stackArguments the argument types on the stack, represented as
* "class path names" e.g java/lang/RuntimeException
*/
public CodeBlock frame_same(final Object... stackArguments)
{
final int type;
switch (stackArguments.length) {
case 0:
type = Opcodes.F_SAME;
break;
case 1:
type = Opcodes.F_SAME1;
break;
default:
throw new IllegalArgumentException("same frame should have 0"
+ " or 1 arguments on stack");
}
instructionList.add(new FrameNode(type, 0, null, stackArguments.length,
stackArguments));
return this;
}
示例5: acceptFn
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
public static void acceptFn(FrameNode fn, MethodVisitor mv)
{
switch (fn.type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
case TaintUtils.RAW_INSN:
mv.visitFrame(fn.type, fn.local.size(), asArray(fn.local), fn.stack.size(),
asArray(fn.stack));
break;
case Opcodes.F_APPEND:
mv.visitFrame(fn.type, fn.local.size(), asArray(fn.local), 0, null);
break;
case Opcodes.F_CHOP:
mv.visitFrame(fn.type, fn.local.size(), null, 0, null);
break;
case Opcodes.F_SAME:
mv.visitFrame(fn.type, 0, null, 0, null);
break;
case Opcodes.F_SAME1:
mv.visitFrame(fn.type, 0, null, 1, asArray(fn.stack));
break;
}
}
示例6: registerTaintedArray
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
/**
*
* @param descOfDest
*/
public void registerTaintedArray() {
super.visitInsn(SWAP);
Label isnull = new Label();
Label ok = new Label();
FrameNode fn2 = getCurrentFrameNode();
super.visitInsn(DUP);
super.visitJumpInsn(IFNULL, isnull);
super.visitInsn(DUP_X1);
super.visitInsn(SWAP);
Type onTop = getTopOfStackType();
String wrapper = (String) TaintUtils.getShadowTaintTypeForFrame(onTop.getDescriptor());
super.visitMethodInsn(INVOKEVIRTUAL, wrapper, "ensureVal", "("+onTop.getDescriptor()+")V", false);
FrameNode fn = getCurrentFrameNode();
super.visitJumpInsn(GOTO, ok);
super.visitLabel(isnull);
acceptFn(fn2);
super.visitInsn(SWAP);
super.visitInsn(POP);
super.visitLabel(ok);
acceptFn(fn);
//A
}
示例7: visitLabel
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
@Override
public void visitLabel(Label label) {
// if (curLabel >= 0)
if (DEBUG)
System.out.println("Visit label: " + curLabel + " analyzer: " + analyzer.stack + " inframes size " + inFrames.size() + " " + outFrames.size());
if (analyzer.locals == null || analyzer.stack == null)
inFrames.add(new FrameNode(0, 0, new Object[0], 0, new Object[0]));
else
inFrames.add(new FrameNode(0, analyzer.locals.size(), analyzer.locals.toArray(), analyzer.stack.size(), analyzer.stack.toArray()));
// if (outFrames.size() <= curLabel) {
// if(analyzer.stack == null)
outFrames.add(null);
if (curLabel > 0 && outFrames.get(curLabel - 1) == null && analyzer.stack != null)
outFrames.set(curLabel - 1, new FrameNode(0, analyzer.locals.size(), analyzer.locals.toArray(), analyzer.stack.size(), analyzer.stack.toArray()));
if (DEBUG)
System.out.println("Added outframe for " + (outFrames.size() - 1) + " : " + analyzer.stack);
// }
super.visitLabel(label);
curLabel++;
}
示例8: patchMethod
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
public void patchMethod(MethodNode methodNode, String patchName, String clazzName) {
methodNode.desc = methodNode.desc.replace(patchName, clazzName);
for (Iterator<AbstractInsnNode> iterator = methodNode.instructions.iterator(); iterator.hasNext();) {
AbstractInsnNode insn = iterator.next();
if (insn instanceof TypeInsnNode) {
TypeInsnNode type = (TypeInsnNode) insn;
type.desc = replace(type.desc, patchName, clazzName);
} else if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode) insn;
field.owner = replace(field.owner, patchName, clazzName);
} else if (insn instanceof MethodInsnNode) {
MethodInsnNode method = (MethodInsnNode) insn;
if (method.owner.equals(patchName) && method.getOpcode() == INVOKEVIRTUAL)
method.setOpcode(INVOKESPECIAL);
method.owner = replace(method.owner, patchName, clazzName);
} else if (insn instanceof InvokeDynamicInsnNode) {
InvokeDynamicInsnNode dynamic = (InvokeDynamicInsnNode) insn;
String patchDesc = ASMHelper.getClassDesc(patchName), clazzDesc = ASMHelper.getClassDesc(clazzName);
dynamic.desc = replace(dynamic.desc, patchDesc, clazzDesc);
for (int i = 0; i < dynamic.bsmArgs.length; i++)
if (dynamic.bsmArgs[i] instanceof Handle) {
Handle handle = (Handle) dynamic.bsmArgs[i];
dynamic.bsmArgs[i] = new Handle(handle.getTag(), replace(handle.getOwner(), patchName, clazzName),
handle.getName(), replace(handle.getDesc(), patchDesc, clazzDesc), handle.isInterface());
}
} else if (insn instanceof FrameNode) {
FrameNode frame = (FrameNode) insn;
if (frame.local != null)
frame.local.replaceAll((o -> o instanceof String ? replace((String) o, patchName, clazzName) : o));
if (frame.stack != null)
frame.stack.replaceAll((o -> o instanceof String ? replace((String) o, patchName, clazzName) : o));
}
}
}
示例9: handle
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
super.handle(node);
LOG.debug(logNode(node));
checkType(node, FrameNode.class);
mState.setFrameLabel(mState.getCurrentLabel());
}
示例10: visitFrame
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
@Override
public final void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
FrameNode node = new FrameNode(type, nLocal, local == null ? null : convertValues(local), nStack,
stack == null ? null : convertValues(stack));
instructions.add(node);
addFrame(node);
}
示例11: isNextFrameNode
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
private static boolean isNextFrameNode(AbstractInsnNode node) {
for (AbstractInsnNode next = node.getNext(); next != null && next.getOpcode() == -1; next = next.getNext()) {
if (next instanceof FrameNode) {
return true;
}
}
return false;
}
示例12: transform
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
@Override
public void transform(byte[] bytes, ClassNode cn) {
////////////////////////////////////////////////////////////////
MethodNode method = this.findMethod(cn, "sendClickBlockToController", "func_147115_a");
InsnList code = method.instructions;
code.clear();
LabelNode l0 = new LabelNode();
code.add(l0);
code.add(new LineNumberNode(1460, l0));
code.add(new VarInsnNode(Opcodes.ILOAD, 1));
LabelNode l1 = new LabelNode();
code.add(new JumpInsnNode(Opcodes.IFNE, l1));
LabelNode l2 = new LabelNode();
code.add(l2);
code.add(new LineNumberNode(1462, l2));
code.add(new VarInsnNode(Opcodes.ALOAD, 0));
code.add(new InsnNode(Opcodes.ICONST_0));
code.add(leftClickCounter.putField());
code.add(l1);
code.add(new LineNumberNode(1484, l1));
code.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));
code.add(new InsnNode(Opcodes.RETURN));
method.maxStack = 2;
method.maxLocals = 2;
////////////////////////////////////////////////////////////////
}
示例13: visitFrame
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
public CodeBlock visitFrame(final int opcode, final int nrLocals,
final Object[] localTypes, final int nrStackElements,
final Object[] stackElements)
{
instructionList.add(new FrameNode(opcode, nrLocals, localTypes,
nrStackElements, stackElements));
return this;
}
示例14: retrieveTaintedArrayWithoutTags
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
public void retrieveTaintedArrayWithoutTags(String type) {
//A
Label isNull = new Label();
Label isDone = new Label();
FrameNode fn = getCurrentFrameNode();
super.visitInsn(DUP);
if(!isIgnoreAllInstrumenting)
super.visitInsn(TaintUtils.IGNORE_EVERYTHING);
super.visitJumpInsn(IFNULL, isNull);
if(!isIgnoreAllInstrumenting)
super.visitInsn(TaintUtils.IGNORE_EVERYTHING);
// System.out.println("unbox: " + onStack + " type passed is " + type);
Class boxType = MultiDTaintedArray.getClassForComponentType(Type.getType(type).getElementType().getSort());
super.visitTypeInsn(CHECKCAST, Type.getInternalName(boxType));
Type arrayDesc = Type.getType(type);
// System.out.println("Get tainted array from " + arrayDesc);
super.visitFieldInsn(GETFIELD, Type.getInternalName(boxType), "val", type);
FrameNode fn2 = getCurrentFrameNode();
super.visitJumpInsn(GOTO, isDone);
super.visitLabel(isNull);
acceptFn(fn);
super.visitTypeInsn(CHECKCAST, type);
super.visitLabel(isDone);
acceptFn(fn2);
}
示例15: generateFrameNode
import org.objectweb.asm.tree.FrameNode; //导入依赖的package包/类
FrameNode generateFrameNode(int type, int nLocal, Object[] local, int nStack, Object[] stack)
{
FrameNode ret = new FrameNode(type, nLocal, local, nStack, stack);
ret.local = new ArrayList<Object>();
ret.stack= new ArrayList<Object>();
visitFrameTypes(nLocal, local, ret.local);
visitFrameTypes(nStack, stack, ret.stack);
return ret;
}