PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/objectweb/asm/CodeVisitor.java

#
Java | 287 lines | 25 code | 40 blank | 222 comment | 0 complexity | e9061d0e47ea5f3b56f1c98e7aefc51f MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /***
  2. * ASM: a very small and fast Java bytecode manipulation framework
  3. * Copyright (C) 2000 INRIA, France Telecom
  4. * Copyright (C) 2002 France Telecom
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * Contact: Eric.Bruneton@rd.francetelecom.com
  21. *
  22. * Author: Eric Bruneton
  23. */
  24. package org.objectweb.asm;
  25. /**
  26. * A visitor to visit the bytecode instructions of a Java method. The methods
  27. * of this visitor must be called in the sequential order of the bytecode
  28. * instructions of the visited code. The {@link #visitMaxs visitMaxs} method
  29. * must be called after all the instructions have been visited. The {@link
  30. * #visitTryCatchBlock visitTryCatchBlock}, {@link #visitLocalVariable
  31. * visitLocalVariable} and {@link #visitLineNumber visitLineNumber} methods may
  32. * be called in any order, at any time (provided the labels passed as arguments
  33. * have already been visited with {@link #visitLabel visitLabel}).
  34. */
  35. public interface CodeVisitor {
  36. /**
  37. * Visits a zero operand instruction.
  38. *
  39. * @param opcode the opcode of the instruction to be visited. This opcode is
  40. * either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2,
  41. * ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1,
  42. * FCONST_2, DCONST_0, DCONST_1,
  43. *
  44. * IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD,
  45. * IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE,
  46. * SASTORE,
  47. *
  48. * POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP,
  49. *
  50. * IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL,
  51. * DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG,
  52. * FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR,
  53. * LOR, IXOR, LXOR,
  54. *
  55. * I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C,
  56. * I2S,
  57. *
  58. * LCMP, FCMPL, FCMPG, DCMPL, DCMPG,
  59. *
  60. * IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN,
  61. *
  62. * ARRAYLENGTH,
  63. *
  64. * ATHROW,
  65. *
  66. * MONITORENTER, or MONITOREXIT.
  67. */
  68. void visitInsn (int opcode);
  69. /**
  70. * Visits an instruction with a single int operand.
  71. *
  72. * @param opcode the opcode of the instruction to be visited. This opcode is
  73. * either BIPUSH, SIPUSH or NEWARRAY.
  74. * @param operand the operand of the instruction to be visited.
  75. */
  76. void visitIntInsn (int opcode, int operand);
  77. /**
  78. * Visits a local variable instruction. A local variable instruction is an
  79. * instruction that loads or stores the value of a local variable.
  80. *
  81. * @param opcode the opcode of the local variable instruction to be visited.
  82. * This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE,
  83. * LSTORE, FSTORE, DSTORE, ASTORE or RET.
  84. * @param var the operand of the instruction to be visited. This operand is
  85. * the index of a local variable.
  86. */
  87. void visitVarInsn (int opcode, int var);
  88. /**
  89. * Visits a type instruction. A type instruction is an instruction that
  90. * takes a type descriptor as parameter.
  91. *
  92. * @param opcode the opcode of the type instruction to be visited. This opcode
  93. * is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
  94. * @param desc the operand of the instruction to be visited. This operand is
  95. * must be a fully qualified class name in internal form, or the type
  96. * descriptor of an array type (see {@link Type Type}).
  97. */
  98. void visitTypeInsn (int opcode, String desc);
  99. /**
  100. * Visits a field instruction. A field instruction is an instruction that
  101. * loads or stores the value of a field of an object.
  102. *
  103. * @param opcode the opcode of the type instruction to be visited. This opcode
  104. * is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
  105. * @param owner the internal name of the field's owner class (see {@link
  106. * Type#getInternalName getInternalName}).
  107. * @param name the field's name.
  108. * @param desc the field's descriptor (see {@link Type Type}).
  109. */
  110. void visitFieldInsn (int opcode, String owner, String name, String desc);
  111. /**
  112. * Visits a method instruction. A method instruction is an instruction that
  113. * invokes a method.
  114. *
  115. * @param opcode the opcode of the type instruction to be visited. This opcode
  116. * is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
  117. * INVOKEINTERFACE.
  118. * @param owner the internal name of the method's owner class (see {@link
  119. * Type#getInternalName getInternalName}).
  120. * @param name the method's name.
  121. * @param desc the method's descriptor (see {@link Type Type}).
  122. */
  123. void visitMethodInsn (int opcode, String owner, String name, String desc);
  124. /**
  125. * Visits a jump instruction. A jump instruction is an instruction that may
  126. * jump to another instruction.
  127. *
  128. * @param opcode the opcode of the type instruction to be visited. This opcode
  129. * is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE,
  130. * IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE,
  131. * GOTO, JSR, IFNULL or IFNONNULL.
  132. * @param label the operand of the instruction to be visited. This operand is
  133. * a label that designates the instruction to which the jump instruction
  134. * may jump.
  135. */
  136. void visitJumpInsn (int opcode, Label label);
  137. /**
  138. * Visits a label. A label designates the instruction that will be visited
  139. * just after it.
  140. *
  141. * @param label a {@link Label Label} object.
  142. */
  143. void visitLabel (Label label);
  144. // -------------------------------------------------------------------------
  145. // Special instructions
  146. // -------------------------------------------------------------------------
  147. /**
  148. * Visits a LDC instruction.
  149. *
  150. * @param cst the constant to be loaded on the stack. This parameter must be
  151. * a non null {@link java.lang.Integer Integer}, a {@link java.lang.Float
  152. * Float}, a {@link java.lang.Long Long}, a {@link java.lang.Double
  153. * Double} or a {@link String String}.
  154. */
  155. void visitLdcInsn (Object cst);
  156. /**
  157. * Visits an IINC instruction.
  158. *
  159. * @param var index of the local variable to be incremented.
  160. * @param increment amount to increment the local variable by.
  161. */
  162. void visitIincInsn (int var, int increment);
  163. /**
  164. * Visits a TABLESWITCH instruction.
  165. *
  166. * @param min the minimum key value.
  167. * @param max the maximum key value.
  168. * @param dflt beginning of the default handler block.
  169. * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is the
  170. * beginning of the handler block for the <tt>min + i</tt> key.
  171. */
  172. void visitTableSwitchInsn (int min, int max, Label dflt, Label labels[]);
  173. /**
  174. * Visits a LOOKUPSWITCH instruction.
  175. *
  176. * @param dflt beginning of the default handler block.
  177. * @param keys the values of the keys.
  178. * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is the
  179. * beginning of the handler block for the <tt>keys[i]</tt> key.
  180. */
  181. void visitLookupSwitchInsn (Label dflt, int keys[], Label labels[]);
  182. /**
  183. * Visits a MULTIANEWARRAY instruction.
  184. *
  185. * @param desc an array type descriptor (see {@link Type Type}).
  186. * @param dims number of dimensions of the array to allocate.
  187. */
  188. void visitMultiANewArrayInsn (String desc, int dims);
  189. // -------------------------------------------------------------------------
  190. // Exceptions table entries, max stack size and max locals
  191. // -------------------------------------------------------------------------
  192. /**
  193. * Visits a try catch block.
  194. *
  195. * @param start beginning of the exception handler's scope (inclusive).
  196. * @param end end of the exception handler's scope (exclusive).
  197. * @param handler beginning of the exception handler's code.
  198. * @param type internal name of the type of exceptions handled by the handler,
  199. * or <tt>null</tt> to catch any exceptions (for "finally" blocks).
  200. * @throws IllegalArgumentException if one of the labels has not already been
  201. * visited by this visitor (by the {@link #visitLabel visitLabel}
  202. * method).
  203. */
  204. void visitTryCatchBlock (Label start, Label end, Label handler, String type);
  205. /**
  206. * Visits the maximum stack size and the maximum number of local variables of
  207. * the method.
  208. *
  209. * @param maxStack maximum stack size of the method.
  210. * @param maxLocals maximum number of local variables for the method.
  211. */
  212. void visitMaxs (int maxStack, int maxLocals);
  213. // -------------------------------------------------------------------------
  214. // Debug information
  215. // -------------------------------------------------------------------------
  216. /**
  217. * Visits a local variable declaration.
  218. *
  219. * @param name the name of a local variable.
  220. * @param desc the type descriptor of this local variable.
  221. * @param start the first instruction corresponding to the scope of this
  222. * local variable (inclusive).
  223. * @param end the last instruction corresponding to the scope of this
  224. * local variable (exclusive).
  225. * @param index the local variable's index.
  226. * @throws IllegalArgumentException if one of the labels has not already been
  227. * visited by this visitor (by the {@link #visitLabel visitLabel}
  228. * method).
  229. */
  230. void visitLocalVariable (
  231. String name,
  232. String desc,
  233. Label start,
  234. Label end,
  235. int index);
  236. /**
  237. * Visits a line number declaration.
  238. *
  239. * @param line a line number. This number refers to the source file
  240. * from which the class was compiled.
  241. * @param start the first instruction corresponding to this line number.
  242. * @throws IllegalArgumentException if <tt>start</tt> has not already been
  243. * visited by this visitor (by the {@link #visitLabel visitLabel}
  244. * method).
  245. */
  246. void visitLineNumber (int line, Label start);
  247. }