http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnList.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnList.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnList.java new file mode 100644 index 0000000..0876b7b --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnList.java @@ -0,0 +1,600 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.ListIterator; +import java.util.NoSuchElementException; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A doubly linked list of {@link AbstractInsnNode} objects. <i>This + * implementation is not thread safe</i>. + */ +public class InsnList { + + /** + * The number of instructions in this list. + */ + private int size; + + /** + * The first instruction in this list. May be <tt>null</tt>. + */ + private AbstractInsnNode first; + + /** + * The last instruction in this list. May be <tt>null</tt>. + */ + private AbstractInsnNode last; + + /** + * A cache of the instructions of this list. This cache is used to improve + * the performance of the {@link #get} method. + */ + AbstractInsnNode[] cache; + + /** + * Returns the number of instructions in this list. + * + * @return the number of instructions in this list. + */ + public int size() { + return size; + } + + /** + * Returns the first instruction in this list. + * + * @return the first instruction in this list, or <tt>null</tt> if the list + * is empty. + */ + public AbstractInsnNode getFirst() { + return first; + } + + /** + * Returns the last instruction in this list. + * + * @return the last instruction in this list, or <tt>null</tt> if the list + * is empty. + */ + public AbstractInsnNode getLast() { + return last; + } + + /** + * Returns the instruction whose index is given. This method builds a cache + * of the instructions in this list to avoid scanning the whole list each + * time it is called. Once the cache is built, this method run in constant + * time. This cache is invalidated by all the methods that modify the list. + * + * @param index + * the index of the instruction that must be returned. + * @return the instruction whose index is given. + * @throws IndexOutOfBoundsException + * if (index < 0 || index >= size()). + */ + public AbstractInsnNode get(final int index) { + if (index < 0 || index >= size) { + throw new IndexOutOfBoundsException(); + } + if (cache == null) { + cache = toArray(); + } + return cache[index]; + } + + /** + * Returns <tt>true</tt> if the given instruction belongs to this list. This + * method always scans the instructions of this list until it finds the + * given instruction or reaches the end of the list. + * + * @param insn + * an instruction. + * @return <tt>true</tt> if the given instruction belongs to this list. + */ + public boolean contains(final AbstractInsnNode insn) { + AbstractInsnNode i = first; + while (i != null && i != insn) { + i = i.next; + } + return i != null; + } + + /** + * Returns the index of the given instruction in this list. This method + * builds a cache of the instruction indexes to avoid scanning the whole + * list each time it is called. Once the cache is built, this method run in + * constant time. The cache is invalidated by all the methods that modify + * the list. + * + * @param insn + * an instruction <i>of this list</i>. + * @return the index of the given instruction in this list. <i>The result of + * this method is undefined if the given instruction does not belong + * to this list</i>. Use {@link #contains contains} to test if an + * instruction belongs to an instruction list or not. + */ + public int indexOf(final AbstractInsnNode insn) { + if (cache == null) { + cache = toArray(); + } + return insn.index; + } + + /** + * Makes the given visitor visit all of the instructions in this list. + * + * @param mv + * the method visitor that must visit the instructions. + */ + public void accept(final MethodVisitor mv) { + AbstractInsnNode insn = first; + while (insn != null) { + insn.accept(mv); + insn = insn.next; + } + } + + /** + * Returns an iterator over the instructions in this list. + * + * @return an iterator over the instructions in this list. + */ + public ListIterator<AbstractInsnNode> iterator() { + return iterator(0); + } + + /** + * Returns an iterator over the instructions in this list. + * + * @return an iterator over the instructions in this list. + */ + @SuppressWarnings("unchecked") + public ListIterator<AbstractInsnNode> iterator(int index) { + return new InsnListIterator(index); + } + + /** + * Returns an array containing all of the instructions in this list. + * + * @return an array containing all of the instructions in this list. + */ + public AbstractInsnNode[] toArray() { + int i = 0; + AbstractInsnNode elem = first; + AbstractInsnNode[] insns = new AbstractInsnNode[size]; + while (elem != null) { + insns[i] = elem; + elem.index = i++; + elem = elem.next; + } + return insns; + } + + /** + * Replaces an instruction of this list with another instruction. + * + * @param location + * an instruction <i>of this list</i>. + * @param insn + * another instruction, <i>which must not belong to any + * {@link InsnList}</i>. + */ + public void set(final AbstractInsnNode location, final AbstractInsnNode insn) { + AbstractInsnNode next = location.next; + insn.next = next; + if (next != null) { + next.prev = insn; + } else { + last = insn; + } + AbstractInsnNode prev = location.prev; + insn.prev = prev; + if (prev != null) { + prev.next = insn; + } else { + first = insn; + } + if (cache != null) { + int index = location.index; + cache[index] = insn; + insn.index = index; + } else { + insn.index = 0; // insn now belongs to an InsnList + } + location.index = -1; // i no longer belongs to an InsnList + location.prev = null; + location.next = null; + } + + /** + * Adds the given instruction to the end of this list. + * + * @param insn + * an instruction, <i>which must not belong to any + * {@link InsnList}</i>. + */ + public void add(final AbstractInsnNode insn) { + ++size; + if (last == null) { + first = insn; + last = insn; + } else { + last.next = insn; + insn.prev = last; + } + last = insn; + cache = null; + insn.index = 0; // insn now belongs to an InsnList + } + + /** + * Adds the given instructions to the end of this list. + * + * @param insns + * an instruction list, which is cleared during the process. This + * list must be different from 'this'. + */ + public void add(final InsnList insns) { + if (insns.size == 0) { + return; + } + size += insns.size; + if (last == null) { + first = insns.first; + last = insns.last; + } else { + AbstractInsnNode elem = insns.first; + last.next = elem; + elem.prev = last; + last = insns.last; + } + cache = null; + insns.removeAll(false); + } + + /** + * Inserts the given instruction at the begining of this list. + * + * @param insn + * an instruction, <i>which must not belong to any + * {@link InsnList}</i>. + */ + public void insert(final AbstractInsnNode insn) { + ++size; + if (first == null) { + first = insn; + last = insn; + } else { + first.prev = insn; + insn.next = first; + } + first = insn; + cache = null; + insn.index = 0; // insn now belongs to an InsnList + } + + /** + * Inserts the given instructions at the begining of this list. + * + * @param insns + * an instruction list, which is cleared during the process. This + * list must be different from 'this'. + */ + public void insert(final InsnList insns) { + if (insns.size == 0) { + return; + } + size += insns.size; + if (first == null) { + first = insns.first; + last = insns.last; + } else { + AbstractInsnNode elem = insns.last; + first.prev = elem; + elem.next = first; + first = insns.first; + } + cache = null; + insns.removeAll(false); + } + + /** + * Inserts the given instruction after the specified instruction. + * + * @param location + * an instruction <i>of this list</i> after which insn must be + * inserted. + * @param insn + * the instruction to be inserted, <i>which must not belong to + * any {@link InsnList}</i>. + */ + public void insert(final AbstractInsnNode location, + final AbstractInsnNode insn) { + ++size; + AbstractInsnNode next = location.next; + if (next == null) { + last = insn; + } else { + next.prev = insn; + } + location.next = insn; + insn.next = next; + insn.prev = location; + cache = null; + insn.index = 0; // insn now belongs to an InsnList + } + + /** + * Inserts the given instructions after the specified instruction. + * + * @param location + * an instruction <i>of this list</i> after which the + * instructions must be inserted. + * @param insns + * the instruction list to be inserted, which is cleared during + * the process. This list must be different from 'this'. + */ + public void insert(final AbstractInsnNode location, final InsnList insns) { + if (insns.size == 0) { + return; + } + size += insns.size; + AbstractInsnNode ifirst = insns.first; + AbstractInsnNode ilast = insns.last; + AbstractInsnNode next = location.next; + if (next == null) { + last = ilast; + } else { + next.prev = ilast; + } + location.next = ifirst; + ilast.next = next; + ifirst.prev = location; + cache = null; + insns.removeAll(false); + } + + /** + * Inserts the given instruction before the specified instruction. + * + * @param location + * an instruction <i>of this list</i> before which insn must be + * inserted. + * @param insn + * the instruction to be inserted, <i>which must not belong to + * any {@link InsnList}</i>. + */ + public void insertBefore(final AbstractInsnNode location, + final AbstractInsnNode insn) { + ++size; + AbstractInsnNode prev = location.prev; + if (prev == null) { + first = insn; + } else { + prev.next = insn; + } + location.prev = insn; + insn.next = location; + insn.prev = prev; + cache = null; + insn.index = 0; // insn now belongs to an InsnList + } + + /** + * Inserts the given instructions before the specified instruction. + * + * @param location + * an instruction <i>of this list</i> before which the + * instructions must be inserted. + * @param insns + * the instruction list to be inserted, which is cleared during + * the process. This list must be different from 'this'. + */ + public void insertBefore(final AbstractInsnNode location, + final InsnList insns) { + if (insns.size == 0) { + return; + } + size += insns.size; + AbstractInsnNode ifirst = insns.first; + AbstractInsnNode ilast = insns.last; + AbstractInsnNode prev = location.prev; + if (prev == null) { + first = ifirst; + } else { + prev.next = ifirst; + } + location.prev = ilast; + ilast.next = location; + ifirst.prev = prev; + cache = null; + insns.removeAll(false); + } + + /** + * Removes the given instruction from this list. + * + * @param insn + * the instruction <i>of this list</i> that must be removed. + */ + public void remove(final AbstractInsnNode insn) { + --size; + AbstractInsnNode next = insn.next; + AbstractInsnNode prev = insn.prev; + if (next == null) { + if (prev == null) { + first = null; + last = null; + } else { + prev.next = null; + last = prev; + } + } else { + if (prev == null) { + first = next; + next.prev = null; + } else { + prev.next = next; + next.prev = prev; + } + } + cache = null; + insn.index = -1; // insn no longer belongs to an InsnList + insn.prev = null; + insn.next = null; + } + + /** + * Removes all of the instructions of this list. + * + * @param mark + * if the instructions must be marked as no longer belonging to + * any {@link InsnList}. + */ + void removeAll(final boolean mark) { + if (mark) { + AbstractInsnNode insn = first; + while (insn != null) { + AbstractInsnNode next = insn.next; + insn.index = -1; // insn no longer belongs to an InsnList + insn.prev = null; + insn.next = null; + insn = next; + } + } + size = 0; + first = null; + last = null; + cache = null; + } + + /** + * Removes all of the instructions of this list. + */ + public void clear() { + removeAll(false); + } + + /** + * Reset all labels in the instruction list. This method should be called + * before reusing same instructions list between several + * <code>ClassWriter</code>s. + */ + public void resetLabels() { + AbstractInsnNode insn = first; + while (insn != null) { + if (insn instanceof LabelNode) { + ((LabelNode) insn).resetLabel(); + } + insn = insn.next; + } + } + + // this class is not generified because it will create bridges + private final class InsnListIterator implements ListIterator { + + AbstractInsnNode next; + + AbstractInsnNode prev; + + InsnListIterator(int index) { + if (index == size()) { + next = null; + prev = getLast(); + } else { + next = get(index); + prev = next.prev; + } + } + + public boolean hasNext() { + return next != null; + } + + public Object next() { + if (next == null) { + throw new NoSuchElementException(); + } + AbstractInsnNode result = next; + prev = result; + next = result.next; + return result; + } + + public void remove() { + InsnList.this.remove(prev); + prev = prev.prev; + } + + public boolean hasPrevious() { + return prev != null; + } + + public Object previous() { + AbstractInsnNode result = prev; + next = result; + prev = result.prev; + return result; + } + + public int nextIndex() { + if (next == null) { + return size(); + } + if (cache == null) { + cache = toArray(); + } + return next.index; + } + + public int previousIndex() { + if (prev == null) { + return -1; + } + if (cache == null) { + cache = toArray(); + } + return prev.index; + } + + public void add(Object o) { + InsnList.this.insertBefore(next, (AbstractInsnNode) o); + prev = (AbstractInsnNode) o; + } + + public void set(Object o) { + InsnList.this.set(next.prev, (AbstractInsnNode) o); + prev = (AbstractInsnNode) o; + } + } +}
http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnNode.java new file mode 100644 index 0000000..61db3ab --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InsnNode.java @@ -0,0 +1,87 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A node that represents a zero operand instruction. + * + * @author Eric Bruneton + */ +public class InsnNode extends AbstractInsnNode { + + /** + * Constructs a new {@link InsnNode}. + * + * @param opcode + * the opcode of the instruction to be constructed. This opcode + * must be NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, + * ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, + * FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD, + * LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, + * IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, + * SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, + * DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, + * IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, + * FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, + * IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D, + * L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, + * LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN, + * DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, + * or MONITOREXIT. + */ + public InsnNode(final int opcode) { + super(opcode); + } + + @Override + public int getType() { + return INSN; + } + + /** + * Makes the given visitor visit this instruction. + * + * @param mv + * a method visitor. + */ + @Override + public void accept(final MethodVisitor mv) { + mv.visitInsn(opcode); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new InsnNode(opcode); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/IntInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/IntInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/IntInsnNode.java new file mode 100644 index 0000000..ade9a7b --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/IntInsnNode.java @@ -0,0 +1,87 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A node that represents an instruction with a single int operand. + * + * @author Eric Bruneton + */ +public class IntInsnNode extends AbstractInsnNode { + + /** + * The operand of this instruction. + */ + public int operand; + + /** + * Constructs a new {@link IntInsnNode}. + * + * @param opcode + * the opcode of the instruction to be constructed. This opcode + * must be BIPUSH, SIPUSH or NEWARRAY. + * @param operand + * the operand of the instruction to be constructed. + */ + public IntInsnNode(final int opcode, final int operand) { + super(opcode); + this.operand = operand; + } + + /** + * Sets the opcode of this instruction. + * + * @param opcode + * the new instruction opcode. This opcode must be BIPUSH, SIPUSH + * or NEWARRAY. + */ + public void setOpcode(final int opcode) { + this.opcode = opcode; + } + + @Override + public int getType() { + return INT_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitIntInsn(opcode, operand); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new IntInsnNode(opcode, operand); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InvokeDynamicInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InvokeDynamicInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InvokeDynamicInsnNode.java new file mode 100644 index 0000000..868062f --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/InvokeDynamicInsnNode.java @@ -0,0 +1,100 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Handle; +import org.apache.tajo.org.objectweb.asm.Opcodes; + +/** + * A node that represents an invokedynamic instruction. + * + * @author Remi Forax + */ +public class InvokeDynamicInsnNode extends AbstractInsnNode { + + /** + * Invokedynamic name. + */ + public String name; + + /** + * Invokedynamic descriptor. + */ + public String desc; + + /** + * Bootstrap method + */ + public Handle bsm; + + /** + * Bootstrap constant arguments + */ + public Object[] bsmArgs; + + /** + * Constructs a new {@link InvokeDynamicInsnNode}. + * + * @param name + * invokedynamic name. + * @param desc + * invokedynamic descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + * @param bsm + * the bootstrap method. + * @param bsmArgs + * the boostrap constant arguments. + */ + public InvokeDynamicInsnNode(final String name, final String desc, + final Handle bsm, final Object... bsmArgs) { + super(Opcodes.INVOKEDYNAMIC); + this.name = name; + this.desc = desc; + this.bsm = bsm; + this.bsmArgs = bsmArgs; + } + + @Override + public int getType() { + return INVOKE_DYNAMIC_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/JumpInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/JumpInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/JumpInsnNode.java new file mode 100644 index 0000000..7979fed --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/JumpInsnNode.java @@ -0,0 +1,95 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A node that represents a jump instruction. A jump instruction is an + * instruction that may jump to another instruction. + * + * @author Eric Bruneton + */ +public class JumpInsnNode extends AbstractInsnNode { + + /** + * The operand of this instruction. This operand is a label that designates + * the instruction to which this instruction may jump. + */ + public LabelNode label; + + /** + * Constructs a new {@link JumpInsnNode}. + * + * @param opcode + * the opcode of the type instruction to be constructed. This + * opcode must be IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, + * IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, + * IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL. + * @param label + * the operand of the instruction to be constructed. This operand + * is a label that designates the instruction to which the jump + * instruction may jump. + */ + public JumpInsnNode(final int opcode, final LabelNode label) { + super(opcode); + this.label = label; + } + + /** + * Sets the opcode of this instruction. + * + * @param opcode + * the new instruction opcode. This opcode must be IFEQ, IFNE, + * IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, + * IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, + * JSR, IFNULL or IFNONNULL. + */ + public void setOpcode(final int opcode) { + this.opcode = opcode; + } + + @Override + public int getType() { + return JUMP_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitJumpInsn(opcode, label.getLabel()); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new JumpInsnNode(opcode, clone(label, labels)); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LabelNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LabelNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LabelNode.java new file mode 100644 index 0000000..a778da0 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LabelNode.java @@ -0,0 +1,78 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.Label; +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * An {@link AbstractInsnNode} that encapsulates a {@link org.apache.tajo.org.objectweb.asm.Label}. + */ +public class LabelNode extends AbstractInsnNode { + + private Label label; + + public LabelNode() { + super(-1); + } + + public LabelNode(final Label label) { + super(-1); + this.label = label; + } + + @Override + public int getType() { + return LABEL; + } + + public Label getLabel() { + if (label == null) { + label = new Label(); + } + return label; + } + + @Override + public void accept(final MethodVisitor cv) { + cv.visitLabel(getLabel()); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return labels.get(this); + } + + public void resetLabel() { + label = null; + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LdcInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LdcInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LdcInsnNode.java new file mode 100644 index 0000000..cadf694 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LdcInsnNode.java @@ -0,0 +1,78 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; + +/** + * A node that represents an LDC instruction. + * + * @author Eric Bruneton + */ +public class LdcInsnNode extends AbstractInsnNode { + + /** + * The constant to be loaded on the stack. This parameter must be a non null + * {@link Integer}, a {@link Float}, a {@link Long}, a {@link Double}, a + * {@link String} or a {@link org.apache.tajo.org.objectweb.asm.Type}. + */ + public Object cst; + + /** + * Constructs a new {@link LdcInsnNode}. + * + * @param cst + * the constant to be loaded on the stack. This parameter must be + * a non null {@link Integer}, a {@link Float}, a {@link Long}, a + * {@link Double} or a {@link String}. + */ + public LdcInsnNode(final Object cst) { + super(Opcodes.LDC); + this.cst = cst; + } + + @Override + public int getType() { + return LDC_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitLdcInsn(cst); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new LdcInsnNode(cst); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LineNumberNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LineNumberNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LineNumberNode.java new file mode 100644 index 0000000..51f07a6 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LineNumberNode.java @@ -0,0 +1,84 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A node that represents a line number declaration. These nodes are pseudo + * instruction nodes in order to be inserted in an instruction list. + * + * @author Eric Bruneton + */ +public class LineNumberNode extends AbstractInsnNode { + + /** + * A line number. This number refers to the source file from which the class + * was compiled. + */ + public int line; + + /** + * The first instruction corresponding to this line number. + */ + public LabelNode start; + + /** + * Constructs a new {@link LineNumberNode}. + * + * @param line + * a line number. This number refers to the source file from + * which the class was compiled. + * @param start + * the first instruction corresponding to this line number. + */ + public LineNumberNode(final int line, final LabelNode start) { + super(-1); + this.line = line; + this.start = start; + } + + @Override + public int getType() { + return LINE; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitLineNumber(line, start.getLabel()); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new LineNumberNode(line, clone(start, labels)); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LocalVariableNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LocalVariableNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LocalVariableNode.java new file mode 100644 index 0000000..35dff24 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LocalVariableNode.java @@ -0,0 +1,112 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A node that represents a local variable declaration. + * + * @author Eric Bruneton + */ +public class LocalVariableNode { + + /** + * The name of a local variable. + */ + public String name; + + /** + * The type descriptor of this local variable. + */ + public String desc; + + /** + * The signature of this local variable. May be <tt>null</tt>. + */ + public String signature; + + /** + * The first instruction corresponding to the scope of this local variable + * (inclusive). + */ + public LabelNode start; + + /** + * The last instruction corresponding to the scope of this local variable + * (exclusive). + */ + public LabelNode end; + + /** + * The local variable's index. + */ + public int index; + + /** + * Constructs a new {@link LocalVariableNode}. + * + * @param name + * the name of a local variable. + * @param desc + * the type descriptor of this local variable. + * @param signature + * the signature of this local variable. May be <tt>null</tt>. + * @param start + * the first instruction corresponding to the scope of this local + * variable (inclusive). + * @param end + * the last instruction corresponding to the scope of this local + * variable (exclusive). + * @param index + * the local variable's index. + */ + public LocalVariableNode(final String name, final String desc, + final String signature, final LabelNode start, final LabelNode end, + final int index) { + this.name = name; + this.desc = desc; + this.signature = signature; + this.start = start; + this.end = end; + this.index = index; + } + + /** + * Makes the given visitor visit this local variable declaration. + * + * @param mv + * a method visitor. + */ + public void accept(final MethodVisitor mv) { + mv.visitLocalVariable(name, desc, signature, start.getLabel(), + end.getLabel(), index); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LookupSwitchInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LookupSwitchInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LookupSwitchInsnNode.java new file mode 100644 index 0000000..0563e31 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/LookupSwitchInsnNode.java @@ -0,0 +1,117 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.Label; +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; + +/** + * A node that represents a LOOKUPSWITCH instruction. + * + * @author Eric Bruneton + */ +public class LookupSwitchInsnNode extends AbstractInsnNode { + + /** + * Beginning of the default handler block. + */ + public LabelNode dflt; + + /** + * The values of the keys. This list is a list of {@link Integer} objects. + */ + public List<Integer> keys; + + /** + * Beginnings of the handler blocks. This list is a list of + * {@link LabelNode} objects. + */ + public List<LabelNode> labels; + + /** + * Constructs a new {@link LookupSwitchInsnNode}. + * + * @param dflt + * beginning of the default handler block. + * @param keys + * the values of the keys. + * @param labels + * beginnings of the handler blocks. <tt>labels[i]</tt> is the + * beginning of the handler block for the <tt>keys[i]</tt> key. + */ + public LookupSwitchInsnNode(final LabelNode dflt, final int[] keys, + final LabelNode[] labels) { + super(Opcodes.LOOKUPSWITCH); + this.dflt = dflt; + this.keys = new ArrayList<Integer>(keys == null ? 0 : keys.length); + this.labels = new ArrayList<LabelNode>(labels == null ? 0 + : labels.length); + if (keys != null) { + for (int i = 0; i < keys.length; ++i) { + this.keys.add(new Integer(keys[i])); + } + } + if (labels != null) { + this.labels.addAll(Arrays.asList(labels)); + } + } + + @Override + public int getType() { + return LOOKUPSWITCH_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + int[] keys = new int[this.keys.size()]; + for (int i = 0; i < keys.length; ++i) { + keys[i] = this.keys.get(i).intValue(); + } + Label[] labels = new Label[this.labels.size()]; + for (int i = 0; i < labels.length; ++i) { + labels[i] = this.labels.get(i).getLabel(); + } + mv.visitLookupSwitchInsn(dflt.getLabel(), keys, labels); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + LookupSwitchInsnNode clone = new LookupSwitchInsnNode(clone(dflt, + labels), null, clone(this.labels, labels)); + clone.keys.addAll(keys); + return clone; + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodInsnNode.java new file mode 100644 index 0000000..d268ed0 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodInsnNode.java @@ -0,0 +1,109 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; + +/** + * A node that represents a method instruction. A method instruction is an + * instruction that invokes a method. + * + * @author Eric Bruneton + */ +public class MethodInsnNode extends AbstractInsnNode { + + /** + * The internal name of the method's owner class (see + * {@link org.apache.tajo.org.objectweb.asm.Type#getInternalName() getInternalName}). + */ + public String owner; + + /** + * The method's name. + */ + public String name; + + /** + * The method's descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + */ + public String desc; + + /** + * Constructs a new {@link MethodInsnNode}. + * + * @param opcode + * the opcode of the type instruction to be constructed. This + * opcode must be INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or + * INVOKEINTERFACE. + * @param owner + * the internal name of the method's owner class (see + * {@link org.apache.tajo.org.objectweb.asm.Type#getInternalName() + * getInternalName}). + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + */ + public MethodInsnNode(final int opcode, final String owner, + final String name, final String desc) { + super(opcode); + this.owner = owner; + this.name = name; + this.desc = desc; + } + + /** + * Sets the opcode of this instruction. + * + * @param opcode + * the new instruction opcode. This opcode must be INVOKEVIRTUAL, + * INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. + */ + public void setOpcode(final int opcode) { + this.opcode = opcode; + } + + @Override + public int getType() { + return METHOD_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitMethodInsn(opcode, owner, name, desc); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new MethodInsnNode(opcode, owner, name, desc); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodNode.java new file mode 100644 index 0000000..e8d1747 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MethodNode.java @@ -0,0 +1,597 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.tajo.org.objectweb.asm.Label; +import org.apache.tajo.org.objectweb.asm.Type; +import org.apache.tajo.org.objectweb.asm.AnnotationVisitor; +import org.apache.tajo.org.objectweb.asm.Attribute; +import org.apache.tajo.org.objectweb.asm.ClassVisitor; +import org.apache.tajo.org.objectweb.asm.Handle; +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; + +/** + * A node that represents a method. + * + * @author Eric Bruneton + */ +public class MethodNode extends MethodVisitor { + + /** + * The method's access flags (see {@link Opcodes}). This field also + * indicates if the method is synthetic and/or deprecated. + */ + public int access; + + /** + * The method's name. + */ + public String name; + + /** + * The method's descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + */ + public String desc; + + /** + * The method's signature. May be <tt>null</tt>. + */ + public String signature; + + /** + * The internal names of the method's exception classes (see + * {@link org.apache.tajo.org.objectweb.asm.Type#getInternalName() getInternalName}). This list is a list of + * {@link String} objects. + */ + public List<String> exceptions; + + /** + * The runtime visible annotations of this method. This list is a list of + * {@link AnnotationNode} objects. May be <tt>null</tt>. + * + * @associates AnnotationNode + * @label visible + */ + public List<AnnotationNode> visibleAnnotations; + + /** + * The runtime invisible annotations of this method. This list is a list of + * {@link AnnotationNode} objects. May be <tt>null</tt>. + * + * @associates AnnotationNode + * @label invisible + */ + public List<AnnotationNode> invisibleAnnotations; + + /** + * The non standard attributes of this method. This list is a list of + * {@link Attribute} objects. May be <tt>null</tt>. + * + * @associates Attribute + */ + public List<Attribute> attrs; + + /** + * The default value of this annotation interface method. This field must be + * a {@link Byte}, {@link Boolean}, {@link Character}, {@link Short}, + * {@link Integer}, {@link Long}, {@link Float}, {@link Double}, + * {@link String} or {@link org.apache.tajo.org.objectweb.asm.Type}, or an two elements String array (for + * enumeration values), a {@link AnnotationNode}, or a {@link List} of + * values of one of the preceding types. May be <tt>null</tt>. + */ + public Object annotationDefault; + + /** + * The runtime visible parameter annotations of this method. These lists are + * lists of {@link AnnotationNode} objects. May be <tt>null</tt>. + * + * @associates AnnotationNode + * @label invisible parameters + */ + public List<AnnotationNode>[] visibleParameterAnnotations; + + /** + * The runtime invisible parameter annotations of this method. These lists + * are lists of {@link AnnotationNode} objects. May be <tt>null</tt>. + * + * @associates AnnotationNode + * @label visible parameters + */ + public List<AnnotationNode>[] invisibleParameterAnnotations; + + /** + * The instructions of this method. This list is a list of + * {@link AbstractInsnNode} objects. + * + * @associates AbstractInsnNode + * @label instructions + */ + public InsnList instructions; + + /** + * The try catch blocks of this method. This list is a list of + * {@link TryCatchBlockNode} objects. + * + * @associates TryCatchBlockNode + */ + public List<TryCatchBlockNode> tryCatchBlocks; + + /** + * The maximum stack size of this method. + */ + public int maxStack; + + /** + * The maximum number of local variables of this method. + */ + public int maxLocals; + + /** + * The local variables of this method. This list is a list of + * {@link LocalVariableNode} objects. May be <tt>null</tt> + * + * @associates LocalVariableNode + */ + public List<LocalVariableNode> localVariables; + + /** + * If the accept method has been called on this object. + */ + private boolean visited; + + /** + * Constructs an uninitialized {@link MethodNode}. <i>Subclasses must not + * use this constructor</i>. Instead, they must use the + * {@link #MethodNode(int)} version. + */ + public MethodNode() { + this(Opcodes.ASM4); + } + + /** + * Constructs an uninitialized {@link MethodNode}. + * + * @param api + * the ASM API version implemented by this visitor. Must be one + * of {@link Opcodes#ASM4}. + */ + public MethodNode(final int api) { + super(api); + this.instructions = new InsnList(); + } + + /** + * Constructs a new {@link MethodNode}. <i>Subclasses must not use this + * constructor</i>. Instead, they must use the + * {@link #MethodNode(int, int, String, String, String, String[])} version. + * + * @param access + * the method's access flags (see {@link Opcodes}). This + * parameter also indicates if the method is synthetic and/or + * deprecated. + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + * @param signature + * the method's signature. May be <tt>null</tt>. + * @param exceptions + * the internal names of the method's exception classes (see + * {@link org.apache.tajo.org.objectweb.asm.Type#getInternalName() getInternalName}). May be + * <tt>null</tt>. + */ + public MethodNode(final int access, final String name, final String desc, + final String signature, final String[] exceptions) { + this(Opcodes.ASM4, access, name, desc, signature, exceptions); + } + + /** + * Constructs a new {@link MethodNode}. + * + * @param api + * the ASM API version implemented by this visitor. Must be one + * of {@link Opcodes#ASM4}. + * @param access + * the method's access flags (see {@link Opcodes}). This + * parameter also indicates if the method is synthetic and/or + * deprecated. + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + * @param signature + * the method's signature. May be <tt>null</tt>. + * @param exceptions + * the internal names of the method's exception classes (see + * {@link org.apache.tajo.org.objectweb.asm.Type#getInternalName() getInternalName}). May be + * <tt>null</tt>. + */ + public MethodNode(final int api, final int access, final String name, + final String desc, final String signature, final String[] exceptions) { + super(api); + this.access = access; + this.name = name; + this.desc = desc; + this.signature = signature; + this.exceptions = new ArrayList<String>(exceptions == null ? 0 + : exceptions.length); + boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0; + if (!isAbstract) { + this.localVariables = new ArrayList<LocalVariableNode>(5); + } + this.tryCatchBlocks = new ArrayList<TryCatchBlockNode>(); + if (exceptions != null) { + this.exceptions.addAll(Arrays.asList(exceptions)); + } + this.instructions = new InsnList(); + } + + // ------------------------------------------------------------------------ + // Implementation of the MethodVisitor abstract class + // ------------------------------------------------------------------------ + + @Override + public AnnotationVisitor visitAnnotationDefault() { + return new AnnotationNode(new ArrayList<Object>(0) { + @Override + public boolean add(final Object o) { + annotationDefault = o; + return super.add(o); + } + }); + } + + @Override + public AnnotationVisitor visitAnnotation(final String desc, + final boolean visible) { + AnnotationNode an = new AnnotationNode(desc); + if (visible) { + if (visibleAnnotations == null) { + visibleAnnotations = new ArrayList<AnnotationNode>(1); + } + visibleAnnotations.add(an); + } else { + if (invisibleAnnotations == null) { + invisibleAnnotations = new ArrayList<AnnotationNode>(1); + } + invisibleAnnotations.add(an); + } + return an; + } + + @Override + public AnnotationVisitor visitParameterAnnotation(final int parameter, + final String desc, final boolean visible) { + AnnotationNode an = new AnnotationNode(desc); + if (visible) { + if (visibleParameterAnnotations == null) { + int params = Type.getArgumentTypes(this.desc).length; + visibleParameterAnnotations = (List<AnnotationNode>[]) new List<?>[params]; + } + if (visibleParameterAnnotations[parameter] == null) { + visibleParameterAnnotations[parameter] = new ArrayList<AnnotationNode>( + 1); + } + visibleParameterAnnotations[parameter].add(an); + } else { + if (invisibleParameterAnnotations == null) { + int params = Type.getArgumentTypes(this.desc).length; + invisibleParameterAnnotations = (List<AnnotationNode>[]) new List<?>[params]; + } + if (invisibleParameterAnnotations[parameter] == null) { + invisibleParameterAnnotations[parameter] = new ArrayList<AnnotationNode>( + 1); + } + invisibleParameterAnnotations[parameter].add(an); + } + return an; + } + + @Override + public void visitAttribute(final Attribute attr) { + if (attrs == null) { + attrs = new ArrayList<Attribute>(1); + } + attrs.add(attr); + } + + @Override + public void visitCode() { + } + + @Override + public void visitFrame(final int type, final int nLocal, + final Object[] local, final int nStack, final Object[] stack) { + instructions.add(new FrameNode(type, nLocal, local == null ? null + : getLabelNodes(local), nStack, stack == null ? null + : getLabelNodes(stack))); + } + + @Override + public void visitInsn(final int opcode) { + instructions.add(new InsnNode(opcode)); + } + + @Override + public void visitIntInsn(final int opcode, final int operand) { + instructions.add(new IntInsnNode(opcode, operand)); + } + + @Override + public void visitVarInsn(final int opcode, final int var) { + instructions.add(new VarInsnNode(opcode, var)); + } + + @Override + public void visitTypeInsn(final int opcode, final String type) { + instructions.add(new TypeInsnNode(opcode, type)); + } + + @Override + public void visitFieldInsn(final int opcode, final String owner, + final String name, final String desc) { + instructions.add(new FieldInsnNode(opcode, owner, name, desc)); + } + + @Override + public void visitMethodInsn(final int opcode, final String owner, + final String name, final String desc) { + instructions.add(new MethodInsnNode(opcode, owner, name, desc)); + } + + @Override + public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, + Object... bsmArgs) { + instructions.add(new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs)); + } + + @Override + public void visitJumpInsn(final int opcode, final Label label) { + instructions.add(new JumpInsnNode(opcode, getLabelNode(label))); + } + + @Override + public void visitLabel(final Label label) { + instructions.add(getLabelNode(label)); + } + + @Override + public void visitLdcInsn(final Object cst) { + instructions.add(new LdcInsnNode(cst)); + } + + @Override + public void visitIincInsn(final int var, final int increment) { + instructions.add(new IincInsnNode(var, increment)); + } + + @Override + public void visitTableSwitchInsn(final int min, final int max, + final Label dflt, final Label... labels) { + instructions.add(new TableSwitchInsnNode(min, max, getLabelNode(dflt), + getLabelNodes(labels))); + } + + @Override + public void visitLookupSwitchInsn(final Label dflt, final int[] keys, + final Label[] labels) { + instructions.add(new LookupSwitchInsnNode(getLabelNode(dflt), keys, + getLabelNodes(labels))); + } + + @Override + public void visitMultiANewArrayInsn(final String desc, final int dims) { + instructions.add(new MultiANewArrayInsnNode(desc, dims)); + } + + @Override + public void visitTryCatchBlock(final Label start, final Label end, + final Label handler, final String type) { + tryCatchBlocks.add(new TryCatchBlockNode(getLabelNode(start), + getLabelNode(end), getLabelNode(handler), type)); + } + + @Override + public void visitLocalVariable(final String name, final String desc, + final String signature, final Label start, final Label end, + final int index) { + localVariables.add(new LocalVariableNode(name, desc, signature, + getLabelNode(start), getLabelNode(end), index)); + } + + @Override + public void visitLineNumber(final int line, final Label start) { + instructions.add(new LineNumberNode(line, getLabelNode(start))); + } + + @Override + public void visitMaxs(final int maxStack, final int maxLocals) { + this.maxStack = maxStack; + this.maxLocals = maxLocals; + } + + @Override + public void visitEnd() { + } + + /** + * Returns the LabelNode corresponding to the given Label. Creates a new + * LabelNode if necessary. The default implementation of this method uses + * the {@link Label#info} field to store associations between labels and + * label nodes. + * + * @param l + * a Label. + * @return the LabelNode corresponding to l. + */ + protected LabelNode getLabelNode(final Label l) { + if (!(l.info instanceof LabelNode)) { + l.info = new LabelNode(); + } + return (LabelNode) l.info; + } + + private LabelNode[] getLabelNodes(final Label[] l) { + LabelNode[] nodes = new LabelNode[l.length]; + for (int i = 0; i < l.length; ++i) { + nodes[i] = getLabelNode(l[i]); + } + return nodes; + } + + private Object[] getLabelNodes(final Object[] objs) { + Object[] nodes = new Object[objs.length]; + for (int i = 0; i < objs.length; ++i) { + Object o = objs[i]; + if (o instanceof Label) { + o = getLabelNode((Label) o); + } + nodes[i] = o; + } + return nodes; + } + + // ------------------------------------------------------------------------ + // Accept method + // ------------------------------------------------------------------------ + + /** + * Checks that this method node is compatible with the given ASM API + * version. This methods checks that this node, and all its nodes + * recursively, do not contain elements that were introduced in more recent + * versions of the ASM API than the given version. + * + * @param api + * an ASM API version. Must be one of {@link Opcodes#ASM4}. + */ + public void check(final int api) { + // nothing to do + } + + /** + * Makes the given class visitor visit this method. + * + * @param cv + * a class visitor. + */ + public void accept(final ClassVisitor cv) { + String[] exceptions = new String[this.exceptions.size()]; + this.exceptions.toArray(exceptions); + MethodVisitor mv = cv.visitMethod(access, name, desc, signature, + exceptions); + if (mv != null) { + accept(mv); + } + } + + /** + * Makes the given method visitor visit this method. + * + * @param mv + * a method visitor. + */ + public void accept(final MethodVisitor mv) { + // visits the method attributes + int i, j, n; + if (annotationDefault != null) { + AnnotationVisitor av = mv.visitAnnotationDefault(); + AnnotationNode.accept(av, null, annotationDefault); + if (av != null) { + av.visitEnd(); + } + } + n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); + for (i = 0; i < n; ++i) { + AnnotationNode an = visibleAnnotations.get(i); + an.accept(mv.visitAnnotation(an.desc, true)); + } + n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); + for (i = 0; i < n; ++i) { + AnnotationNode an = invisibleAnnotations.get(i); + an.accept(mv.visitAnnotation(an.desc, false)); + } + n = visibleParameterAnnotations == null ? 0 + : visibleParameterAnnotations.length; + for (i = 0; i < n; ++i) { + List<?> l = visibleParameterAnnotations[i]; + if (l == null) { + continue; + } + for (j = 0; j < l.size(); ++j) { + AnnotationNode an = (AnnotationNode) l.get(j); + an.accept(mv.visitParameterAnnotation(i, an.desc, true)); + } + } + n = invisibleParameterAnnotations == null ? 0 + : invisibleParameterAnnotations.length; + for (i = 0; i < n; ++i) { + List<?> l = invisibleParameterAnnotations[i]; + if (l == null) { + continue; + } + for (j = 0; j < l.size(); ++j) { + AnnotationNode an = (AnnotationNode) l.get(j); + an.accept(mv.visitParameterAnnotation(i, an.desc, false)); + } + } + if (visited) { + instructions.resetLabels(); + } + n = attrs == null ? 0 : attrs.size(); + for (i = 0; i < n; ++i) { + mv.visitAttribute(attrs.get(i)); + } + // visits the method's code + if (instructions.size() > 0) { + mv.visitCode(); + // visits try catch blocks + n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size(); + for (i = 0; i < n; ++i) { + tryCatchBlocks.get(i).accept(mv); + } + // visits instructions + instructions.accept(mv); + // visits local variables + n = localVariables == null ? 0 : localVariables.size(); + for (i = 0; i < n; ++i) { + localVariables.get(i).accept(mv); + } + // visits maxs + mv.visitMaxs(maxStack, maxLocals); + visited = true; + } + mv.visitEnd(); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MultiANewArrayInsnNode.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MultiANewArrayInsnNode.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MultiANewArrayInsnNode.java new file mode 100644 index 0000000..14c9f98 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/tree/MultiANewArrayInsnNode.java @@ -0,0 +1,83 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.apache.tajo.org.objectweb.asm.tree; + +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; + +/** + * A node that represents a MULTIANEWARRAY instruction. + * + * @author Eric Bruneton + */ +public class MultiANewArrayInsnNode extends AbstractInsnNode { + + /** + * An array type descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + */ + public String desc; + + /** + * Number of dimensions of the array to allocate. + */ + public int dims; + + /** + * Constructs a new {@link MultiANewArrayInsnNode}. + * + * @param desc + * an array type descriptor (see {@link org.apache.tajo.org.objectweb.asm.Type}). + * @param dims + * number of dimensions of the array to allocate. + */ + public MultiANewArrayInsnNode(final String desc, final int dims) { + super(Opcodes.MULTIANEWARRAY); + this.desc = desc; + this.dims = dims; + } + + @Override + public int getType() { + return MULTIANEWARRAY_INSN; + } + + @Override + public void accept(final MethodVisitor mv) { + mv.visitMultiANewArrayInsn(desc, dims); + } + + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { + return new MultiANewArrayInsnNode(desc, dims); + } + +}
