Java Code Examples for org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn()
The following examples show how to use
org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn() .
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: NewArrayExpr.java From maple-ir with GNU General Public License v3.0 | 6 votes |
@Override public void toCode(MethodVisitor visitor, BytecodeFrontend assembler) { for (int i = 0; i < bounds.length; i++) { bounds[i].toCode(visitor, assembler); int[] cast = TypeUtils.getPrimitiveCastOpcodes(bounds[i].getType(), Type.INT_TYPE); for (int a = 0; a < cast.length; a++) visitor.visitInsn(cast[a]); } if (type.getDimensions() != 1) { visitor.visitMultiANewArrayInsn(type.getDescriptor(), bounds.length); } else { Type element = type.getElementType(); if (element.getSort() == Type.OBJECT || element.getSort() == Type.METHOD) { visitor.visitTypeInsn(Opcodes.ANEWARRAY, element.getInternalName()); } else { visitor.visitIntInsn(Opcodes.NEWARRAY, TypeUtils.getPrimitiveArrayOpcode(type)); } } }
Example 2
Source File: MethodTests.java From Despector with MIT License | 6 votes |
@Test public void testMultiNewArray() { TestMethodBuilder builder = new TestMethodBuilder("test_mth", "()V"); MethodVisitor mv = builder.getGenerator(); Label start = new Label(); Label l1 = new Label(); Label end = new Label(); mv.visitLabel(start); mv.visitInsn(ICONST_5); mv.visitIntInsn(BIPUSH, 6); mv.visitMultiANewArrayInsn("[[I", 2); mv.visitVarInsn(ASTORE, 0); mv.visitLabel(l1); mv.visitInsn(RETURN); mv.visitLabel(end); mv.visitLocalVariable("a", "[[I", null, l1, end, 0); String insn = TestHelper.getAsString(builder.finish(), "test_mth"); String good = "int[][] a = new int[5][6];"; Assert.assertEquals(good, insn); }
Example 3
Source File: MultiANewArrayInsnNode.java From Cafebabe with GNU General Public License v3.0 | 4 votes |
@Override public void accept(final MethodVisitor methodVisitor) { methodVisitor.visitMultiANewArrayInsn(desc, dims); acceptAnnotations(methodVisitor); }
Example 4
Source File: MultiANewArrayInsnNode.java From Concurnas with MIT License | 4 votes |
@Override public void accept(final MethodVisitor methodVisitor) { methodVisitor.visitMultiANewArrayInsn(desc, dims); acceptAnnotations(methodVisitor); }
Example 5
Source File: MultiANewArray.java From OSRS-Deobfuscator with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void accept(MethodVisitor visitor) { visitor.visitMultiANewArrayInsn(type.toString(), dimensions); }
Example 6
Source File: MultiANewArrayInsnNode.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitMultiANewArrayInsn(desc, dims); acceptAnnotations(mv); }
Example 7
Source File: AsmClassGenerator.java From groovy with Apache License 2.0 | 4 votes |
@Override public void visitArrayExpression(final ArrayExpression expression) { MethodVisitor mv = controller.getMethodVisitor(); ClassNode elementType = expression.getElementType(); String arrayTypeName = BytecodeHelper.getClassInternalName(elementType); List<Expression> sizeExpression = expression.getSizeExpression(); int size = 0; int dimensions = 0; if (sizeExpression != null) { for (Expression element : sizeExpression) { if (element == ConstantExpression.EMPTY_EXPRESSION) break; dimensions += 1; // let's convert to an int element.visit(this); controller.getOperandStack().doGroovyCast(ClassHelper.int_TYPE); } controller.getOperandStack().remove(dimensions); } else { size = expression.getExpressions().size(); BytecodeHelper.pushConstant(mv, size); } int storeIns = AASTORE; if (sizeExpression != null) { arrayTypeName = BytecodeHelper.getTypeDescription(expression.getType()); mv.visitMultiANewArrayInsn(arrayTypeName, dimensions); } else if (ClassHelper.isPrimitiveType(elementType)) { int primType = 0; if (elementType == ClassHelper.boolean_TYPE) { primType = T_BOOLEAN; storeIns = BASTORE; } else if (elementType == ClassHelper.char_TYPE) { primType = T_CHAR; storeIns = CASTORE; } else if (elementType == ClassHelper.float_TYPE) { primType = T_FLOAT; storeIns = FASTORE; } else if (elementType == ClassHelper.double_TYPE) { primType = T_DOUBLE; storeIns = DASTORE; } else if (elementType == ClassHelper.byte_TYPE) { primType = T_BYTE; storeIns = BASTORE; } else if (elementType == ClassHelper.short_TYPE) { primType = T_SHORT; storeIns = SASTORE; } else if (elementType == ClassHelper.int_TYPE) { primType = T_INT; storeIns = IASTORE; } else if (elementType == ClassHelper.long_TYPE) { primType = T_LONG; storeIns = LASTORE; } mv.visitIntInsn(NEWARRAY, primType); } else { mv.visitTypeInsn(ANEWARRAY, arrayTypeName); } for (int i = 0; i < size; i += 1) { mv.visitInsn(DUP); BytecodeHelper.pushConstant(mv, i); Expression elementExpression = expression.getExpression(i); if (elementExpression == null) { ConstantExpression.NULL.visit(this); } else { elementExpression.visit(this); controller.getOperandStack().doGroovyCast(elementType); } mv.visitInsn(storeIns); controller.getOperandStack().remove(1); } controller.getOperandStack().push(expression.getType()); }
Example 8
Source File: MultiANewArrayInsnNode.java From JReFrameworker with MIT License | 4 votes |
@Override public void accept(final MethodVisitor methodVisitor) { methodVisitor.visitMultiANewArrayInsn(desc, dims); acceptAnnotations(methodVisitor); }
Example 9
Source File: MultiANewArrayInsnNode.java From JReFrameworker with MIT License | 4 votes |
@Override public void accept(final MethodVisitor methodVisitor) { methodVisitor.visitMultiANewArrayInsn(desc, dims); acceptAnnotations(methodVisitor); }