org.objectweb.asm.tree.MultiANewArrayInsnNode Java Examples

The following examples show how to use org.objectweb.asm.tree.MultiANewArrayInsnNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Multianewarray.java    From nuls with MIT License 6 votes vote down vote up
public static void multianewarray(final Frame frame) {
    MultiANewArrayInsnNode multiANewArrayInsnNode = frame.multiANewArrayInsnNode();
    int[] dimensions = new int[multiANewArrayInsnNode.dims];
    for (int i = multiANewArrayInsnNode.dims - 1; i >= 0; i--) {
        int length = frame.operandStack.popInt();
        if (length < 0) {
            frame.throwNegativeArraySizeException();
            return;
        }
        dimensions[i] = length;
    }
    VariableType variableType = VariableType.valueOf(multiANewArrayInsnNode.desc);
    ObjectRef arrayRef = frame.heap.newArray(variableType, dimensions);
    frame.operandStack.pushRef(arrayRef);

    //Log.result(frame.getCurrentOpCode(), arrayRef);
}
 
Example #2
Source File: Multianewarray.java    From nuls-v2 with MIT License 6 votes vote down vote up
public static void multianewarray(final Frame frame) {
    MultiANewArrayInsnNode multiANewArrayInsnNode = frame.multiANewArrayInsnNode();
    int[] dimensions = new int[multiANewArrayInsnNode.dims];
    for (int i = multiANewArrayInsnNode.dims - 1; i >= 0; i--) {
        int length = frame.operandStack.popInt();
        if (length < 0) {
            frame.throwNegativeArraySizeException();
            return;
        }
        dimensions[i] = length;
    }
    VariableType variableType = VariableType.valueOf(multiANewArrayInsnNode.desc);
    ObjectRef arrayRef = frame.heap.newArray(variableType, dimensions);
    frame.operandStack.pushRef(arrayRef);

    //Log.result(frame.getCurrentOpCode(), arrayRef);
}
 
Example #3
Source File: CoffeeInterpreter.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CoffeeValue naryOperation(final AbstractInsnNode insn, final List<? extends CoffeeValue> values)
		throws AnalyzerException {
	int opcode = insn.getOpcode();
	if (opcode == MULTIANEWARRAY) {
		return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
	} else if (opcode == INVOKEDYNAMIC) {
		return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
	} else {
		return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
	}
}
 
Example #4
Source File: BasicInterpreter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public BasicValue naryOperation(
    final AbstractInsnNode insn, final List<? extends BasicValue> values)
    throws AnalyzerException {
  int opcode = insn.getOpcode();
  if (opcode == MULTIANEWARRAY) {
    return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
  } else if (opcode == INVOKEDYNAMIC) {
    return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
  } else {
    return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
  }
}
 
Example #5
Source File: BasicInterpreter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public BasicValue naryOperation(
    final AbstractInsnNode insn, final List<? extends BasicValue> values)
    throws AnalyzerException {
  int opcode = insn.getOpcode();
  if (opcode == MULTIANEWARRAY) {
    return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
  } else if (opcode == INVOKEDYNAMIC) {
    return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
  } else {
    return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
  }
}
 
