List of usage examples for org.objectweb.asm Opcodes LONG
Integer LONG
To view the source code for org.objectweb.asm Opcodes LONG.
Click Source Link
From source file:blockphysics.asm.BPTransformer.java
License:Open Source License
private byte[] transformBlockPhysics(byte[] bytes) { /*try// w w w . jav a2 s . co m { FileOutputStream fos = new FileOutputStream("d:/BlockPhysics.orig.class"); fos.write(bytes); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ try { Class.forName("org.bukkit.Bukkit"); System.out.println("[BlockPhysics] Bukkit detected."); } catch (ClassNotFoundException e) { return bytes; } System.out.print("[BlockPhysics] Patching BlockPhysics.class ............"); boolean ok = false; ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); MethodNode m; Iterator<MethodNode> methods = classNode.methods.iterator(); while (methods.hasNext()) { m = methods.next(); if (m.name.equals("tickBlocksRandomMove") && m.desc.equals("(Ljr;)V")) { m.instructions.clear(); m.localVariables.clear(); InsnList toInject = new InsnList(); toInject.add(new FieldInsnNode(GETSTATIC, "blockphysics/BlockPhysics", "skipMove", "Z")); LabelNode l0 = new LabelNode(); toInject.add(new JumpInsnNode(IFEQ, l0)); toInject.add(new InsnNode(RETURN)); toInject.add(l0); toInject.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null)); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new FieldInsnNode(GETFIELD, "jr", "G", "Lgnu/trove/map/hash/TLongShortHashMap;")); toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "gnu/trove/map/hash/TLongShortHashMap", "iterator", "()Lgnu/trove/iterator/TLongShortIterator;")); toInject.add(new VarInsnNode(ASTORE, 1)); LabelNode l1 = new LabelNode(); toInject.add(l1); toInject.add(new FrameNode(Opcodes.F_APPEND, 1, new Object[] { "gnu/trove/iterator/TLongShortIterator" }, 0, null)); toInject.add(new VarInsnNode(ALOAD, 1)); toInject.add(new MethodInsnNode(INVOKEINTERFACE, "gnu/trove/iterator/TLongShortIterator", "hasNext", "()Z")); LabelNode l2 = new LabelNode(); toInject.add(new JumpInsnNode(IFEQ, l2)); toInject.add(new VarInsnNode(ALOAD, 1)); toInject.add(new MethodInsnNode(INVOKEINTERFACE, "gnu/trove/iterator/TLongShortIterator", "advance", "()V")); toInject.add(new VarInsnNode(ALOAD, 1)); toInject.add( new MethodInsnNode(INVOKEINTERFACE, "gnu/trove/iterator/TLongShortIterator", "key", "()J")); toInject.add(new VarInsnNode(LSTORE, 2)); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new InsnNode(POP)); toInject.add(new VarInsnNode(LLOAD, 2)); toInject.add(new MethodInsnNode(INVOKESTATIC, "abv", "keyToX", "(J)I")); toInject.add(new VarInsnNode(ISTORE, 4)); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new InsnNode(POP)); toInject.add(new VarInsnNode(LLOAD, 2)); toInject.add(new MethodInsnNode(INVOKESTATIC, "abv", "keyToZ", "(J)I")); toInject.add(new VarInsnNode(ISTORE, 5)); toInject.add(new VarInsnNode(ILOAD, 4)); toInject.add(new IntInsnNode(BIPUSH, 16)); toInject.add(new InsnNode(IMUL)); toInject.add(new VarInsnNode(ISTORE, 6)); toInject.add(new VarInsnNode(ILOAD, 5)); toInject.add(new IntInsnNode(BIPUSH, 16)); toInject.add(new InsnNode(IMUL)); toInject.add(new VarInsnNode(ISTORE, 7)); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new VarInsnNode(ILOAD, 4)); toInject.add(new VarInsnNode(ILOAD, 5)); toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "jr", "e", "(II)Ladq;")); toInject.add(new VarInsnNode(ASTORE, 8)); toInject.add(new VarInsnNode(ALOAD, 8)); toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "adq", "i", "()[Ladr;")); toInject.add(new VarInsnNode(ASTORE, 12)); toInject.add(new VarInsnNode(ALOAD, 12)); toInject.add(new InsnNode(ARRAYLENGTH)); toInject.add(new VarInsnNode(ISTORE, 9)); toInject.add(new InsnNode(ICONST_0)); toInject.add(new VarInsnNode(ISTORE, 10)); LabelNode l3 = new LabelNode(); toInject.add(l3); toInject.add(new FrameNode(Opcodes.F_FULL, 12, new Object[] { "jr", "gnu/trove/iterator/TLongShortIterator", Opcodes.LONG, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, "adq", Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.TOP, "[Ladr;" }, 0, new Object[] {})); toInject.add(new VarInsnNode(ILOAD, 10)); toInject.add(new VarInsnNode(ILOAD, 9)); LabelNode l4 = new LabelNode(); toInject.add(new JumpInsnNode(IF_ICMPGE, l4)); toInject.add(new VarInsnNode(ALOAD, 12)); toInject.add(new VarInsnNode(ILOAD, 10)); toInject.add(new InsnNode(AALOAD)); toInject.add(new VarInsnNode(ASTORE, 13)); toInject.add(new VarInsnNode(ALOAD, 13)); LabelNode l5 = new LabelNode(); toInject.add(new JumpInsnNode(IFNULL, l5)); toInject.add(new InsnNode(ICONST_0)); toInject.add(new VarInsnNode(ISTORE, 14)); LabelNode l6 = new LabelNode(); toInject.add(l6); toInject.add(new FrameNode(Opcodes.F_APPEND, 2, new Object[] { "adr", Opcodes.INTEGER }, 0, null)); toInject.add(new VarInsnNode(ILOAD, 14)); toInject.add(new InsnNode(ICONST_3)); toInject.add(new JumpInsnNode(IF_ICMPGE, l5)); toInject.add(new FieldInsnNode(GETSTATIC, "blockphysics/BlockPhysics", "updateLCG", "I")); toInject.add(new InsnNode(ICONST_3)); toInject.add(new InsnNode(IMUL)); toInject.add(new LdcInsnNode(new Integer(1013904223))); toInject.add(new InsnNode(IADD)); toInject.add(new FieldInsnNode(PUTSTATIC, "blockphysics/BlockPhysics", "updateLCG", "I")); toInject.add(new FieldInsnNode(GETSTATIC, "blockphysics/BlockPhysics", "updateLCG", "I")); toInject.add(new InsnNode(ICONST_2)); toInject.add(new InsnNode(ISHR)); toInject.add(new VarInsnNode(ISTORE, 11)); toInject.add(new VarInsnNode(ILOAD, 11)); toInject.add(new IntInsnNode(BIPUSH, 15)); toInject.add(new InsnNode(IAND)); toInject.add(new VarInsnNode(ISTORE, 15)); toInject.add(new VarInsnNode(ILOAD, 11)); toInject.add(new IntInsnNode(BIPUSH, 8)); toInject.add(new InsnNode(ISHR)); toInject.add(new IntInsnNode(BIPUSH, 15)); toInject.add(new InsnNode(IAND)); toInject.add(new VarInsnNode(ISTORE, 16)); toInject.add(new VarInsnNode(ILOAD, 11)); toInject.add(new IntInsnNode(BIPUSH, 16)); toInject.add(new InsnNode(ISHR)); toInject.add(new IntInsnNode(BIPUSH, 15)); toInject.add(new InsnNode(IAND)); toInject.add(new VarInsnNode(ISTORE, 17)); toInject.add(new VarInsnNode(ALOAD, 13)); toInject.add(new VarInsnNode(ILOAD, 15)); toInject.add(new VarInsnNode(ILOAD, 17)); toInject.add(new VarInsnNode(ILOAD, 16)); toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "adr", "a", "(III)I")); toInject.add(new VarInsnNode(ISTORE, 18)); toInject.add(new VarInsnNode(ALOAD, 13)); toInject.add(new VarInsnNode(ILOAD, 15)); toInject.add(new VarInsnNode(ILOAD, 17)); toInject.add(new VarInsnNode(ILOAD, 16)); toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "adr", "b", "(III)I")); toInject.add(new VarInsnNode(ISTORE, 19)); toInject.add(new FieldInsnNode(GETSTATIC, "blockphysics/BlockPhysics", "blockSet", "[[Lblockphysics/BlockDef;")); toInject.add(new VarInsnNode(ILOAD, 18)); toInject.add(new InsnNode(AALOAD)); toInject.add(new VarInsnNode(ILOAD, 19)); toInject.add(new InsnNode(AALOAD)); toInject.add(new FieldInsnNode(GETFIELD, "blockphysics/BlockDef", "randomtick", "Z")); LabelNode l7 = new LabelNode(); toInject.add(new JumpInsnNode(IFEQ, l7)); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new VarInsnNode(ILOAD, 15)); toInject.add(new VarInsnNode(ILOAD, 6)); toInject.add(new InsnNode(IADD)); toInject.add(new VarInsnNode(ILOAD, 17)); toInject.add(new VarInsnNode(ALOAD, 13)); toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "adr", "d", "()I")); toInject.add(new InsnNode(IADD)); toInject.add(new VarInsnNode(ILOAD, 16)); toInject.add(new VarInsnNode(ILOAD, 7)); toInject.add(new InsnNode(IADD)); toInject.add(new VarInsnNode(ILOAD, 18)); toInject.add(new VarInsnNode(ILOAD, 19)); toInject.add(new InsnNode(ICONST_0)); toInject.add(new MethodInsnNode(INVOKESTATIC, "blockphysics/BlockPhysics", "tryToMove", "(Labv;IIIIIZ)Z")); toInject.add(new InsnNode(POP)); toInject.add(l7); toInject.add(new FrameNode(Opcodes.F_FULL, 14, new Object[] { "jr", "gnu/trove/iterator/TLongShortIterator", Opcodes.LONG, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, "adq", Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, "[Ladr;", "adr", Opcodes.INTEGER }, 0, new Object[] {})); toInject.add(new IincInsnNode(14, 1)); toInject.add(new JumpInsnNode(GOTO, l6)); toInject.add(l5); toInject.add(new FrameNode(Opcodes.F_FULL, 12, new Object[] { "jr", "gnu/trove/iterator/TLongShortIterator", Opcodes.LONG, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER, "adq", Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.TOP, "[Ladr;" }, 0, new Object[] {})); toInject.add(new IincInsnNode(10, 1)); toInject.add(new JumpInsnNode(GOTO, l3)); toInject.add(l4); toInject.add(new FrameNode(Opcodes.F_FULL, 2, new Object[] { "jr", "gnu/trove/iterator/TLongShortIterator" }, 0, new Object[] {})); toInject.add(new JumpInsnNode(GOTO, l1)); toInject.add(l2); toInject.add(new FrameNode(Opcodes.F_CHOP, 1, null, 0, null)); toInject.add(new InsnNode(RETURN)); m.instructions.add(toInject); ok = true; break; } } ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(cw); if (ok) System.out.println("OK"); else System.out.println("Failed." + ok); /*try { FileOutputStream fos = new FileOutputStream("d:/BlockPhysics.class"); fos.write(cw.toByteArray()); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ return cw.toByteArray(); }
From source file:br.usp.each.saeg.badua.core.internal.instr.CoverageMethodTransformer.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public void transform(final MethodNode methodNode) { final DefUseAnalyzer analyzer = new DefUseAnalyzer(); try {/*from ww w . j a v a 2s.c om*/ analyzer.analyze(className, methodNode); } catch (final AnalyzerException e) { throw new RuntimeException(e); } final DefUseFrame[] frames = analyzer.getDefUseFrames(); final Variable[] variables = analyzer.getVariables(); final int[][] successors = analyzer.getSuccessors(); final int[][] predecessors = analyzer.getPredecessors(); final int[][] basicBlocks = analyzer.getBasicBlocks(); final int[] leaders = analyzer.getLeaders(); final DefUseChain[] chains = DefUseChain.toBasicBlock( new DepthFirstDefUseChainSearch().search(frames, variables, successors, predecessors), leaders, basicBlocks); this.chains = chains; if (chains.length == 0) return; // basic block definitions final Set<Variable>[] defs = (Set<Variable>[]) new Set<?>[basicBlocks.length]; for (int b = 0; b < basicBlocks.length; b++) { defs[b] = new HashSet<Variable>(); for (final int insnIndex : basicBlocks[b]) { defs[b].addAll(frames[insnIndex].getDefinitions()); } } // bit-sets final BitSet[] potcov = new BitSet[basicBlocks.length]; final BitSet[] potcovpuse = new BitSet[basicBlocks.length]; final BitSet[] born = new BitSet[basicBlocks.length]; final BitSet[] disabled = new BitSet[basicBlocks.length]; final BitSet[] sleepy = new BitSet[basicBlocks.length]; for (int b = 0; b < basicBlocks.length; b++) { potcov[b] = new BitSet(chains.length); potcovpuse[b] = new BitSet(chains.length); born[b] = new BitSet(chains.length); disabled[b] = new BitSet(chains.length); sleepy[b] = new BitSet(chains.length); for (int i = 0; i < chains.length; i++) { final DefUseChain chain = chains[i]; if (chain.target != -1 ? chain.target == b : chain.use == b) { potcov[b].set(i); if (chain.target != -1) { potcovpuse[b].set(i); } } if (chain.def == b) { born[b].set(i); } if (chain.def != b && defs[b].contains(variables[chain.var])) { disabled[b].set(i); } if (chain.target != -1) { if (chain.use != b) { sleepy[b].set(i); } } } } // first/last valid instructions final AbstractInsnNode[] first = new AbstractInsnNode[basicBlocks.length]; final AbstractInsnNode[] last = new AbstractInsnNode[basicBlocks.length]; for (int b = 0; b < basicBlocks.length; b++) { for (final int insnIndex : basicBlocks[b]) { final AbstractInsnNode insn = methodNode.instructions.get(insnIndex); // skip switch (insn.getType()) { case AbstractInsnNode.LABEL: case AbstractInsnNode.FRAME: case AbstractInsnNode.LINE: continue; } if (first[b] == null) { first[b] = insn; } last[b] = insn; } } AbstractInsnNode insn = methodNode.instructions.getFirst(); final int windows = (chains.length + 63) / 64; final int[] indexes = new int[windows]; for (int w = 0; w < windows; w++) { indexes[w] = idGen.nextId(); LabelFrameNode.insertBefore(insn, methodNode.instructions, init(methodNode, w)); } for (int b = 0; b < basicBlocks.length; b++) { final long[] lPotcov = BitSetUtils.toLongArray(potcov[b], windows); final long[] lPotcovpuse = BitSetUtils.toLongArray(potcovpuse[b], windows); final long[] lBorn = BitSetUtils.toLongArray(born[b], windows); final long[] lDisabled = BitSetUtils.toLongArray(disabled[b], windows); final long[] lSleepy = BitSetUtils.toLongArray(sleepy[b], windows); for (int w = 0; w < windows; w++) { final int nPredecessors = predecessors[basicBlocks[b][0]].length; final Probe p = probe(methodNode, w, nPredecessors == 0); p.potcov = lPotcov[w]; p.potcovpuse = lPotcovpuse[w]; p.born = lBorn[w]; p.disabled = lDisabled[w]; p.sleepy = lSleepy[w]; p.singlePredecessor = nPredecessors == 1; LabelFrameNode.insertBefore(first[b], methodNode.instructions, p); } if (isReturn(last[b].getOpcode())) { for (int w = 0; w < windows; w++) { final Probe p = update(methodNode, w, indexes[w]); LabelFrameNode.insertBefore(last[b], methodNode.instructions, p); } } } // Finally, update the frames while (insn != null) { if (insn instanceof FrameNode) { final FrameNode frame = (FrameNode) insn; frame.local = new ArrayList<Object>(frame.local); int size = 0; for (final Object obj : frame.local) { size++; if (obj.equals(Opcodes.DOUBLE) || obj.equals(Opcodes.LONG)) { size++; } } while (size < methodNode.maxLocals) { frame.local.add(Opcodes.TOP); size++; } final Integer type = typeOfVars(); for (int i = 0; i < windows; i++) { frame.local.add(type); frame.local.add(type); frame.local.add(type); } } insn = insn.getNext(); } methodNode.maxLocals = methodNode.maxLocals + windows * numOfVars(); methodNode.maxStack = methodNode.maxStack + 6; }
From source file:br.usp.each.saeg.badua.core.internal.instr.CoverageMethodTransformer.java
License:Open Source License
private Integer typeOfVars() { if (chains.length <= 32) { // three integers return Opcodes.INTEGER; } else {//from w w w. j a v a2 s.c om // three longs return Opcodes.LONG; } }
From source file:ch.eiafr.cojac.instrumenters.FloatProxyMethod.java
License:Apache License
private Object[] addReturnTypeTo(Object[] stackContent, Type returnType) { int sort = returnType.getSort(); if (sort == Type.VOID) return stackContent; if (sort == Type.ARRAY || sort == Type.OBJECT) return addTo(stackContent, returnType.getInternalName()); // else primitive type switch (sort) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: return addTo(stackContent, Opcodes.INTEGER); case Type.LONG: return addTo(stackContent, Opcodes.LONG); //return addTo(addTo(stackContent, Opcodes.LONG), Opcodes.TOP); }// ww w.j a v a 2s.c o m return stackContent; }
From source file:com.google.code.jconts.instrument.util.Frames.java
License:Apache License
public static Object toFrameType(Type type) { switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: return Opcodes.INTEGER; case Type.FLOAT: return Opcodes.FLOAT; case Type.LONG: return Opcodes.LONG; case Type.DOUBLE: return Opcodes.DOUBLE; case Type.ARRAY: return type.getDescriptor(); // case Type.OBJECT: default:/*from w ww.j a v a 2s .c o m*/ return type.getInternalName(); } }
From source file:com.google.code.jconts.instrument.util.Frames.java
License:Apache License
public static Type fromFrameType(final Object type) { if (type instanceof String) { return Type.getObjectType((String) type); } else if (type == Opcodes.INTEGER) { return Type.INT_TYPE; } else if (type == Opcodes.FLOAT) { return Type.FLOAT_TYPE; } else if (type == Opcodes.LONG) { return Type.LONG_TYPE; } else if (type == Opcodes.DOUBLE) { return Type.DOUBLE_TYPE; }// w w w. j a v a 2 s .c om throw new IllegalArgumentException("Unexpected local type: " + type); }
From source file:com.google.devtools.build.android.desugar.BytecodeTypeInference.java
License:Open Source License
/** Convert the type in stack map frame to inference type. */ private InferredType convertTypeInStackMapFrame(Object typeInStackMapFrame) { if (typeInStackMapFrame == Opcodes.TOP) { return InferredType.TOP; } else if (typeInStackMapFrame == Opcodes.INTEGER) { return InferredType.INT; } else if (typeInStackMapFrame == Opcodes.FLOAT) { return InferredType.FLOAT; } else if (typeInStackMapFrame == Opcodes.DOUBLE) { return InferredType.DOUBLE; } else if (typeInStackMapFrame == Opcodes.LONG) { return InferredType.LONG; } else if (typeInStackMapFrame == Opcodes.NULL) { return InferredType.NULL; } else if (typeInStackMapFrame == Opcodes.UNINITIALIZED_THIS) { return InferredType.UNINITIALIZED_THIS; } else if (typeInStackMapFrame instanceof String) { String referenceTypeName = (String) typeInStackMapFrame; if (referenceTypeName.charAt(0) == '[') { return InferredType.createNonUninitializedType(referenceTypeName); } else {/*from w ww . j a v a 2 s .c o m*/ return InferredType.createNonUninitializedType('L' + referenceTypeName + ';'); } } else if (typeInStackMapFrame instanceof Label) { Label label = (Label) typeInStackMapFrame; return InferredType.createUninitializedType(label); } else { throw new RuntimeException("Cannot reach here. Unhandled element: value=" + typeInStackMapFrame + ", class=" + typeInStackMapFrame.getClass() + ". The current method being desugared is " + methodSignature); } }
From source file:com.ibm.layout.GenArray1D.java
License:Open Source License
/** * Generate bytecodes for runtime class/*from ww w .jav a 2 s . co m*/ * * @return byte array containing bytecodes for runtime class * @throws Exception */ public byte[] genBytecode() throws Exception { ClassWriter cw = new ClassWriter(0); MethodVisitor mv; FieldVisitor fv; final boolean itf = false; /* If user-defined array class is supplied, use it as superclass, and use its name instead of generating it */ cw.visit(V1_8, ACC_FINAL + ACC_SUPER, arrayImplClassName, arrayInterfaceClassSig, "java/lang/Object", new String[] { arrayInterfaceClassName }); { fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, "elementSize", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "arraySize", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, "length", "J", null, null); fv.visitEnd(); } { mv = cw.visitMethod(ACC_PROTECTED, "<init>", "(JJ)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "length", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 3); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "elementSize", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(LLOAD, 3); mv.visitInsn(LMUL); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "arraySize", "J"); mv.visitInsn(RETURN); mv.visitMaxs(5, 5); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "sizeof", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "arraySize", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, "java/lang/StringBuffer"); mv.visitInsn(DUP); mv.visitLdcInsn("["); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ASTORE, 1); mv.visitInsn(LCONST_0); mv.visitVarInsn(LSTORE, 2); Label l0 = new Label(); mv.visitJumpInsn(GOTO, l0); Label l1 = new Label(); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_APPEND, 2, new Object[] { "java/lang/StringBuffer", Opcodes.LONG }, 0, null); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitLdcInsn(" "); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(J)L" + elementInterfaceClassName + ";", false); mv.visitMethodInsn(INVOKEINTERFACE, elementInterfaceClassName, "toString", "()Ljava/lang/String;", true); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitVarInsn(LLOAD, 2); mv.visitInsn(LCONST_1); mv.visitInsn(LADD); mv.visitVarInsn(LSTORE, 2); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(LLOAD, 2); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "length", "J"); mv.visitInsn(LCMP); mv.visitJumpInsn(IFLT, l1); mv.visitVarInsn(ALOAD, 1); mv.visitLdcInsn(" ]"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "toString", "()Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitMaxs(5, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getComponentType", "()Ljava/lang/Class;", "()Ljava/lang/Class<*>;", null); mv.visitCode(); mv.visitLdcInsn(Type.getType("L" + elementInterfaceClassName + ";")); mv.visitInsn(ARETURN); mv.visitMaxs(1, 0); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "getLength", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "length", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "at", "(J)L" + elementInterfaceClassName + ";", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, elementImplClassName); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, elementImplClassName, "<init>", "()V", itf); mv.visitVarInsn(ASTORE, 3); mv.visitTypeInsn(NEW, "com/ibm/layout/Location"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, this.arrayImplClassName, "location", "Lcom/ibm/layout/Location;"); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "sizeof", "()J", itf); mv.visitInsn(LMUL); mv.visitMethodInsn(INVOKESPECIAL, "com/ibm/layout/Location", "<init>", "(Lcom/ibm/layout/Location;J)V", itf); mv.visitVarInsn(ASTORE, 4); mv.visitVarInsn(ALOAD, 3); mv.visitVarInsn(ALOAD, 4); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "bindLocation", "(Lcom/ibm/layout/Location;)V", itf); mv.visitVarInsn(ALOAD, 3); mv.visitInsn(ARETURN); mv.visitMaxs(7, 5); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "range", "(JJ)Lcom/ibm/layout/Array1D;", "(JJ)Lcom/ibm/layout/Array1D<" + elementInterfaceClassName + ";>;", null); mv.visitCode(); mv.visitTypeInsn(NEW, arrayImplClassName); mv.visitInsn(DUP); mv.visitVarInsn(LLOAD, 3); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, this.arrayImplClassName, "elementSize", "J"); mv.visitMethodInsn(INVOKESPECIAL, this.arrayImplClassName, "<init>", "(JJ)V", itf); mv.visitVarInsn(ASTORE, 5); mv.visitTypeInsn(NEW, "com/ibm/layout/Location"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "location", "Lcom/ibm/layout/Location;"); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "elementSize", "J"); mv.visitInsn(LMUL); mv.visitMethodInsn(INVOKESPECIAL, "com/ibm/layout/Location", "<init>", "(Lcom/ibm/layout/Location;J)V", itf); mv.visitVarInsn(ASTORE, 6); mv.visitVarInsn(ALOAD, 5); mv.visitVarInsn(ALOAD, 6); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "bindLocation", "(Lcom/ibm/layout/Location;)V", itf); mv.visitVarInsn(ALOAD, 5); mv.visitInsn(ARETURN); mv.visitMaxs(7, 7); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "put", "(JL" + elementInterfaceClassName + ";)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(J)L" + elementInterfaceClassName + ";", itf); mv.visitTypeInsn(CHECKCAST, elementImplClassName); mv.visitVarInsn(ALOAD, 3); mv.visitTypeInsn(CHECKCAST, elementImplClassName); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "copyFrom", "(L" + elementImplClassName + ";)V", itf); mv.visitInsn(RETURN); mv.visitMaxs(3, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "at", "(J)Lcom/ibm/layout/Layout;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(J)L" + elementInterfaceClassName + ";", itf); mv.visitInsn(ARETURN); mv.visitMaxs(3, 3); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "put", "(JLcom/ibm/layout/Layout;)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 3); mv.visitTypeInsn(CHECKCAST, elementInterfaceClassName); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "put", "(JL" + elementInterfaceClassName + ";)V", itf); mv.visitInsn(RETURN); mv.visitMaxs(4, 4); mv.visitEnd(); } ImplHelper.genLayoutTypeImpl(cw, mv, fv, arrayImplClassName, false); cw.visitEnd(); return cw.toByteArray(); }
From source file:com.ibm.layout.GenArray2D.java
License:Open Source License
/** * Generate bytecodes for runtime class/*from w w w . jav a 2s . c om*/ * * @return byte array containing bytecodes for runtime class * @throws Exception */ public byte[] genBytecode() throws Exception { ClassWriter cw = new ClassWriter(0); MethodVisitor mv = null; FieldVisitor fv = null; final boolean itf = false; cw.visit(V1_8, ACC_FINAL + ACC_SUPER, arrayImplClassName, arrayInterfaceClassSig, "java/lang/Object", new String[] { arrayInterfaceClassName }); { fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, "dim1", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, "dim2", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "elementSize", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "arraySize", "J", null, null); fv.visitEnd(); } { mv = cw.visitMethod(ACC_PROTECTED, "<init>", "(JJJ)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "dim1", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 3); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "dim2", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 5); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "elementSize", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 5); mv.visitVarInsn(LLOAD, 1); mv.visitInsn(LMUL); mv.visitVarInsn(LLOAD, 3); mv.visitInsn(LMUL); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "arraySize", "J"); mv.visitInsn(RETURN); mv.visitMaxs(5, 7); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "at", "(JJ)L" + elementInterfaceClassName + ";", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, elementImplClassName); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, elementImplClassName, "<init>", "()V", itf); mv.visitVarInsn(ASTORE, 5); mv.visitTypeInsn(NEW, "com/ibm/layout/Location"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "location", "Lcom/ibm/layout/Location;"); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "dim2", "J"); mv.visitInsn(LMUL); mv.visitVarInsn(LLOAD, 3); mv.visitInsn(LADD); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "sizeof", "()J", itf); mv.visitInsn(LMUL); mv.visitMethodInsn(INVOKESPECIAL, "com/ibm/layout/Location", "<init>", "(Lcom/ibm/layout/Location;J)V", itf); mv.visitVarInsn(ASTORE, 6); mv.visitVarInsn(ALOAD, 5); mv.visitVarInsn(ALOAD, 6); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "bindLocation", "(Lcom/ibm/layout/Location;)V", itf); mv.visitVarInsn(ALOAD, 5); mv.visitInsn(ARETURN); mv.visitMaxs(7, 7); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "put", "(JJL" + elementInterfaceClassName + ";)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(LLOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(JJ)L" + elementInterfaceClassName + ";", itf); mv.visitTypeInsn(CHECKCAST, elementImplClassName); mv.visitVarInsn(ALOAD, 5); mv.visitTypeInsn(CHECKCAST, elementImplClassName); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "copyFrom", "(L" + elementImplClassName + ";)V", itf); mv.visitInsn(RETURN); mv.visitMaxs(5, 6); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "at", "(JJ)Lcom/ibm/layout/Layout;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(LLOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(JJ)L" + elementInterfaceClassName + ";", itf); mv.visitInsn(ARETURN); mv.visitMaxs(5, 5); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "put", "(JJLcom/ibm/layout/Layout;)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(LLOAD, 3); mv.visitVarInsn(ALOAD, 5); mv.visitTypeInsn(CHECKCAST, elementInterfaceClassName); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "put", "(JJL" + elementInterfaceClassName + ";)V", itf); mv.visitInsn(RETURN); mv.visitMaxs(6, 6); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "dim1", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "dim1", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "dim2", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "dim2", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "sizeof", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "arraySize", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, "java/lang/StringBuffer"); mv.visitInsn(DUP); mv.visitLdcInsn("["); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ASTORE, 1); mv.visitInsn(LCONST_0); mv.visitVarInsn(LSTORE, 2); Label l0 = new Label(); mv.visitJumpInsn(GOTO, l0); Label l1 = new Label(); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_APPEND, 2, new Object[] { "java/lang/StringBuffer", Opcodes.LONG }, 0, null); mv.visitInsn(LCONST_0); mv.visitVarInsn(LSTORE, 4); Label l2 = new Label(); mv.visitJumpInsn(GOTO, l2); Label l3 = new Label(); mv.visitLabel(l3); mv.visitFrame(Opcodes.F_APPEND, 1, new Object[] { Opcodes.LONG }, 0, null); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitLdcInsn(" "); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 2); mv.visitVarInsn(LLOAD, 4); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(JJ)Lcom/ibm/layout/Layout;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitVarInsn(LLOAD, 4); mv.visitInsn(LCONST_1); mv.visitInsn(LADD); mv.visitVarInsn(LSTORE, 4); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(LLOAD, 4); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "dim2", "J"); mv.visitInsn(LCMP); mv.visitJumpInsn(IFLT, l3); mv.visitVarInsn(LLOAD, 2); mv.visitInsn(LCONST_1); mv.visitInsn(LADD); mv.visitVarInsn(LSTORE, 2); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_CHOP, 1, null, 0, null); mv.visitVarInsn(LLOAD, 2); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "dim1", "J"); mv.visitInsn(LCMP); mv.visitJumpInsn(IFLT, l1); mv.visitVarInsn(ALOAD, 1); mv.visitLdcInsn(" ]"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "toString", "()Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitMaxs(7, 6); mv.visitEnd(); } ImplHelper.genLayoutTypeImpl(cw, mv, fv, arrayImplClassName, false); cw.visitEnd(); return cw.toByteArray(); }
From source file:com.ibm.layout.GenVLArray.java
License:Open Source License
/** * Generate bytecodes for runtime class// w ww. j a va 2s . c o m * * @return byte array containing bytecodes for runtime class * @throws Exception */ public byte[] genBytecode() throws Exception { ClassWriter cw = new ClassWriter(0); MethodVisitor mv; FieldVisitor fv; final boolean itf = false; /* If user-defined array class is supplied, use it as superclass, and use its name instead of generating it */ cw.visit(V1_8, ACC_FINAL + ACC_SUPER, arrayImplClassName, arrayInterfaceClassSig, "java/lang/Object", new String[] { arrayInterfaceClassName }); { fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, "length", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, "elementSize", "J", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE, "arraySize", "J", null, null); fv.visitEnd(); } { mv = cw.visitMethod(ACC_PROTECTED, "<init>", "(JJ)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 3); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "elementSize", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "length", "J"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 3); mv.visitVarInsn(LLOAD, 1); mv.visitInsn(LMUL); mv.visitFieldInsn(PUTFIELD, arrayImplClassName, "arraySize", "J"); mv.visitInsn(RETURN); mv.visitMaxs(5, 5); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "sizeof", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "arraySize", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getComponentType", "()Ljava/lang/Class;", "()Ljava/lang/Class<*>;", null); mv.visitCode(); mv.visitLdcInsn(Type.getType("L" + elementInterfaceClassName + ";")); mv.visitInsn(ARETURN); mv.visitMaxs(1, 0); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "getVLALength", "()J", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "length", "J"); mv.visitInsn(LRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "at", "(J)L" + elementInterfaceClassName + ";", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, elementImplClassName); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, elementImplClassName, "<init>", "()V", false); mv.visitVarInsn(ASTORE, 3); mv.visitVarInsn(ALOAD, 3); mv.visitTypeInsn(NEW, "com/ibm/layout/Location"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "location", "Lcom/ibm/layout/Location;"); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "elementSize", "J"); mv.visitInsn(LMUL); mv.visitMethodInsn(INVOKESPECIAL, "com/ibm/layout/Location", "<init>", "(Lcom/ibm/layout/Location;J)V", false); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "bindLocation", "(Lcom/ibm/layout/Location;)V", false); mv.visitVarInsn(ALOAD, 3); mv.visitInsn(ARETURN); mv.visitMaxs(8, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "range", "(JJ)Lcom/ibm/layout/Array1D;", "(JJ)Lcom/ibm/layout/Array1D<" + elementInterfaceClassName + ";>;", null); mv.visitCode(); mv.visitTypeInsn(NEW, arrayImplClassName); mv.visitInsn(DUP); mv.visitVarInsn(LLOAD, 3); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, this.arrayImplClassName, "elementSize", "J"); mv.visitMethodInsn(INVOKESPECIAL, this.arrayImplClassName, "<init>", "(JJ)V", itf); mv.visitVarInsn(ASTORE, 5); mv.visitTypeInsn(NEW, "com/ibm/layout/Location"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "location", "Lcom/ibm/layout/Location;"); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "elementSize", "J"); mv.visitInsn(LMUL); mv.visitMethodInsn(INVOKESPECIAL, "com/ibm/layout/Location", "<init>", "(Lcom/ibm/layout/Location;J)V", itf); mv.visitVarInsn(ASTORE, 6); mv.visitVarInsn(ALOAD, 5); mv.visitVarInsn(ALOAD, 6); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "bindLocation", "(Lcom/ibm/layout/Location;)V", itf); mv.visitVarInsn(ALOAD, 5); mv.visitInsn(ARETURN); mv.visitMaxs(7, 7); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "put", "(JLcom/ibm/layout/Layout;)V", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, elementImplClassName); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, elementImplClassName, "<init>", "()V", false); mv.visitVarInsn(ASTORE, 4); mv.visitVarInsn(ALOAD, 4); mv.visitTypeInsn(NEW, "com/ibm/layout/Location"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "location", "Lcom/ibm/layout/Location;"); mv.visitVarInsn(LLOAD, 1); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "elementSize", "J"); mv.visitInsn(LMUL); mv.visitMethodInsn(INVOKESPECIAL, "com/ibm/layout/Location", "<init>", "(Lcom/ibm/layout/Location;J)V", false); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "bindLocation", "(Lcom/ibm/layout/Location;)V", false); mv.visitVarInsn(ALOAD, 4); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "copyFrom", "(Lcom/ibm/layout/Layout;)V", false); mv.visitInsn(RETURN); mv.visitMaxs(8, 5); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "put", "(JL" + elementInterfaceClassName + ";)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(J)L" + elementInterfaceClassName + ";", itf); mv.visitTypeInsn(CHECKCAST, elementImplClassName); mv.visitVarInsn(ALOAD, 3); mv.visitTypeInsn(CHECKCAST, elementImplClassName); mv.visitMethodInsn(INVOKEVIRTUAL, elementImplClassName, "copyFrom", "(L" + elementImplClassName + ";)V", itf); mv.visitInsn(RETURN); mv.visitMaxs(3, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "at", "(J)Lcom/ibm/layout/Layout;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(J)L" + elementInterfaceClassName + ";", itf); mv.visitInsn(ARETURN); mv.visitMaxs(3, 3); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, "java/lang/StringBuffer"); mv.visitInsn(DUP); mv.visitLdcInsn("["); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ASTORE, 1); mv.visitInsn(LCONST_0); mv.visitVarInsn(LSTORE, 2); Label l0 = new Label(); mv.visitJumpInsn(GOTO, l0); Label l1 = new Label(); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_APPEND, 2, new Object[] { "java/lang/StringBuffer", Opcodes.LONG }, 0, null); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitLdcInsn(" "); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(LLOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, arrayImplClassName, "at", "(J)L" + elementInterfaceClassName + ";", false); mv.visitMethodInsn(INVOKEINTERFACE, elementInterfaceClassName, "toString", "()Ljava/lang/String;", true); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitVarInsn(LLOAD, 2); mv.visitInsn(LCONST_1); mv.visitInsn(LADD); mv.visitVarInsn(LSTORE, 2); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(LLOAD, 2); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, arrayImplClassName, "length", "J"); mv.visitInsn(LCMP); mv.visitJumpInsn(IFLT, l1); mv.visitVarInsn(ALOAD, 1); mv.visitLdcInsn(" ]"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;", false); mv.visitInsn(POP); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "toString", "()Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitMaxs(5, 4); mv.visitEnd(); } ImplHelper.genLayoutTypeImpl(cw, mv, fv, arrayImplClassName, false); cw.visitEnd(); return cw.toByteArray(); }