PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/com/alibaba/fastjson/asm/MethodWriter.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 213 lines | 192 code | 17 blank | 4 comment | 34 complexity | 4a9e90c68dfa6a111ae12c5eb162156a MD5 | raw file
  1. package com.alibaba.fastjson.asm;
  2. class MethodWriter
  3. implements MethodVisitor
  4. {
  5. static final int ACC_CONSTRUCTOR = 262144;
  6. static final int APPEND_FRAME = 252;
  7. static final int CHOP_FRAME = 248;
  8. static final int FULL_FRAME = 255;
  9. static final int RESERVED = 128;
  10. static final int SAME_FRAME = 0;
  11. static final int SAME_FRAME_EXTENDED = 251;
  12. static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64;
  13. static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247;
  14. private int access;
  15. int classReaderLength;
  16. private ByteVector code = new ByteVector();
  17. final ClassWriter cw;
  18. private final int desc;
  19. int exceptionCount;
  20. int[] exceptions;
  21. private int maxLocals;
  22. private int maxStack;
  23. private final int name;
  24. MethodWriter next;
  25. MethodWriter(ClassWriter paramClassWriter, int paramInt, String paramString1, String paramString2, String paramString3, String[] paramArrayOfString)
  26. {
  27. if (paramClassWriter.firstMethod == null)
  28. paramClassWriter.firstMethod = this;
  29. while (true)
  30. {
  31. paramClassWriter.lastMethod = this;
  32. this.cw = paramClassWriter;
  33. this.access = paramInt;
  34. this.name = paramClassWriter.newUTF8(paramString1);
  35. this.desc = paramClassWriter.newUTF8(paramString2);
  36. if ((paramArrayOfString == null) || (paramArrayOfString.length <= 0))
  37. break;
  38. this.exceptionCount = paramArrayOfString.length;
  39. this.exceptions = new int[this.exceptionCount];
  40. paramInt = 0;
  41. while (paramInt < this.exceptionCount)
  42. {
  43. this.exceptions[paramInt] = paramClassWriter.newClass(paramArrayOfString[paramInt]);
  44. paramInt += 1;
  45. }
  46. paramClassWriter.lastMethod.next = this;
  47. }
  48. }
  49. final int getSize()
  50. {
  51. int i = 8;
  52. if (this.code.length > 0)
  53. {
  54. this.cw.newUTF8("Code");
  55. i = 8 + (this.code.length + 18 + 0);
  56. }
  57. int j = i;
  58. if (this.exceptionCount > 0)
  59. {
  60. this.cw.newUTF8("Exceptions");
  61. j = i + (this.exceptionCount * 2 + 8);
  62. }
  63. return j;
  64. }
  65. final void put(ByteVector paramByteVector)
  66. {
  67. int i = (this.access & 0x40000) / 64;
  68. paramByteVector.putShort(this.access & ((0x60000 | i) ^ 0xFFFFFFFF)).putShort(this.name).putShort(this.desc);
  69. i = 0;
  70. if (this.code.length > 0)
  71. i = 0 + 1;
  72. int j = i;
  73. if (this.exceptionCount > 0)
  74. j = i + 1;
  75. paramByteVector.putShort(j);
  76. if (this.code.length > 0)
  77. {
  78. i = this.code.length;
  79. paramByteVector.putShort(this.cw.newUTF8("Code")).putInt(i + 12 + 0);
  80. paramByteVector.putShort(this.maxStack).putShort(this.maxLocals);
  81. paramByteVector.putInt(this.code.length).putByteArray(this.code.data, 0, this.code.length);
  82. paramByteVector.putShort(0);
  83. paramByteVector.putShort(0);
  84. }
  85. if (this.exceptionCount > 0)
  86. {
  87. paramByteVector.putShort(this.cw.newUTF8("Exceptions")).putInt(this.exceptionCount * 2 + 2);
  88. paramByteVector.putShort(this.exceptionCount);
  89. i = 0;
  90. while (i < this.exceptionCount)
  91. {
  92. paramByteVector.putShort(this.exceptions[i]);
  93. i += 1;
  94. }
  95. }
  96. }
  97. public void visitEnd()
  98. {
  99. }
  100. public void visitFieldInsn(int paramInt, String paramString1, String paramString2, String paramString3)
  101. {
  102. paramString1 = this.cw.newFieldItem(paramString1, paramString2, paramString3);
  103. this.code.put12(paramInt, paramString1.index);
  104. }
  105. public void visitIincInsn(int paramInt1, int paramInt2)
  106. {
  107. this.code.putByte(132).put11(paramInt1, paramInt2);
  108. }
  109. public void visitInsn(int paramInt)
  110. {
  111. this.code.putByte(paramInt);
  112. }
  113. public void visitIntInsn(int paramInt1, int paramInt2)
  114. {
  115. this.code.put11(paramInt1, paramInt2);
  116. }
  117. public void visitJumpInsn(int paramInt, Label paramLabel)
  118. {
  119. if (((paramLabel.status & 0x2) != 0) && (paramLabel.position - this.code.length < -32768))
  120. throw new UnsupportedOperationException();
  121. this.code.putByte(paramInt);
  122. paramLabel.put(this, this.code, this.code.length - 1);
  123. }
  124. public void visitLabel(Label paramLabel)
  125. {
  126. paramLabel.resolve(this, this.code.length, this.code.data);
  127. }
  128. public void visitLdcInsn(Object paramObject)
  129. {
  130. paramObject = this.cw.newConstItem(paramObject);
  131. int i = paramObject.index;
  132. if ((paramObject.type == 5) || (paramObject.type == 6))
  133. {
  134. this.code.put12(20, i);
  135. return;
  136. }
  137. if (i >= 256)
  138. {
  139. this.code.put12(19, i);
  140. return;
  141. }
  142. this.code.put11(18, i);
  143. }
  144. public void visitMaxs(int paramInt1, int paramInt2)
  145. {
  146. this.maxStack = paramInt1;
  147. this.maxLocals = paramInt2;
  148. }
  149. public void visitMethodInsn(int paramInt, String paramString1, String paramString2, String paramString3)
  150. {
  151. if (paramInt == 185);
  152. for (boolean bool = true; ; bool = false)
  153. {
  154. paramString1 = this.cw.newMethodItem(paramString1, paramString2, paramString3, bool);
  155. int i = paramString1.intVal;
  156. if (!bool)
  157. break;
  158. paramInt = i;
  159. if (i == 0)
  160. {
  161. paramInt = Type.getArgumentsAndReturnSizes(paramString3);
  162. paramString1.intVal = paramInt;
  163. }
  164. this.code.put12(185, paramString1.index).put11(paramInt >> 2, 0);
  165. return;
  166. }
  167. this.code.put12(paramInt, paramString1.index);
  168. }
  169. public void visitTypeInsn(int paramInt, String paramString)
  170. {
  171. paramString = this.cw.newClassItem(paramString);
  172. this.code.put12(paramInt, paramString.index);
  173. }
  174. public void visitVarInsn(int paramInt1, int paramInt2)
  175. {
  176. if ((paramInt2 < 4) && (paramInt1 != 169))
  177. {
  178. if (paramInt1 < 54);
  179. for (paramInt1 = (paramInt1 - 21 << 2) + 26 + paramInt2; ; paramInt1 = (paramInt1 - 54 << 2) + 59 + paramInt2)
  180. {
  181. this.code.putByte(paramInt1);
  182. return;
  183. }
  184. }
  185. if (paramInt2 >= 256)
  186. {
  187. this.code.putByte(196).put12(paramInt1, paramInt2);
  188. return;
  189. }
  190. this.code.put11(paramInt1, paramInt2);
  191. }
  192. }
  193. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  194. * Qualified Name: com.alibaba.fastjson.asm.MethodWriter
  195. * JD-Core Version: 0.6.2
  196. */