Example #6
Source File: OpUtils.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
public static String toString(AbstractInsnNode ain) {
  String s = getOpcodeText(ain.getOpcode());
  switch (ain.getType()) {
  case AbstractInsnNode.FIELD_INSN:
    FieldInsnNode fin = (FieldInsnNode) ain;
    return s + " " + fin.owner + "#" + fin.name + " " + fin.desc;
  case AbstractInsnNode.METHOD_INSN:
    MethodInsnNode min = (MethodInsnNode) ain;
    return s + " " + min.owner + "#" + min.name + min.desc;
  case AbstractInsnNode.VAR_INSN:
    VarInsnNode vin = (VarInsnNode) ain;
    return s + " " + vin.var;
  case AbstractInsnNode.TYPE_INSN:
    TypeInsnNode tin = (TypeInsnNode) ain;
    return s + " " + tin.desc;
  case AbstractInsnNode.MULTIANEWARRAY_INSN:
    MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain;
    return s + " " + mnin.dims + " " + mnin.desc;
  case AbstractInsnNode.JUMP_INSN:
    JumpInsnNode jin = (JumpInsnNode) ain;
    return s + " " + getIndex(jin.label);
  case AbstractInsnNode.LDC_INSN:
    LdcInsnNode ldc = (LdcInsnNode) ain;
    return s + " " + ldc.cst.toString();
  case AbstractInsnNode.INT_INSN:
    return s + " " + getIntValue(ain);
  case AbstractInsnNode.IINC_INSN:
    IincInsnNode iinc = (IincInsnNode) ain;
    return s + " " + iinc.var + " +" + iinc.incr;
  case AbstractInsnNode.FRAME:
    FrameNode fn = (FrameNode) ain;
    return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size();
  case AbstractInsnNode.LABEL:
    LabelNode ln = (LabelNode) ain;
    return s + " " + getIndex(ln);
  }
  return s;
}
 
Example #7
Source File: BasicInterpreter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BasicValue naryOperation(final AbstractInsnNode insn, final List<? extends BasicValue> values) throws AnalyzerException {
  int opcode = insn.getOpcode();
  if (opcode == MULTIANEWARRAY) {
    return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
  } else if (opcode == INVOKEDYNAMIC) {
    return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
  } else {
    return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
  }
}
 
Example #8
Source File: Virtualizer.java    From radon with GNU General Public License v3.0 5 votes vote down vote up
private static boolean canProtect(InsnList insnList) {
    return Stream.of(insnList.toArray()).noneMatch(insn -> insn.getOpcode() == INVOKEDYNAMIC
            || (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Handle)
            || insn instanceof MultiANewArrayInsnNode
            || insn instanceof LookupSwitchInsnNode
            || insn instanceof TableSwitchInsnNode);
}
 
Example #9
Source File: StackHelper.java    From zelixkiller with GNU General Public License v3.0 5 votes vote down vote up
public InsnValue onMultiANewArray(MultiANewArrayInsnNode insn, List<InsnValue> values) {
	Type t = Type.getType((insn).desc);
	// I have no idea how I would go about making new N-D arrays without
	// really REALLY ugly code.
	//
	// TODO: Suck it up and do the ugly.
	return new InsnValue(t);
}
 
Example #10
Source File: MultiANewArrayInsnNodeSerializer.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
@Override
public JsonElement serialize(MultiANewArrayInsnNode src, Type typeOfSrc, JsonSerializationContext context) {
	JsonObject object = new JsonObject();
    object.add("desc", context.serialize(src.desc));
    object.add("dims", context.serialize(src.dims));
    return object;
}
 
Example #11
Source File: MultiANewArrayInsnNodeSerializer.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
@Override
  public MultiANewArrayInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
String desc = jsonObject.get("desc").getAsString();
int dims = jsonObject.get("dims").getAsInt();
      return new MultiANewArrayInsnNode(desc, dims);
  }
 
Example #12
Source File: BasicInterpreter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public BasicValue naryOperation(
    final AbstractInsnNode insn, final List<? extends BasicValue> values)
    throws AnalyzerException {
  int opcode = insn.getOpcode();
  if (opcode == MULTIANEWARRAY) {
    return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
  } else if (opcode == INVOKEDYNAMIC) {
    return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
  } else {
    return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
  }
}
 
