PageRenderTime 125ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/QingTingFanBianYi/src/com/alibaba/fastjson/serializer/ASMSerializerFactory.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 1380 lines | 1329 code | 47 blank | 4 comment | 242 complexity | b54cd53ef38d7b0c70524a535e949d94 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. package com.alibaba.fastjson.serializer;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONException;
  4. import com.alibaba.fastjson.annotation.JSONField;
  5. import com.alibaba.fastjson.annotation.JSONType;
  6. import com.alibaba.fastjson.asm.ClassWriter;
  7. import com.alibaba.fastjson.asm.FieldVisitor;
  8. import com.alibaba.fastjson.asm.Label;
  9. import com.alibaba.fastjson.asm.MethodVisitor;
  10. import com.alibaba.fastjson.asm.Opcodes;
  11. import com.alibaba.fastjson.asm.Type;
  12. import com.alibaba.fastjson.util.ASMClassLoader;
  13. import com.alibaba.fastjson.util.ASMUtils;
  14. import com.alibaba.fastjson.util.FieldInfo;
  15. import com.alibaba.fastjson.util.TypeUtils;
  16. import java.lang.reflect.Field;
  17. import java.lang.reflect.Method;
  18. import java.lang.reflect.Modifier;
  19. import java.math.BigDecimal;
  20. import java.util.Collection;
  21. import java.util.HashMap;
  22. import java.util.Iterator;
  23. import java.util.List;
  24. import java.util.Map;
  25. import java.util.concurrent.atomic.AtomicLong;
  26. public class ASMSerializerFactory
  27. implements Opcodes
  28. {
  29. private ASMClassLoader classLoader = new ASMClassLoader();
  30. private final AtomicLong seed = new AtomicLong();
  31. private void _after(MethodVisitor paramMethodVisitor, Context paramContext)
  32. {
  33. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  34. paramMethodVisitor.visitVarInsn(25, paramContext.obj());
  35. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  36. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "writeAfter", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;C)C");
  37. paramMethodVisitor.visitVarInsn(54, paramContext.var("seperator"));
  38. }
  39. private void _apply(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  40. {
  41. paramFieldInfo = paramFieldInfo.getFieldClass();
  42. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  43. paramMethodVisitor.visitVarInsn(25, paramContext.obj());
  44. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  45. if (paramFieldInfo == Byte.TYPE)
  46. {
  47. paramMethodVisitor.visitVarInsn(21, paramContext.var("byte"));
  48. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;B)Z");
  49. return;
  50. }
  51. if (paramFieldInfo == Short.TYPE)
  52. {
  53. paramMethodVisitor.visitVarInsn(21, paramContext.var("short"));
  54. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;S)Z");
  55. return;
  56. }
  57. if (paramFieldInfo == Integer.TYPE)
  58. {
  59. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  60. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;I)Z");
  61. return;
  62. }
  63. if (paramFieldInfo == Character.TYPE)
  64. {
  65. paramMethodVisitor.visitVarInsn(21, paramContext.var("char"));
  66. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;C)Z");
  67. return;
  68. }
  69. if (paramFieldInfo == Long.TYPE)
  70. {
  71. paramMethodVisitor.visitVarInsn(22, paramContext.var("long", 2));
  72. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;J)Z");
  73. return;
  74. }
  75. if (paramFieldInfo == Float.TYPE)
  76. {
  77. paramMethodVisitor.visitVarInsn(23, paramContext.var("float"));
  78. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;F)Z");
  79. return;
  80. }
  81. if (paramFieldInfo == Double.TYPE)
  82. {
  83. paramMethodVisitor.visitVarInsn(24, paramContext.var("double", 2));
  84. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;D)Z");
  85. return;
  86. }
  87. if (paramFieldInfo == Boolean.TYPE)
  88. {
  89. paramMethodVisitor.visitVarInsn(21, paramContext.var("boolean"));
  90. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;B)Z");
  91. return;
  92. }
  93. if (paramFieldInfo == BigDecimal.class)
  94. {
  95. paramMethodVisitor.visitVarInsn(25, paramContext.var("decimal"));
  96. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
  97. return;
  98. }
  99. if (paramFieldInfo == String.class)
  100. {
  101. paramMethodVisitor.visitVarInsn(25, paramContext.var("string"));
  102. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
  103. return;
  104. }
  105. if (paramFieldInfo.isEnum())
  106. {
  107. paramMethodVisitor.visitVarInsn(25, paramContext.var("enum"));
  108. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
  109. return;
  110. }
  111. if (List.class.isAssignableFrom(paramFieldInfo))
  112. {
  113. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  114. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
  115. return;
  116. }
  117. paramMethodVisitor.visitVarInsn(25, paramContext.var("object"));
  118. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
  119. }
  120. private void _before(MethodVisitor paramMethodVisitor, Context paramContext)
  121. {
  122. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  123. paramMethodVisitor.visitVarInsn(25, paramContext.obj());
  124. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  125. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "writeBefore", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;C)C");
  126. paramMethodVisitor.visitVarInsn(54, paramContext.var("seperator"));
  127. }
  128. private void _boolean(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  129. {
  130. paramClass = new Label();
  131. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  132. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  133. paramMethodVisitor.visitVarInsn(54, paramContext.var("boolean"));
  134. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  135. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  136. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  137. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  138. paramMethodVisitor.visitVarInsn(21, paramContext.var("boolean"));
  139. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Z)V");
  140. _seperator(paramMethodVisitor, paramContext);
  141. paramMethodVisitor.visitLabel(paramClass);
  142. }
  143. private void _byte(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  144. {
  145. paramClass = new Label();
  146. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  147. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  148. paramMethodVisitor.visitVarInsn(54, paramContext.var("byte"));
  149. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  150. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  151. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  152. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  153. paramMethodVisitor.visitVarInsn(21, paramContext.var("byte"));
  154. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V");
  155. _seperator(paramMethodVisitor, paramContext);
  156. paramMethodVisitor.visitLabel(paramClass);
  157. }
  158. private void _char(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  159. {
  160. paramClass = new Label();
  161. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  162. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  163. paramMethodVisitor.visitVarInsn(54, paramContext.var("char"));
  164. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  165. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  166. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  167. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  168. paramMethodVisitor.visitVarInsn(21, paramContext.var("char"));
  169. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;C)V");
  170. _seperator(paramMethodVisitor, paramContext);
  171. paramMethodVisitor.visitLabel(paramClass);
  172. }
  173. private void _decimal(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  174. {
  175. paramClass = new Label();
  176. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  177. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  178. paramMethodVisitor.visitVarInsn(58, paramContext.var("decimal"));
  179. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  180. Label localLabel1 = new Label();
  181. Label localLabel2 = new Label();
  182. Label localLabel3 = new Label();
  183. paramMethodVisitor.visitLabel(localLabel1);
  184. paramMethodVisitor.visitVarInsn(25, paramContext.var("decimal"));
  185. paramMethodVisitor.visitJumpInsn(199, localLabel2);
  186. _if_write_null(paramMethodVisitor, paramFieldInfo, paramContext);
  187. paramMethodVisitor.visitJumpInsn(167, localLabel3);
  188. paramMethodVisitor.visitLabel(localLabel2);
  189. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  190. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  191. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  192. paramMethodVisitor.visitVarInsn(25, paramContext.var("decimal"));
  193. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Ljava/math/BigDecimal;)V");
  194. _seperator(paramMethodVisitor, paramContext);
  195. paramMethodVisitor.visitJumpInsn(167, localLabel3);
  196. paramMethodVisitor.visitLabel(localLabel3);
  197. paramMethodVisitor.visitLabel(paramClass);
  198. }
  199. private void _double(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  200. {
  201. paramClass = new Label();
  202. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  203. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  204. paramMethodVisitor.visitVarInsn(57, paramContext.var("double", 2));
  205. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  206. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  207. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  208. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  209. paramMethodVisitor.visitVarInsn(24, paramContext.var("double", 2));
  210. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;D)V");
  211. _seperator(paramMethodVisitor, paramContext);
  212. paramMethodVisitor.visitLabel(paramClass);
  213. }
  214. private void _enum(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  215. {
  216. int k = 0;
  217. int i = 0;
  218. paramClass = (JSONField)paramFieldInfo.getAnnotation(JSONField.class);
  219. if (paramClass != null)
  220. {
  221. paramClass = paramClass.serialzeFeatures();
  222. int m = paramClass.length;
  223. int j = 0;
  224. while (true)
  225. {
  226. k = i;
  227. if (j >= m)
  228. break;
  229. if (paramClass[j] == SerializerFeature.WriteEnumUsingToString)
  230. i = 1;
  231. j += 1;
  232. }
  233. }
  234. paramClass = new Label();
  235. Label localLabel1 = new Label();
  236. Label localLabel2 = new Label();
  237. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, localLabel2);
  238. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  239. paramMethodVisitor.visitTypeInsn(192, ASMUtils.getType(Enum.class));
  240. paramMethodVisitor.visitVarInsn(58, paramContext.var("enum"));
  241. _filters(paramMethodVisitor, paramFieldInfo, paramContext, localLabel2);
  242. paramMethodVisitor.visitVarInsn(25, paramContext.var("enum"));
  243. paramMethodVisitor.visitJumpInsn(199, paramClass);
  244. _if_write_null(paramMethodVisitor, paramFieldInfo, paramContext);
  245. paramMethodVisitor.visitJumpInsn(167, localLabel1);
  246. paramMethodVisitor.visitLabel(paramClass);
  247. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  248. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  249. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  250. paramMethodVisitor.visitVarInsn(25, paramContext.var("enum"));
  251. if (k != 0)
  252. {
  253. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(Object.class), "toString", "()Ljava/lang/String;");
  254. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V");
  255. }
  256. while (true)
  257. {
  258. _seperator(paramMethodVisitor, paramContext);
  259. paramMethodVisitor.visitLabel(localLabel1);
  260. paramMethodVisitor.visitLabel(localLabel2);
  261. return;
  262. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;L" + ASMUtils.getType(Enum.class) + ";)V");
  263. }
  264. }
  265. private void _filters(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext, Label paramLabel)
  266. {
  267. if ((paramFieldInfo.getField() != null) && (Modifier.isTransient(paramFieldInfo.getField().getModifiers())))
  268. {
  269. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  270. paramMethodVisitor.visitFieldInsn(178, ASMUtils.getType(SerializerFeature.class), "SkipTransientField", "L" + ASMUtils.getType(SerializerFeature.class) + ";");
  271. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "isEnabled", "(L" + ASMUtils.getType(SerializerFeature.class) + ";" + ")Z");
  272. paramMethodVisitor.visitJumpInsn(154, paramLabel);
  273. }
  274. _apply(paramMethodVisitor, paramFieldInfo, paramContext);
  275. paramMethodVisitor.visitJumpInsn(153, paramLabel);
  276. _processKey(paramMethodVisitor, paramFieldInfo, paramContext);
  277. Label localLabel = new Label();
  278. _processValue(paramMethodVisitor, paramFieldInfo, paramContext);
  279. paramMethodVisitor.visitVarInsn(25, paramContext.original());
  280. paramMethodVisitor.visitVarInsn(25, paramContext.processValue());
  281. paramMethodVisitor.visitJumpInsn(165, localLabel);
  282. _writeObject(paramMethodVisitor, paramFieldInfo, paramContext, paramLabel);
  283. paramMethodVisitor.visitJumpInsn(167, paramLabel);
  284. paramMethodVisitor.visitLabel(localLabel);
  285. }
  286. private void _float(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  287. {
  288. paramClass = new Label();
  289. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  290. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  291. paramMethodVisitor.visitVarInsn(56, paramContext.var("float"));
  292. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  293. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  294. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  295. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  296. paramMethodVisitor.visitVarInsn(23, paramContext.var("float"));
  297. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;F)V");
  298. _seperator(paramMethodVisitor, paramContext);
  299. paramMethodVisitor.visitLabel(paramClass);
  300. }
  301. private void _get(MethodVisitor paramMethodVisitor, Context paramContext, FieldInfo paramFieldInfo)
  302. {
  303. Method localMethod = paramFieldInfo.getMethod();
  304. if (localMethod != null)
  305. {
  306. paramMethodVisitor.visitVarInsn(25, paramContext.var("entity"));
  307. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(localMethod.getDeclaringClass()), localMethod.getName(), ASMUtils.getDesc(localMethod));
  308. return;
  309. }
  310. paramMethodVisitor.visitVarInsn(25, paramContext.var("entity"));
  311. paramMethodVisitor.visitFieldInsn(180, ASMUtils.getType(paramFieldInfo.getDeclaringClass()), paramFieldInfo.getField().getName(), ASMUtils.getDesc(paramFieldInfo.getFieldClass()));
  312. }
  313. private void _if_write_null(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  314. {
  315. Class localClass = paramFieldInfo.getFieldClass();
  316. Label localLabel4 = new Label();
  317. Label localLabel1 = new Label();
  318. Label localLabel2 = new Label();
  319. Label localLabel3 = new Label();
  320. paramMethodVisitor.visitLabel(localLabel4);
  321. int i2 = 0;
  322. int n = 0;
  323. int i5 = 0;
  324. int j = 0;
  325. int i6 = 0;
  326. int i = 0;
  327. int i3 = 0;
  328. int k = 0;
  329. int i4 = 0;
  330. int m = 0;
  331. paramFieldInfo = (JSONField)paramFieldInfo.getAnnotation(JSONField.class);
  332. if (paramFieldInfo != null)
  333. {
  334. paramFieldInfo = paramFieldInfo.serialzeFeatures();
  335. int i7 = paramFieldInfo.length;
  336. int i1 = 0;
  337. i2 = n;
  338. i3 = k;
  339. i4 = m;
  340. i5 = j;
  341. i6 = i;
  342. if (i1 < i7)
  343. {
  344. localLabel4 = paramFieldInfo[i1];
  345. if (localLabel4 == SerializerFeature.WriteMapNullValue)
  346. {
  347. i2 = 1;
  348. i5 = i;
  349. i4 = j;
  350. i3 = k;
  351. }
  352. while (true)
  353. {
  354. i1 += 1;
  355. n = i2;
  356. k = i3;
  357. j = i4;
  358. i = i5;
  359. break;
  360. if (localLabel4 == SerializerFeature.WriteNullNumberAsZero)
  361. {
  362. i4 = 1;
  363. i2 = n;
  364. i3 = k;
  365. i5 = i;
  366. }
  367. else if (localLabel4 == SerializerFeature.WriteNullStringAsEmpty)
  368. {
  369. i5 = 1;
  370. i2 = n;
  371. i3 = k;
  372. i4 = j;
  373. }
  374. else if (localLabel4 == SerializerFeature.WriteNullBooleanAsFalse)
  375. {
  376. i3 = 1;
  377. i2 = n;
  378. i4 = j;
  379. i5 = i;
  380. }
  381. else
  382. {
  383. i2 = n;
  384. i3 = k;
  385. i4 = j;
  386. i5 = i;
  387. if (localLabel4 == SerializerFeature.WriteNullListAsEmpty)
  388. {
  389. m = 1;
  390. i2 = n;
  391. i3 = k;
  392. i4 = j;
  393. i5 = i;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. if (i2 == 0)
  400. {
  401. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  402. paramMethodVisitor.visitFieldInsn(178, ASMUtils.getType(SerializerFeature.class), "WriteMapNullValue", "L" + ASMUtils.getType(SerializerFeature.class) + ";");
  403. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "isEnabled", "(L" + ASMUtils.getType(SerializerFeature.class) + ";" + ")Z");
  404. paramMethodVisitor.visitJumpInsn(153, localLabel1);
  405. }
  406. paramMethodVisitor.visitLabel(localLabel2);
  407. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  408. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  409. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  410. if ((localClass == String.class) || (localClass == Character.class))
  411. if (i6 != 0)
  412. {
  413. paramMethodVisitor.visitLdcInsn("");
  414. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V");
  415. }
  416. while (true)
  417. {
  418. _seperator(paramMethodVisitor, paramContext);
  419. paramMethodVisitor.visitJumpInsn(167, localLabel3);
  420. paramMethodVisitor.visitLabel(localLabel1);
  421. paramMethodVisitor.visitLabel(localLabel3);
  422. return;
  423. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldNullString", "(CLjava/lang/String;)V");
  424. continue;
  425. if (Number.class.isAssignableFrom(localClass))
  426. {
  427. if (i5 != 0)
  428. {
  429. paramMethodVisitor.visitInsn(3);
  430. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V");
  431. }
  432. else
  433. {
  434. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldNullNumber", "(CLjava/lang/String;)V");
  435. }
  436. }
  437. else if (localClass == Boolean.class)
  438. {
  439. if (i3 != 0)
  440. {
  441. paramMethodVisitor.visitInsn(3);
  442. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Z)V");
  443. }
  444. else
  445. {
  446. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldNullBoolean", "(CLjava/lang/String;)V");
  447. }
  448. }
  449. else if ((Collection.class.isAssignableFrom(localClass)) || (localClass.isArray()))
  450. {
  451. if (i4 != 0)
  452. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldEmptyList", "(CLjava/lang/String;)V");
  453. else
  454. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldNullList", "(CLjava/lang/String;)V");
  455. }
  456. else
  457. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldNull", "(CLjava/lang/String;)V");
  458. }
  459. }
  460. private void _int(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  461. {
  462. paramClass = new Label();
  463. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  464. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  465. paramMethodVisitor.visitVarInsn(54, paramContext.var("int"));
  466. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  467. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  468. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  469. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  470. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  471. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V");
  472. _seperator(paramMethodVisitor, paramContext);
  473. paramMethodVisitor.visitLabel(paramClass);
  474. }
  475. private void _list(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  476. {
  477. paramClass = paramFieldInfo.getFieldType();
  478. if ((paramClass instanceof Class));
  479. Class localClass;
  480. for (paramClass = Object.class; ; paramClass = ((java.lang.reflect.ParameterizedType)paramClass).getActualTypeArguments()[0])
  481. {
  482. localClass = null;
  483. if ((paramClass instanceof Class))
  484. localClass = (Class)paramClass;
  485. Label localLabel1 = new Label();
  486. Label localLabel3 = new Label();
  487. Label localLabel4 = new Label();
  488. Label localLabel2 = new Label();
  489. paramMethodVisitor.visitLabel(localLabel3);
  490. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, localLabel1);
  491. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  492. paramMethodVisitor.visitTypeInsn(192, ASMUtils.getType(List.class));
  493. paramMethodVisitor.visitVarInsn(58, paramContext.var("list"));
  494. _filters(paramMethodVisitor, paramFieldInfo, paramContext, localLabel1);
  495. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  496. paramMethodVisitor.visitJumpInsn(199, localLabel4);
  497. _if_write_null(paramMethodVisitor, paramFieldInfo, paramContext);
  498. paramMethodVisitor.visitJumpInsn(167, localLabel2);
  499. paramMethodVisitor.visitLabel(localLabel4);
  500. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  501. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  502. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  503. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  504. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  505. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldName", "(Ljava/lang/String;)V");
  506. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  507. paramMethodVisitor.visitMethodInsn(185, ASMUtils.getType(List.class), "size", "()I");
  508. paramMethodVisitor.visitVarInsn(54, paramContext.var("int"));
  509. localLabel3 = new Label();
  510. localLabel4 = new Label();
  511. paramFieldInfo = new Label();
  512. paramMethodVisitor.visitLabel(localLabel3);
  513. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  514. paramMethodVisitor.visitInsn(3);
  515. paramMethodVisitor.visitJumpInsn(160, localLabel4);
  516. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  517. paramMethodVisitor.visitLdcInsn("[]");
  518. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(Ljava/lang/String;)V");
  519. paramMethodVisitor.visitJumpInsn(167, paramFieldInfo);
  520. paramMethodVisitor.visitLabel(localLabel4);
  521. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  522. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  523. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  524. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "setContext", "(Ljava/lang/Object;Ljava/lang/Object;)V");
  525. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  526. paramMethodVisitor.visitVarInsn(16, 91);
  527. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  528. paramMethodVisitor.visitInsn(1);
  529. paramMethodVisitor.visitTypeInsn(192, ASMUtils.getType(ObjectSerializer.class));
  530. paramMethodVisitor.visitVarInsn(58, paramContext.var("list_ser"));
  531. localLabel3 = new Label();
  532. localLabel4 = new Label();
  533. paramMethodVisitor.visitInsn(3);
  534. paramMethodVisitor.visitVarInsn(54, paramContext.var("i"));
  535. paramMethodVisitor.visitLabel(localLabel3);
  536. paramMethodVisitor.visitVarInsn(21, paramContext.var("i"));
  537. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  538. paramMethodVisitor.visitInsn(4);
  539. paramMethodVisitor.visitInsn(100);
  540. paramMethodVisitor.visitJumpInsn(162, localLabel4);
  541. if (paramClass != String.class)
  542. break;
  543. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  544. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  545. paramMethodVisitor.visitVarInsn(21, paramContext.var("i"));
  546. paramMethodVisitor.visitMethodInsn(185, ASMUtils.getType(List.class), "get", "(I)Ljava/lang/Object;");
  547. paramMethodVisitor.visitTypeInsn(192, ASMUtils.getType(String.class));
  548. paramMethodVisitor.visitVarInsn(16, 44);
  549. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeString", "(Ljava/lang/String;C)V");
  550. paramMethodVisitor.visitIincInsn(paramContext.var("i"), 1);
  551. paramMethodVisitor.visitJumpInsn(167, localLabel3);
  552. paramMethodVisitor.visitLabel(localLabel4);
  553. if (paramClass != String.class)
  554. break label1298;
  555. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  556. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  557. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  558. paramMethodVisitor.visitInsn(4);
  559. paramMethodVisitor.visitInsn(100);
  560. paramMethodVisitor.visitMethodInsn(185, ASMUtils.getType(List.class), "get", "(I)Ljava/lang/Object;");
  561. paramMethodVisitor.visitTypeInsn(192, ASMUtils.getType(String.class));
  562. paramMethodVisitor.visitVarInsn(16, 93);
  563. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeString", "(Ljava/lang/String;C)V");
  564. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  565. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "popContext", "()V");
  566. paramMethodVisitor.visitLabel(paramFieldInfo);
  567. _seperator(paramMethodVisitor, paramContext);
  568. paramMethodVisitor.visitLabel(localLabel2);
  569. paramMethodVisitor.visitLabel(localLabel1);
  570. return;
  571. }
  572. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  573. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  574. paramMethodVisitor.visitVarInsn(21, paramContext.var("i"));
  575. paramMethodVisitor.visitMethodInsn(185, ASMUtils.getType(List.class), "get", "(I)Ljava/lang/Object;");
  576. paramMethodVisitor.visitVarInsn(21, paramContext.var("i"));
  577. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Integer.class), "valueOf", "(I)Ljava/lang/Integer;");
  578. if ((localClass != null) && (Modifier.isPublic(localClass.getModifiers())))
  579. {
  580. paramMethodVisitor.visitLdcInsn(Type.getType(ASMUtils.getDesc((Class)paramClass)));
  581. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V");
  582. }
  583. while (true)
  584. {
  585. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  586. paramMethodVisitor.visitVarInsn(16, 44);
  587. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  588. break;
  589. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;)V");
  590. }
  591. label1298: paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  592. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  593. paramMethodVisitor.visitVarInsn(21, paramContext.var("i"));
  594. paramMethodVisitor.visitMethodInsn(185, ASMUtils.getType(List.class), "get", "(I)Ljava/lang/Object;");
  595. paramMethodVisitor.visitVarInsn(21, paramContext.var("i"));
  596. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Integer.class), "valueOf", "(I)Ljava/lang/Integer;");
  597. if ((localClass != null) && (Modifier.isPublic(localClass.getModifiers())))
  598. {
  599. paramMethodVisitor.visitLdcInsn(Type.getType(ASMUtils.getDesc((Class)paramClass)));
  600. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V");
  601. }
  602. while (true)
  603. {
  604. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  605. paramMethodVisitor.visitVarInsn(16, 93);
  606. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  607. break;
  608. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;)V");
  609. }
  610. }
  611. private void _long(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  612. {
  613. paramClass = new Label();
  614. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  615. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  616. paramMethodVisitor.visitVarInsn(55, paramContext.var("long", 2));
  617. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  618. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  619. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  620. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  621. paramMethodVisitor.visitVarInsn(22, paramContext.var("long", 2));
  622. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;J)V");
  623. _seperator(paramMethodVisitor, paramContext);
  624. paramMethodVisitor.visitLabel(paramClass);
  625. }
  626. private void _nameApply(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext, Label paramLabel)
  627. {
  628. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  629. paramMethodVisitor.visitVarInsn(25, paramContext.obj());
  630. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  631. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "applyName", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;)Z");
  632. paramMethodVisitor.visitJumpInsn(153, paramLabel);
  633. }
  634. private void _object(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  635. {
  636. paramClass = new Label();
  637. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  638. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  639. paramMethodVisitor.visitVarInsn(58, paramContext.var("object"));
  640. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  641. _writeObject(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  642. paramMethodVisitor.visitLabel(paramClass);
  643. }
  644. private void _processKey(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  645. {
  646. paramFieldInfo = paramFieldInfo.getFieldClass();
  647. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  648. paramMethodVisitor.visitVarInsn(25, paramContext.obj());
  649. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  650. if (paramFieldInfo == Byte.TYPE)
  651. {
  652. paramMethodVisitor.visitVarInsn(21, paramContext.var("byte"));
  653. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;B)Ljava/lang/String;");
  654. }
  655. while (true)
  656. {
  657. paramMethodVisitor.visitVarInsn(58, paramContext.fieldName());
  658. return;
  659. if (paramFieldInfo == Short.TYPE)
  660. {
  661. paramMethodVisitor.visitVarInsn(21, paramContext.var("short"));
  662. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;S)Ljava/lang/String;");
  663. }
  664. else if (paramFieldInfo == Integer.TYPE)
  665. {
  666. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  667. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;I)Ljava/lang/String;");
  668. }
  669. else if (paramFieldInfo == Character.TYPE)
  670. {
  671. paramMethodVisitor.visitVarInsn(21, paramContext.var("char"));
  672. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;C)Ljava/lang/String;");
  673. }
  674. else if (paramFieldInfo == Long.TYPE)
  675. {
  676. paramMethodVisitor.visitVarInsn(22, paramContext.var("long", 2));
  677. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;J)Ljava/lang/String;");
  678. }
  679. else if (paramFieldInfo == Float.TYPE)
  680. {
  681. paramMethodVisitor.visitVarInsn(23, paramContext.var("float"));
  682. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;F)Ljava/lang/String;");
  683. }
  684. else if (paramFieldInfo == Double.TYPE)
  685. {
  686. paramMethodVisitor.visitVarInsn(24, paramContext.var("double", 2));
  687. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;D)Ljava/lang/String;");
  688. }
  689. else if (paramFieldInfo == Boolean.TYPE)
  690. {
  691. paramMethodVisitor.visitVarInsn(21, paramContext.var("boolean"));
  692. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Z)Ljava/lang/String;");
  693. }
  694. else if (paramFieldInfo == BigDecimal.class)
  695. {
  696. paramMethodVisitor.visitVarInsn(25, paramContext.var("decimal"));
  697. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
  698. }
  699. else if (paramFieldInfo == String.class)
  700. {
  701. paramMethodVisitor.visitVarInsn(25, paramContext.var("string"));
  702. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
  703. }
  704. else if (paramFieldInfo.isEnum())
  705. {
  706. paramMethodVisitor.visitVarInsn(25, paramContext.var("enum"));
  707. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
  708. }
  709. else if (List.class.isAssignableFrom(paramFieldInfo))
  710. {
  711. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  712. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
  713. }
  714. else
  715. {
  716. paramMethodVisitor.visitVarInsn(25, paramContext.var("object"));
  717. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
  718. }
  719. }
  720. }
  721. private void _processValue(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  722. {
  723. paramFieldInfo = paramFieldInfo.getFieldClass();
  724. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  725. paramMethodVisitor.visitVarInsn(25, paramContext.obj());
  726. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  727. if (paramFieldInfo == Byte.TYPE)
  728. {
  729. paramMethodVisitor.visitVarInsn(21, paramContext.var("byte"));
  730. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Byte.class), "valueOf", "(B)Ljava/lang/Byte;");
  731. }
  732. while (true)
  733. {
  734. paramMethodVisitor.visitVarInsn(58, paramContext.original());
  735. paramMethodVisitor.visitVarInsn(25, paramContext.original());
  736. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(FilterUtils.class), "processValue", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
  737. paramMethodVisitor.visitVarInsn(58, paramContext.processValue());
  738. return;
  739. if (paramFieldInfo == Short.TYPE)
  740. {
  741. paramMethodVisitor.visitVarInsn(21, paramContext.var("short"));
  742. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Short.class), "valueOf", "(S)Ljava/lang/Short;");
  743. }
  744. else if (paramFieldInfo == Integer.TYPE)
  745. {
  746. paramMethodVisitor.visitVarInsn(21, paramContext.var("int"));
  747. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Integer.class), "valueOf", "(I)Ljava/lang/Integer;");
  748. }
  749. else if (paramFieldInfo == Character.TYPE)
  750. {
  751. paramMethodVisitor.visitVarInsn(21, paramContext.var("char"));
  752. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Character.class), "valueOf", "(C)Ljava/lang/Character;");
  753. }
  754. else if (paramFieldInfo == Long.TYPE)
  755. {
  756. paramMethodVisitor.visitVarInsn(22, paramContext.var("long", 2));
  757. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Long.class), "valueOf", "(J)Ljava/lang/Long;");
  758. }
  759. else if (paramFieldInfo == Float.TYPE)
  760. {
  761. paramMethodVisitor.visitVarInsn(23, paramContext.var("float"));
  762. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Float.class), "valueOf", "(F)Ljava/lang/Float;");
  763. }
  764. else if (paramFieldInfo == Double.TYPE)
  765. {
  766. paramMethodVisitor.visitVarInsn(24, paramContext.var("double", 2));
  767. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Double.class), "valueOf", "(D)Ljava/lang/Double;");
  768. }
  769. else if (paramFieldInfo == Boolean.TYPE)
  770. {
  771. paramMethodVisitor.visitVarInsn(21, paramContext.var("boolean"));
  772. paramMethodVisitor.visitMethodInsn(184, ASMUtils.getType(Boolean.class), "valueOf", "(Z)Ljava/lang/Boolean;");
  773. }
  774. else if (paramFieldInfo == BigDecimal.class)
  775. {
  776. paramMethodVisitor.visitVarInsn(25, paramContext.var("decimal"));
  777. }
  778. else if (paramFieldInfo == String.class)
  779. {
  780. paramMethodVisitor.visitVarInsn(25, paramContext.var("string"));
  781. }
  782. else if (paramFieldInfo.isEnum())
  783. {
  784. paramMethodVisitor.visitVarInsn(25, paramContext.var("enum"));
  785. }
  786. else if (List.class.isAssignableFrom(paramFieldInfo))
  787. {
  788. paramMethodVisitor.visitVarInsn(25, paramContext.var("list"));
  789. }
  790. else
  791. {
  792. paramMethodVisitor.visitVarInsn(25, paramContext.var("object"));
  793. }
  794. }
  795. }
  796. private void _seperator(MethodVisitor paramMethodVisitor, Context paramContext)
  797. {
  798. paramMethodVisitor.visitVarInsn(16, 44);
  799. paramMethodVisitor.visitVarInsn(54, paramContext.var("seperator"));
  800. }
  801. private void _short(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  802. {
  803. paramClass = new Label();
  804. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  805. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  806. paramMethodVisitor.visitVarInsn(54, paramContext.var("short"));
  807. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  808. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  809. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  810. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  811. paramMethodVisitor.visitVarInsn(21, paramContext.var("short"));
  812. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V");
  813. _seperator(paramMethodVisitor, paramContext);
  814. paramMethodVisitor.visitLabel(paramClass);
  815. }
  816. private void _string(Class<?> paramClass, MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext)
  817. {
  818. paramClass = new Label();
  819. _nameApply(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  820. _get(paramMethodVisitor, paramContext, paramFieldInfo);
  821. paramMethodVisitor.visitVarInsn(58, paramContext.var("string"));
  822. _filters(paramMethodVisitor, paramFieldInfo, paramContext, paramClass);
  823. Label localLabel1 = new Label();
  824. Label localLabel2 = new Label();
  825. paramMethodVisitor.visitVarInsn(25, paramContext.var("string"));
  826. paramMethodVisitor.visitJumpInsn(199, localLabel1);
  827. _if_write_null(paramMethodVisitor, paramFieldInfo, paramContext);
  828. paramMethodVisitor.visitJumpInsn(167, localLabel2);
  829. paramMethodVisitor.visitLabel(localLabel1);
  830. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  831. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  832. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  833. paramMethodVisitor.visitVarInsn(25, paramContext.var("string"));
  834. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V");
  835. _seperator(paramMethodVisitor, paramContext);
  836. paramMethodVisitor.visitLabel(localLabel2);
  837. paramMethodVisitor.visitLabel(paramClass);
  838. }
  839. private void _writeObject(MethodVisitor paramMethodVisitor, FieldInfo paramFieldInfo, Context paramContext, Label paramLabel)
  840. {
  841. String str = paramFieldInfo.getFormat();
  842. Label localLabel = new Label();
  843. paramMethodVisitor.visitVarInsn(25, paramContext.processValue());
  844. paramMethodVisitor.visitJumpInsn(199, localLabel);
  845. _if_write_null(paramMethodVisitor, paramFieldInfo, paramContext);
  846. paramMethodVisitor.visitJumpInsn(167, paramLabel);
  847. paramMethodVisitor.visitLabel(localLabel);
  848. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  849. paramMethodVisitor.visitVarInsn(21, paramContext.var("seperator"));
  850. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  851. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  852. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  853. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFieldName", "(Ljava/lang/String;)V");
  854. paramMethodVisitor.visitVarInsn(25, paramContext.serializer());
  855. paramMethodVisitor.visitVarInsn(25, paramContext.processValue());
  856. if (str != null)
  857. {
  858. paramMethodVisitor.visitLdcInsn(str);
  859. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFormat", "(Ljava/lang/Object;Ljava/lang/String;)V");
  860. }
  861. while (true)
  862. {
  863. _seperator(paramMethodVisitor, paramContext);
  864. return;
  865. paramMethodVisitor.visitVarInsn(25, paramContext.fieldName());
  866. if (((paramFieldInfo.getFieldType() instanceof Class)) && (((Class)paramFieldInfo.getFieldType()).isPrimitive()))
  867. {
  868. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;)V");
  869. }
  870. else
  871. {
  872. paramMethodVisitor.visitVarInsn(25, 0);
  873. paramMethodVisitor.visitFieldInsn(180, paramContext.getClassName(), paramFieldInfo.getName() + "_asm_fieldType", "Ljava/lang/reflect/Type;");
  874. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(JSONSerializer.class), "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V");
  875. }
  876. }
  877. }
  878. private void generateWriteAsArray(Class<?> paramClass, MethodVisitor paramMethodVisitor, List<FieldInfo> paramList, Context paramContext)
  879. throws Exception
  880. {
  881. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  882. paramMethodVisitor.visitVarInsn(16, 91);
  883. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  884. int k = paramList.size();
  885. if (k == 0)
  886. {
  887. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  888. paramMethodVisitor.visitVarInsn(16, 93);
  889. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "write", "(C)V");
  890. return;
  891. }
  892. int i = 0;
  893. label107: int j;
  894. if (i < k)
  895. {
  896. if (i != k - 1)
  897. break label254;
  898. j = 93;
  899. label127: paramClass = (FieldInfo)paramList.get(i);
  900. localObject = paramClass.getFieldClass();
  901. paramMethodVisitor.visitLdcInsn(paramClass.getName());
  902. paramMethodVisitor.visitVarInsn(58, paramContext.fieldName());
  903. if ((localObject != Byte.TYPE) && (localObject != Short.TYPE) && (localObject != Integer.TYPE))
  904. break label261;
  905. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  906. _get(paramMethodVisitor, paramContext, paramClass);
  907. paramMethodVisitor.visitVarInsn(16, j);
  908. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeIntAndChar", "(IC)V");
  909. }
  910. while (true)
  911. {
  912. i += 1;
  913. break label107;
  914. break;
  915. label254: j = 44;
  916. break label127;
  917. label261: if (localObject == Long.TYPE)
  918. {
  919. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  920. _get(paramMethodVisitor, paramContext, paramClass);
  921. paramMethodVisitor.visitVarInsn(16, j);
  922. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeLongAndChar", "(JC)V");
  923. }
  924. else if (localObject == Float.TYPE)
  925. {
  926. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  927. _get(paramMethodVisitor, paramContext, paramClass);
  928. paramMethodVisitor.visitVarInsn(16, j);
  929. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeFloatAndChar", "(FC)V");
  930. }
  931. else if (localObject == Double.TYPE)
  932. {
  933. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  934. _get(paramMethodVisitor, paramContext, paramClass);
  935. paramMethodVisitor.visitVarInsn(16, j);
  936. paramMethodVisitor.visitMethodInsn(182, ASMUtils.getType(SerializeWriter.class), "writeDoubleAndChar", "(DC)V");
  937. }
  938. else if (localObject == Boolean.TYPE)
  939. {
  940. paramMethodVisitor.visitVarInsn(25, paramContext.var("out"));
  941. _get(paramMethodVisitor, paramContext, paramClass);
  942. paramMethodVisitor.visitVarInsn(1

Large files files are truncated, but you can click here to view the full file