private void _batchSet(Context context, MethodVisitor mw, boolean flag) { for (int i = 0, size = context.fieldInfoList.length; i < size; ++i) { Label notSet_ = new Label(); if (flag) { _isFlag(mw, context, i, notSet_); } FieldInfo fieldInfo = context.fieldInfoList[i]; _loadAndSet(context, mw, fieldInfo); if (flag) { mw.visitLabel(notSet_); } } }
private void _getCollectionFieldItemDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> itemType) { Label notNull_ = new Label(); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_list_item_deser__", desc(ObjectDeserializer.class)); mw.visitJumpInsn(IFNONNULL, notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitVarInsn(ALOAD, 1); mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getConfig", "()" + desc(ParserConfig.class)); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(desc(itemType))); mw.visitMethodInsn(INVOKEVIRTUAL, type(ParserConfig.class), "getDeserializer", "(Ljava/lang/reflect/Type;)" + desc(ObjectDeserializer.class)); mw.visitFieldInsn(PUTFIELD, context.className, fieldInfo.name + "_asm_list_item_deser__", desc(ObjectDeserializer.class)); mw.visitLabel(notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_list_item_deser__", desc(ObjectDeserializer.class)); }
private void _getFieldDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo) { Label notNull_ = new Label(); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_deser__", desc(ObjectDeserializer.class)); mw.visitJumpInsn(IFNONNULL, notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitVarInsn(ALOAD, 1); mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getConfig", "()" + desc(ParserConfig.class)); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(desc(fieldInfo.fieldClass))); mw.visitMethodInsn(INVOKEVIRTUAL, type(ParserConfig.class), "getDeserializer", "(Ljava/lang/reflect/Type;)" + desc(ObjectDeserializer.class)); mw.visitFieldInsn(PUTFIELD, context.className, fieldInfo.name + "_asm_deser__", desc(ObjectDeserializer.class)); mw.visitLabel(notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_deser__", desc(ObjectDeserializer.class)); }
private void _decimal(Class<?> cls, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(58, context.var("decimal")); _filters(mw, property, context, _end); Label _if = new Label(); Label _else = new Label(); Label _end_if = new Label(); mw.visitLabel(_if); mw.visitVarInsn(25, context.var("decimal")); mw.visitJumpInsn(199, _else); _if_write_null(mw, property, context); mw.visitJumpInsn(167, _end_if); mw.visitLabel(_else); mw.visitVarInsn(25, context.var("out")); mw.visitVarInsn(21, context.var("seperator")); mw.visitVarInsn(25, context.fieldName()); mw.visitVarInsn(25, context.var("decimal")); mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/math/BigDecimal;)V"); _seperator(mw, context); mw.visitJumpInsn(167, _end_if); mw.visitLabel(_end_if); mw.visitLabel(_end); }
private void _string(Class<?> cls, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(58, context.var("string")); _filters(mw, property, context, _end); Label _else = new Label(); Label _end_if = new Label(); mw.visitVarInsn(25, context.var("string")); mw.visitJumpInsn(199, _else); _if_write_null(mw, property, context); mw.visitJumpInsn(167, _end_if); mw.visitLabel(_else); mw.visitVarInsn(25, context.var("out")); mw.visitVarInsn(21, context.var("seperator")); mw.visitVarInsn(25, context.fieldName()); mw.visitVarInsn(25, context.var("string")); mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V"); _seperator(mw, context); mw.visitLabel(_end_if); mw.visitLabel(_end); }
private void _filters(MethodVisitor mw, FieldInfo property, Context context, Label _end) { if (property.getField() != null && Modifier.isTransient(property.getField().getModifiers())) { mw.visitVarInsn(25, context.var("out")); mw.visitFieldInsn(178, "com/alibaba/fastjson/serializer/SerializerFeature", "SkipTransientField", "Lcom/alibaba/fastjson/serializer/SerializerFeature;"); mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "isEnabled", "(Lcom/alibaba/fastjson/serializer/SerializerFeature;)Z"); mw.visitJumpInsn(154, _end); } _notWriteDefault(mw, property, context, _end); _apply(mw, property, context); mw.visitJumpInsn(153, _end); _processKey(mw, property, context); Label _else_processKey = new Label(); _processValue(mw, property, context); mw.visitVarInsn(25, context.original()); mw.visitVarInsn(25, context.processValue()); mw.visitJumpInsn(165, _else_processKey); _writeObject(mw, property, context, _end); mw.visitJumpInsn(167, _end); mw.visitLabel(_else_processKey); }
private void _batchSet(Context context, MethodVisitor mw, boolean flag) { for (int i = 0, size = context.getFieldInfoList().size(); i < size; ++i) { Label notSet_ = new Label(); if (flag) { _isFlag(mw, context, i, notSet_); } FieldInfo fieldInfo = context.getFieldInfoList().get(i); _loadAndSet(context, mw, fieldInfo); if (flag) { mw.visitLabel(notSet_); } } }
private void _setContext(Context context, MethodVisitor mw) { mw.visitVarInsn(ALOAD, 1); // parser mw.visitVarInsn(ALOAD, context.var("context")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/DefaultJSONParser", "setContext", "(Lcom/alibaba/fastjson/parser/ParseContext;)V"); Label endIf_ = new Label(); mw.visitVarInsn(ALOAD, context.var("childContext")); mw.visitJumpInsn(IFNULL, endIf_); mw.visitVarInsn(ALOAD, context.var("childContext")); mw.visitVarInsn(ALOAD, context.var("instance")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/ParseContext", "setObject", "(Ljava/lang/Object;)V"); mw.visitLabel(endIf_); }
private void _deserialize_endCheck(Context context, MethodVisitor mw, Label reset_) { // Label nextToken_ = new Label(); // mw.visitFieldInsn(GETSTATIC, getType(System.class), "out", "Ljava/io/PrintStream;"); // mw.visitIntInsn(ILOAD, context.var("matchedCount")); // mw.visitMethodInsn(INVOKEVIRTUAL, getType(java.io.PrintStream.class), "println", "(I)V"); mw.visitIntInsn(ILOAD, context.var("matchedCount")); mw.visitJumpInsn(IFLE, reset_); // mw.visitFieldInsn(GETSTATIC, getType(System.class), "out", "Ljava/io/PrintStream;"); // mw.visitVarInsn(ALOAD, context.var("lexer")); // mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/JSONLexerBase", "token", "()I"); // mw.visitMethodInsn(INVOKEVIRTUAL, getType(java.io.PrintStream.class), "println", "(I)V"); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/JSONLexerBase", "token", "()I"); mw.visitFieldInsn(GETSTATIC, "com/alibaba/fastjson/parser/JSONToken", "RBRACE", "I"); mw.visitJumpInsn(IF_ICMPNE, reset_); // mw.visitLabel(nextToken_); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitFieldInsn(GETSTATIC, "com/alibaba/fastjson/parser/JSONToken", "COMMA", "I"); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/JSONLexerBase", "nextToken", "(I)V"); }
private void _getCollectionFieldItemDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> itemType) { Label notNull_ = new Label(); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitJumpInsn(IFNONNULL, notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitVarInsn(ALOAD, 1); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/DefaultJSONParser", "getConfig", "()" + "Lcom/alibaba/fastjson/parser/ParserConfig;"); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(getDesc(itemType))); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/ParserConfig", "getDeserializer", "(Ljava/lang/reflect/Type;)Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitFieldInsn(PUTFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitLabel(notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); }
private void _getFieldDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo) { Label notNull_ = new Label(); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitJumpInsn(IFNONNULL, notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitVarInsn(ALOAD, 1); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/DefaultJSONParser", "getConfig", "()" + "Lcom/alibaba/fastjson/parser/ParserConfig;"); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(getDesc(fieldInfo.getFieldClass()))); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/ParserConfig", "getDeserializer", "(Ljava/lang/reflect/Type;)Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitFieldInsn(PUTFIELD, context.getClassName(), fieldInfo.getName() + "_asm_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitLabel(notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); }
private void _long(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(LSTORE, context.var("long", 2)); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(LLOAD, context.var("long", 2)); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;J)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _float(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(FSTORE, context.var("float")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(FLOAD, context.var("float")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;F)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _double(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(DSTORE, context.var("double", 2)); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(DLOAD, context.var("double", 2)); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;D)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _char(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("char")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("char")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;C)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _boolean(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("boolean")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("boolean")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Z)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _byte(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("byte")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("byte")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _short(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("short")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("short")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _int(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("int")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("int")); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _setContext(Context context, MethodVisitor mw) { mw.visitVarInsn(ALOAD, 1); // parser mw.visitVarInsn(ALOAD, context.var("context")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "setContext", "(" + ASMUtils.getDesc(ParseContext.class) + ")V"); Label endIf_ = new Label(); mw.visitVarInsn(ALOAD, context.var("childContext")); mw.visitJumpInsn(IFNULL, endIf_); mw.visitVarInsn(ALOAD, context.var("childContext")); mw.visitVarInsn(ALOAD, context.var("instance")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(ParseContext.class), "setObject", "(Ljava/lang/Object;)V"); mw.visitLabel(endIf_); }
private void _getCollectionFieldItemDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> itemType) { Label notNull_ = new Label(); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", getDesc(ObjectDeserializer.class)); mw.visitJumpInsn(IFNONNULL, notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitVarInsn(ALOAD, 1); mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "getConfig", "()" + getDesc(ParserConfig.class)); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(getDesc(itemType))); mw.visitMethodInsn(INVOKEVIRTUAL, getType(ParserConfig.class), "getDeserializer", "(" + getDesc(Type.class) + ")" + getDesc(ObjectDeserializer.class)); mw.visitFieldInsn(PUTFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", getDesc(ObjectDeserializer.class)); mw.visitLabel(notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", getDesc(ObjectDeserializer.class)); }
private void _getFieldDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo) { Label notNull_ = new Label(); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_deser__", getDesc(ObjectDeserializer.class)); mw.visitJumpInsn(IFNONNULL, notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitVarInsn(ALOAD, 1); mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "getConfig", "()" + getDesc(ParserConfig.class)); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(getDesc(fieldInfo.getFieldClass()))); mw.visitMethodInsn(INVOKEVIRTUAL, getType(ParserConfig.class), "getDeserializer", "(" + getDesc(Type.class) + ")" + getDesc(ObjectDeserializer.class)); mw.visitFieldInsn(PUTFIELD, context.getClassName(), fieldInfo.getName() + "_asm_deser__", getDesc(ObjectDeserializer.class)); mw.visitLabel(notNull_); mw.visitVarInsn(ALOAD, 0); mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_deser__", getDesc(ObjectDeserializer.class)); }
private void _long(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(LSTORE, context.var("long", 2)); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(LLOAD, context.var("long", 2)); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;J)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _float(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(FSTORE, context.var("float")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(FLOAD, context.var("float")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;F)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _double(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(DSTORE, context.var("double", 2)); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(DLOAD, context.var("double", 2)); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;D)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _char(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("char")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("char")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;C)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _boolean(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("boolean")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("boolean")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;Z)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _byte(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("byte")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("byte")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _short(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("short")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("short")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _int(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitVarInsn(ISTORE, context.var("int")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ILOAD, context.var("int")); mw.visitMethodInsn(INVOKEVIRTUAL, getType(SerializeWriter.class), "writeFieldValue", "(CLjava/lang/String;I)V"); _seperator(mw, context); mw.visitLabel(_end); }
private void _isFlag(MethodVisitor mw, Context context, int i, Label label) { mw.visitVarInsn(ILOAD, context.var("_asm_flag_" + (i / 32))); mw.visitLdcInsn(1 << i); mw.visitInsn(IAND); mw.visitJumpInsn(IFEQ, label); }
private void _setContext(Context context, MethodVisitor mw) { mw.visitVarInsn(ALOAD, 1); // parser mw.visitVarInsn(ALOAD, context.var("context")); mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "setContext", "(" + desc(ParseContext.class) + ")V"); Label endIf_ = new Label(); mw.visitVarInsn(ALOAD, context.var("childContext")); mw.visitJumpInsn(IFNULL, endIf_); mw.visitVarInsn(ALOAD, context.var("childContext")); mw.visitVarInsn(ALOAD, context.var("instance")); mw.visitFieldInsn(PUTFIELD, type(ParseContext.class), "object", "Ljava/lang/Object;"); mw.visitLabel(endIf_); }
private void _deserialize_endCheck(Context context, MethodVisitor mw, Label reset_) { mw.visitIntInsn(ILOAD, context.var("matchedCount")); mw.visitJumpInsn(IFLE, reset_); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "token", "()I"); mw.visitLdcInsn(JSONToken.RBRACE); mw.visitJumpInsn(IF_ICMPNE, reset_); // mw.visitLabel(nextToken_); _quickNextTokenComma(context, mw); }
private void _quickNextToken(Context context, MethodVisitor mw, int token) { Label quickElse_ = new Label(), quickEnd_ = new Label(); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "getCurrent", "()C"); if (token == JSONToken.LBRACE) { mw.visitVarInsn(BIPUSH, '{'); } else if (token == JSONToken.LBRACKET) { mw.visitVarInsn(BIPUSH, '['); } else { throw new IllegalStateException(); } mw.visitJumpInsn(IF_ICMPNE, quickElse_); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "next", "()C"); mw.visitInsn(POP); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitLdcInsn(token); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "setToken", "(I)V"); mw.visitJumpInsn(GOTO, quickEnd_); mw.visitLabel(quickElse_); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitLdcInsn(token); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "nextToken", "(I)V"); mw.visitLabel(quickEnd_); }
private void _batchSet(Context context, MethodVisitor mw, boolean flag) { int size = context.getFieldInfoList().size(); for (int i = 0; i < size; i++) { Label notSet_ = new Label(); if (flag) { _isFlag(mw, context, i, notSet_); } _loadAndSet(context, mw, (FieldInfo) context.getFieldInfoList().get(i)); if (flag) { mw.visitLabel(notSet_); } } }
private void _setContext(Context context, MethodVisitor mw) { mw.visitVarInsn(25, 1); mw.visitVarInsn(25, context.var("context")); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser", "setContext", "(Lcom/alibaba/fastjson/parser/ParseContext;)V"); Label endIf_ = new Label(); mw.visitVarInsn(25, context.var("childContext")); mw.visitJumpInsn(198, endIf_); mw.visitVarInsn(25, context.var("childContext")); mw.visitVarInsn(25, context.var("instance")); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/ParseContext", "setObject", "(Ljava/lang/Object;)V"); mw.visitLabel(endIf_); }
private void _deserialize_endCheck(Context context, MethodVisitor mw, Label reset_) { Label _end_if = new Label(); mw.visitIntInsn(21, context.var("matchedCount")); mw.visitJumpInsn(158, reset_); mw.visitVarInsn(25, context.var("lexer")); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/JSONLexerBase", "token", "()I"); mw.visitFieldInsn(178, "com/alibaba/fastjson/parser/JSONToken", "RBRACE", "I"); mw.visitJumpInsn(160, reset_); mw.visitVarInsn(25, context.var("lexer")); mw.visitFieldInsn(178, "com/alibaba/fastjson/parser/JSONToken", "COMMA", "I"); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/JSONLexerBase", "nextToken", "(I)V"); mw.visitLabel(_end_if); }
private void _getCollectionFieldItemDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> itemType) { Label notNull_ = new Label(); mw.visitVarInsn(25, 0); mw.visitFieldInsn(180, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitJumpInsn(199, notNull_); mw.visitVarInsn(25, 0); mw.visitVarInsn(25, 1); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser", "getConfig", "()Lcom/alibaba/fastjson/parser/ParserConfig;"); mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(ASMUtils.getDesc((Class) itemType))); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/ParserConfig", "getDeserializer", "(Ljava/lang/reflect/Type;)Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitFieldInsn(181, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); mw.visitLabel(notNull_); mw.visitVarInsn(25, 0); mw.visitFieldInsn(180, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__", "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;"); }
private void _deserialze_obj(Context context, MethodVisitor mw, Label reset_, FieldInfo fieldInfo, Class<?> fieldClass, int i) { Label matched_ = new Label(); Label _end_if = new Label(); mw.visitVarInsn(25, context.var("lexer")); mw.visitVarInsn(25, 0); mw.visitFieldInsn(180, context.getClassName(), fieldInfo.getName() + "_asm_prefix__", "[C"); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/JSONLexerBase", "matchField", "([C)Z"); mw.visitJumpInsn(154, matched_); mw.visitInsn(1); mw.visitVarInsn(58, context.var(fieldInfo.getName() + "_asm")); mw.visitJumpInsn(167, _end_if); mw.visitLabel(matched_); _setFlag(mw, context, i); mw.visitVarInsn(21, context.var("matchedCount")); mw.visitInsn(4); mw.visitInsn(96); mw.visitVarInsn(54, context.var("matchedCount")); _deserObject(context, mw, fieldInfo, fieldClass); mw.visitVarInsn(25, 1); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser", "getResolveStatus", "()I"); mw.visitFieldInsn(178, "com/alibaba/fastjson/parser/DefaultJSONParser", "NeedToResolve", "I"); mw.visitJumpInsn(160, _end_if); mw.visitVarInsn(25, 1); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser", "getLastResolveTask", "()Lcom/alibaba/fastjson/parser/DefaultJSONParser$ResolveTask;"); mw.visitVarInsn(58, context.var("resolveTask")); mw.visitVarInsn(25, context.var("resolveTask")); mw.visitVarInsn(25, 1); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser", "getContext", "()Lcom/alibaba/fastjson/parser/ParseContext;"); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser$ResolveTask", "setOwnerContext", "(Lcom/alibaba/fastjson/parser/ParseContext;)V"); mw.visitVarInsn(25, context.var("resolveTask")); mw.visitVarInsn(25, 0); mw.visitLdcInsn(fieldInfo.getName()); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/deserializer/ASMJavaBeanDeserializer", "getFieldDeserializer", "(Ljava/lang/String;)Lcom/alibaba/fastjson/parser/deserializer/FieldDeserializer;"); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser$ResolveTask", "setFieldDeserializer", "(Lcom/alibaba/fastjson/parser/deserializer/FieldDeserializer;)V"); mw.visitVarInsn(25, 1); mw.visitFieldInsn(178, "com/alibaba/fastjson/parser/DefaultJSONParser", "NONE", "I"); mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/DefaultJSONParser", "setResolveStatus", "(I)V"); mw.visitLabel(_end_if); }