Example #13
Source File: OpcodeFormatting.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
public static String toString(AbstractInsnNode ain) {
	String s = getOpcodeText(ain.getOpcode());
	switch (ain.getType()) {
	case AbstractInsnNode.FIELD_INSN:
		FieldInsnNode fin = (FieldInsnNode) ain;
		return s + " " + fin.owner + "#" + fin.name + " " + fin.desc;
	case AbstractInsnNode.METHOD_INSN:
		MethodInsnNode min = (MethodInsnNode) ain;
		return s + " " + min.owner + "#" + min.name + min.desc;
	case AbstractInsnNode.VAR_INSN:
		VarInsnNode vin = (VarInsnNode) ain;
		return s + " " + vin.var;
	case AbstractInsnNode.TYPE_INSN:
		TypeInsnNode tin = (TypeInsnNode) ain;
		return s + " " + tin.desc;
	case AbstractInsnNode.MULTIANEWARRAY_INSN:
		MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain;
		return s + " " + mnin.dims + " " + mnin.desc;
	case AbstractInsnNode.JUMP_INSN:
		JumpInsnNode jin = (JumpInsnNode) ain;
		return s + " " + getIndex(jin.label);
	case AbstractInsnNode.LDC_INSN:
		LdcInsnNode ldc = (LdcInsnNode) ain;
		return s + " " + ldc.cst.toString();
	case AbstractInsnNode.INT_INSN:
		return s + " " + getIntValue(ain);
	case AbstractInsnNode.IINC_INSN:
		IincInsnNode iinc = (IincInsnNode) ain;
		return s + " " + iinc.var + " +" + iinc.incr;
	case AbstractInsnNode.FRAME:
		FrameNode fn = (FrameNode) ain;
		return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size();
	case AbstractInsnNode.LABEL:
		LabelNode ln = (LabelNode) ain;
		return s + " " + getIndex(ln);
	}
	return s;
}
 
Example #14
Source File: BasicInterpreter.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BasicValue naryOperation(final AbstractInsnNode insn, final List<? extends BasicValue> values)
		throws AnalyzerException {
	int opcode = insn.getOpcode();
	if (opcode == MULTIANEWARRAY) {
		return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
	} else if (opcode == INVOKEDYNAMIC) {
		return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
	} else {
		return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
	}
}
 
Example #15
Source File: MultiANewArrayInstructionFilter.java    From maple-ir with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean accept(AbstractInsnNode t) {
	if (!(t instanceof MultiANewArrayInsnNode))
		return false;
	return descFilter.accept(((MultiANewArrayInsnNode) t).desc) && dimsFilter.accept(((MultiANewArrayInsnNode) t).dims);
}
 
Example #16
Source File: FrameSateTrackingMethodVisitor.java    From Concurnas with MIT License 4 votes vote down vote up
public void visitMultiANewArrayInsn(String desc, int dims) {
	BytecodeStackFrameModifier.intepret(0, MULTIANEWARRAY, new MultiANewArrayInsnNode(desc, dims), currentFrame, "");
	super.visitMultiANewArrayInsn(desc, dims);
}
 
Example #17
Source File: InstrUtils.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
public static String toString(AbstractInsnNode ain) {
	String opc = TextUtils.toBold(OpUtils.getOpcodeText(ain.getOpcode()).toLowerCase()) + " ";
	switch (ain.getType()) {
	case AbstractInsnNode.LABEL:
		opc = TextUtils.toLight("label " + OpUtils.getLabelIndex((LabelNode) ain));
		break;
	case AbstractInsnNode.LINE:
		opc = TextUtils.toLight("line " + ((LineNumberNode) ain).line);
		break;
	case AbstractInsnNode.FIELD_INSN:
		FieldInsnNode fin = (FieldInsnNode) ain;
		opc += getDisplayType(TextUtils.escape(fin.desc), true) + " " + getDisplayClassRed(TextUtils.escape(fin.owner))
				+ "." + fin.name;
		break;
	case AbstractInsnNode.METHOD_INSN:
		MethodInsnNode min = (MethodInsnNode) ain;
		if (min.desc.contains(")")) {
			opc += getDisplayType(min.desc.split("\\)")[1], true);
		} else {
			opc += min.desc;
		}
		opc += " " + getDisplayClassRed(TextUtils.escape(min.owner)) + "." + TextUtils.escape(min.name) + "("
				+ getDisplayArgs(TextUtils.escape(min.desc)) + ")";
		break;
	case AbstractInsnNode.VAR_INSN:
		VarInsnNode vin = (VarInsnNode) ain;
		opc += vin.var;
		break;
	case AbstractInsnNode.TYPE_INSN:
		TypeInsnNode tin = (TypeInsnNode) ain;
		String esc = TextUtils.escape(tin.desc);
		if (esc.endsWith(";") && esc.startsWith("L")) {
			opc += TextUtils.addTag(esc, "font color=" + primColor.getString());
		} else {
			opc += getDisplayClass(esc);
		}
		break;
	case AbstractInsnNode.MULTIANEWARRAY_INSN:
		MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain;
		opc += mnin.dims + " " + getDisplayType(TextUtils.escape(mnin.desc), true);
		break;
	case AbstractInsnNode.JUMP_INSN:
		JumpInsnNode jin = (JumpInsnNode) ain;
		opc += OpUtils.getLabelIndex(jin.label);
		break;
	case AbstractInsnNode.LDC_INSN:
		LdcInsnNode ldc = (LdcInsnNode) ain;
		opc += TextUtils.addTag(ldc.cst.getClass().getSimpleName(), "font color=" + primColor.getString()) + " ";
		if (ldc.cst instanceof String)
			opc += TextUtils.addTag("\"" + TextUtils.escape(ldc.cst.toString()) + "\"", "font color=#559955");
		else {
			opc += ldc.cst.toString();
		}
		break;
	case AbstractInsnNode.INT_INSN:
		opc += OpUtils.getIntValue(ain);
		break;
	case AbstractInsnNode.IINC_INSN:
		IincInsnNode iinc = (IincInsnNode) ain;
		opc += iinc.var + " " + iinc.incr;
		break;
	case AbstractInsnNode.FRAME:
		FrameNode fn = (FrameNode) ain;
		opc = TextUtils
				.toLight(OpUtils.getFrameType(fn.type).toLowerCase() + " " + fn.local.size() + " " + fn.stack.size());
		break;
	case AbstractInsnNode.TABLESWITCH_INSN:
		TableSwitchInsnNode tsin = (TableSwitchInsnNode) ain;
		if (tsin.dflt != null) {
			opc += TextUtils.addTag("L" + OpUtils.getLabelIndex(tsin.dflt), "font color=" + secColor.getString());
		}
		if (tsin.labels.size() < 20) {
			for (LabelNode l : tsin.labels) {
				opc += " " + TextUtils.addTag("L" + OpUtils.getLabelIndex(l), "font color=" + primColor.getString());
			}
		} else {
			opc += " " + TextUtils.addTag(tsin.labels.size() + " cases", "font color=" + primColor.getString());
		}
		break;
	case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
		InvokeDynamicInsnNode idin = (InvokeDynamicInsnNode) ain;
		Object[] arr = idin.bsmArgs;
		if (arr.length > 1) {
			Object o = arr[1];
			if (o instanceof Handle) {
				Handle h = (Handle) o;
				opc += getDisplayType(h.getDesc().split("\\)")[1], true) + " "
						+ getDisplayClassRed(TextUtils.escape(h.getOwner())) + "." + TextUtils.escape(h.getName()) + "("
						+ getDisplayArgs(TextUtils.escape(h.getDesc())) + ")";

			}
		} else {
			opc += TextUtils.addTag(TextUtils.escape(idin.name), "font color=" + primColor.getString()) + " "
					+ TextUtils.escape(idin.desc);
		}
		break;
	}
	return opc;
}
 
Example #18
Source File: InstrUtils.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
public static String toEasyString(AbstractInsnNode ain) {
	String opc = OpUtils.getOpcodeText(ain.getOpcode()).toLowerCase() + " ";
	switch (ain.getType()) {
	case AbstractInsnNode.LABEL:
		opc = "label " + OpUtils.getLabelIndex((LabelNode) ain);
		break;
	case AbstractInsnNode.LINE:
		opc = "line " + ((LineNumberNode) ain).line;
		break;
	case AbstractInsnNode.FIELD_INSN:
		FieldInsnNode fin = (FieldInsnNode) ain;
		opc += getDisplayType(fin.desc, false) + " " + getDisplayClassEasy(fin.owner) + "." + fin.name;
		break;
	case AbstractInsnNode.METHOD_INSN:
		MethodInsnNode min = (MethodInsnNode) ain;
		opc += getDisplayType(min.desc.split("\\)")[1], false) + " " + getDisplayClassEasy(min.owner) + "." + min.name
				+ "(" + getDisplayArgsEasy(min.desc) + ")";
		break;
	case AbstractInsnNode.VAR_INSN:
		VarInsnNode vin = (VarInsnNode) ain;
		opc += vin.var;
		break;
	case AbstractInsnNode.MULTIANEWARRAY_INSN:
		MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain;
		opc += mnin.dims + " " + getDisplayType(mnin.desc, false);
		break;
	case AbstractInsnNode.TYPE_INSN:
		TypeInsnNode tin = (TypeInsnNode) ain;
		String esc = tin.desc;
		if (esc.endsWith(";") && esc.startsWith("L")) {
			opc += esc;
		} else {
			opc += getDisplayClassEasy(esc);
		}
		break;
	case AbstractInsnNode.JUMP_INSN:
		JumpInsnNode jin = (JumpInsnNode) ain;
		opc += OpUtils.getLabelIndex(jin.label);
		break;
	case AbstractInsnNode.LDC_INSN:
		LdcInsnNode ldc = (LdcInsnNode) ain;
		opc += ldc.cst.getClass().getSimpleName() + " ";
		if (ldc.cst instanceof String)
			opc += "\"" + ldc.cst.toString() + "\"";
		else {
			opc += ldc.cst.toString();
		}
		break;
	case AbstractInsnNode.INT_INSN:
		opc += OpUtils.getIntValue(ain);
		break;
	case AbstractInsnNode.IINC_INSN:
		IincInsnNode iinc = (IincInsnNode) ain;
		opc += iinc.var + " " + iinc.incr;
		break;
	case AbstractInsnNode.FRAME:
		FrameNode fn = (FrameNode) ain;
		opc = OpUtils.getOpcodeText(fn.type).toLowerCase() + " " + fn.local.size() + " " + fn.stack.size();
		break;
	case AbstractInsnNode.TABLESWITCH_INSN:
		TableSwitchInsnNode tsin = (TableSwitchInsnNode) ain;
		if (tsin.dflt != null) {
			opc += "L" + OpUtils.getLabelIndex(tsin.dflt);
		}
		if (tsin.labels.size() < 20) {
			for (LabelNode l : tsin.labels) {
				opc += " " + "L" + OpUtils.getLabelIndex(l);
			}
		} else {
			opc += " " + tsin.labels.size() + " cases";
		}
		break;
	case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
		InvokeDynamicInsnNode idin = (InvokeDynamicInsnNode) ain;
		opc += idin.name + " " + idin.desc;
		break;
	}
	return opc;
}
 
Example #19
Source File: MultiANewArrayHandler.java    From native-obfuscator with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void process(MethodContext context, MultiANewArrayInsnNode node) {
    props.put("count", String.valueOf(node.dims));
    props.put("desc", node.desc);
}
 
Example #20
Source File: InsnListPrinter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void _visitInsn(AbstractInsnNode insn) {
	switch (insn.getType()) {
		case 0:
			visitInsn(insn.getOpcode());
			break;
		case 1:
			IntInsnNode iinsn = (IntInsnNode) insn;
			visitIntInsn(iinsn.getOpcode(), iinsn.operand);
			break;
		case 2:
			VarInsnNode vinsn = (VarInsnNode) insn;
			visitVarInsn(vinsn.getOpcode(), vinsn.var);
			break;
		case 3:
			TypeInsnNode tinsn = (TypeInsnNode) insn;
			visitTypeInsn(tinsn.getOpcode(), tinsn.desc);
			break;
		case 4:
			FieldInsnNode finsn = (FieldInsnNode) insn;
			visitFieldInsn(finsn.getOpcode(), finsn.owner, finsn.name, finsn.desc);
			break;
		case 5:
			MethodInsnNode minsn = (MethodInsnNode) insn;
			visitMethodInsn(minsn.getOpcode(), minsn.owner, minsn.name, minsn.desc);
			break;
		case 6:
			InvokeDynamicInsnNode idinsn = (InvokeDynamicInsnNode) insn;
			visitInvokeDynamicInsn(idinsn.name, idinsn.desc, idinsn.bsm, idinsn.bsmArgs);
			break;
		case 7:
			JumpInsnNode jinsn = (JumpInsnNode) insn;
			visitJumpInsn(jinsn.getOpcode(), jinsn.label.getLabel());
			break;
		case 8:
			LabelNode linsn = (LabelNode) insn;
			visitLabel(linsn.getLabel());
			break;
		case 9:
			LdcInsnNode ldcinsn = (LdcInsnNode) insn;
			visitLdcInsn(ldcinsn.cst);
			break;
		case 10:
			IincInsnNode iiinsn = (IincInsnNode) insn;
			visitIincInsn(iiinsn.var, iiinsn.incr);
			break;
		case 11:
			TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn;
			Label[] tslables = new Label[tsinsn.labels.size()];
			for (int i = 0; i < tslables.length; i++) {
				tslables[i] = tsinsn.labels.get(i).getLabel();
			}
			visitTableSwitchInsn(tsinsn.min, tsinsn.max, tsinsn.dflt.getLabel(), tslables);
			break;
		case 12:
			LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn;
			Label[] lslables = new Label[lsinsn.labels.size()];
			for (int i = 0; i < lslables.length; i++) {
				lslables[i] = lsinsn.labels.get(i).getLabel();
			}
			int[] lskeys = new int[lsinsn.keys.size()];
			for (int i = 0; i < lskeys.length; i++) {
				lskeys[i] = lsinsn.keys.get(i);
			}
			visitLookupSwitchInsn(lsinsn.dflt.getLabel(), lskeys, lslables);
			break;
		case 13:
			MultiANewArrayInsnNode ainsn = (MultiANewArrayInsnNode) insn;
			visitMultiANewArrayInsn(ainsn.desc, ainsn.dims);
			break;
		case 14:
			FrameNode fnode = (FrameNode) insn;
			switch (fnode.type) {
				case -1:
				case 0:
					visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), fnode.stack.size(), fnode.stack.toArray());
					break;
				case 1:
					visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), 0, null);
					break;
				case 2:
					visitFrame(fnode.type, fnode.local.size(), null, 0, null);
					break;
				case 3:
					visitFrame(fnode.type, 0, null, 0, null);
					break;
				case 4:
					visitFrame(fnode.type, 0, null, 1, fnode.stack.toArray());
			}
			break;
		case 15:
			LineNumberNode lnode = (LineNumberNode) insn;
			visitLineNumber(lnode.line, lnode.start.getLabel());
			break;
	}
}
 
Example #21
Source File: InsnListPrinter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void _visitInsn(AbstractInsnNode insn) {
	switch (insn.getType()) {
		case 0:
			visitInsn(insn.getOpcode());
			break;
		case 1:
			IntInsnNode iinsn = (IntInsnNode) insn;
			visitIntInsn(iinsn.getOpcode(), iinsn.operand);
			break;
		case 2:
			VarInsnNode vinsn = (VarInsnNode) insn;
			visitVarInsn(vinsn.getOpcode(), vinsn.var);
			break;
		case 3:
			TypeInsnNode tinsn = (TypeInsnNode) insn;
			visitTypeInsn(tinsn.getOpcode(), tinsn.desc);
			break;
		case 4:
			FieldInsnNode finsn = (FieldInsnNode) insn;
			visitFieldInsn(finsn.getOpcode(), finsn.owner, finsn.name, finsn.desc);
			break;
		case 5:
			MethodInsnNode minsn = (MethodInsnNode) insn;
			visitMethodInsn(minsn.getOpcode(), minsn.owner, minsn.name, minsn.desc);
			break;
		case 6:
			InvokeDynamicInsnNode idinsn = (InvokeDynamicInsnNode) insn;
			visitInvokeDynamicInsn(idinsn.name, idinsn.desc, idinsn.bsm, idinsn.bsmArgs);
			break;
		case 7:
			JumpInsnNode jinsn = (JumpInsnNode) insn;
			visitJumpInsn(jinsn.getOpcode(), jinsn.label.getLabel());
			break;
		case 8:
			LabelNode linsn = (LabelNode) insn;
			visitLabel(linsn.getLabel());
			break;
		case 9:
			LdcInsnNode ldcinsn = (LdcInsnNode) insn;
			visitLdcInsn(ldcinsn.cst);
			break;
		case 10:
			IincInsnNode iiinsn = (IincInsnNode) insn;
			visitIincInsn(iiinsn.var, iiinsn.incr);
			break;
		case 11:
			TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn;
			Label[] tslables = new Label[tsinsn.labels.size()];
			for (int i = 0; i < tslables.length; i++) {
				tslables[i] = tsinsn.labels.get(i).getLabel();
			}
			visitTableSwitchInsn(tsinsn.min, tsinsn.max, tsinsn.dflt.getLabel(), tslables);
			break;
		case 12:
			LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn;
			Label[] lslables = new Label[lsinsn.labels.size()];
			for (int i = 0; i < lslables.length; i++) {
				lslables[i] = lsinsn.labels.get(i).getLabel();
			}
			int[] lskeys = new int[lsinsn.keys.size()];
			for (int i = 0; i < lskeys.length; i++) {
				lskeys[i] = lsinsn.keys.get(i);
			}
			visitLookupSwitchInsn(lsinsn.dflt.getLabel(), lskeys, lslables);
			break;
		case 13:
			MultiANewArrayInsnNode ainsn = (MultiANewArrayInsnNode) insn;
			visitMultiANewArrayInsn(ainsn.desc, ainsn.dims);
			break;
		case 14:
			FrameNode fnode = (FrameNode) insn;
			switch (fnode.type) {
				case -1:
				case 0:
					visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), fnode.stack.size(), fnode.stack.toArray());
					break;
				case 1:
					visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), 0, null);
					break;
				case 2:
					visitFrame(fnode.type, fnode.local.size(), null, 0, null);
					break;
				case 3:
					visitFrame(fnode.type, 0, null, 0, null);
					break;
				case 4:
					visitFrame(fnode.type, 0, null, 1, fnode.stack.toArray());
			}
			break;
		case 15:
			LineNumberNode lnode = (LineNumberNode) insn;
			visitLineNumber(lnode.line, lnode.start.getLabel());
			break;
	}
}
 
Example #22
Source File: InsnListPrinter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void _visitInsn(AbstractInsnNode insn) {
	switch (insn.getType()) {
		case 0:
			visitInsn(insn.getOpcode());
			break;
		case 1:
			IntInsnNode iinsn = (IntInsnNode) insn;
			visitIntInsn(iinsn.getOpcode(), iinsn.operand);
			break;
		case 2:
			VarInsnNode vinsn = (VarInsnNode) insn;
			visitVarInsn(vinsn.getOpcode(), vinsn.var);
			break;
		case 3:
			TypeInsnNode tinsn = (TypeInsnNode) insn;
			visitTypeInsn(tinsn.getOpcode(), tinsn.desc);
			break;
		case 4:
			FieldInsnNode finsn = (FieldInsnNode) insn;
			visitFieldInsn(finsn.getOpcode(), finsn.owner, finsn.name, finsn.desc);
			break;
		case 5:
			MethodInsnNode minsn = (MethodInsnNode) insn;
			visitMethodInsn(minsn.getOpcode(), minsn.owner, minsn.name, minsn.desc);
			break;
		case 6:
			InvokeDynamicInsnNode idinsn = (InvokeDynamicInsnNode) insn;
			visitInvokeDynamicInsn(idinsn.name, idinsn.desc, idinsn.bsm, idinsn.bsmArgs);
			break;
		case 7:
			JumpInsnNode jinsn = (JumpInsnNode) insn;
			visitJumpInsn(jinsn.getOpcode(), jinsn.label.getLabel());
			break;
		case 8:
			LabelNode linsn = (LabelNode) insn;
			visitLabel(linsn.getLabel());
			break;
		case 9:
			LdcInsnNode ldcinsn = (LdcInsnNode) insn;
			visitLdcInsn(ldcinsn.cst);
			break;
		case 10:
			IincInsnNode iiinsn = (IincInsnNode) insn;
			visitIincInsn(iiinsn.var, iiinsn.incr);
			break;
		case 11:
			TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn;
			Label[] tslables = new Label[tsinsn.labels.size()];
			for (int i = 0; i < tslables.length; i++) {
				tslables[i] = tsinsn.labels.get(i).getLabel();
			}
			visitTableSwitchInsn(tsinsn.min, tsinsn.max, tsinsn.dflt.getLabel(), tslables);
			break;
		case 12:
			LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn;
			Label[] lslables = new Label[lsinsn.labels.size()];
			for (int i = 0; i < lslables.length; i++) {
				lslables[i] = lsinsn.labels.get(i).getLabel();
			}
			int[] lskeys = new int[lsinsn.keys.size()];
			for (int i = 0; i < lskeys.length; i++) {
				lskeys[i] = lsinsn.keys.get(i);
			}
			visitLookupSwitchInsn(lsinsn.dflt.getLabel(), lskeys, lslables);
			break;
		case 13:
			MultiANewArrayInsnNode ainsn = (MultiANewArrayInsnNode) insn;
			visitMultiANewArrayInsn(ainsn.desc, ainsn.dims);
			break;
		case 14:
			FrameNode fnode = (FrameNode) insn;
			switch (fnode.type) {
				case -1:
				case 0:
					visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), fnode.stack.size(), fnode.stack.toArray());
					break;
				case 1:
					visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), 0, null);
					break;
				case 2:
					visitFrame(fnode.type, fnode.local.size(), null, 0, null);
					break;
				case 3:
					visitFrame(fnode.type, 0, null, 0, null);
					break;
				case 4:
					visitFrame(fnode.type, 0, null, 1, fnode.stack.toArray());
			}
			break;
		case 15:
			LineNumberNode lnode = (LineNumberNode) insn;
			visitLineNumber(lnode.line, lnode.start.getLabel());
			break;
	}
}
 
Example #23
Source File: CodeBlock.java    From grappa with Apache License 2.0 4 votes vote down vote up
public CodeBlock multianewarray(final String arrayDesc, final int dims)
{
    instructionList.add(new MultiANewArrayInsnNode(arrayDesc, dims));
    return this;
}
 
Example #24
Source File: CodeBlock.java    From grappa with Apache License 2.0 4 votes vote down vote up
public CodeBlock visitMultiANewArrayInsn(final String desc, final int dims)
{
    instructionList.add(new MultiANewArrayInsnNode(desc, dims));
    return this;
}