mirror of https://github.com/goccy/go-json.git
Refactor encoding of marshaler and structEnd
This commit is contained in:
parent
287d5f97a1
commit
fc968c75ee
|
@ -390,7 +390,7 @@ func AppendMarshalJSON(ctx *RuntimeContext, code *Opcode, b []byte, v interface{
|
|||
return compactedBuf, nil
|
||||
}
|
||||
|
||||
func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}, indent int, escape bool) ([]byte, error) {
|
||||
func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}, escape bool) ([]byte, error) {
|
||||
rv := reflect.ValueOf(v) // convert by dynamic interface type
|
||||
if code.AddrForMarshaler {
|
||||
if rv.CanAddr() {
|
||||
|
@ -415,7 +415,7 @@ func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v inte
|
|||
indentedBuf, err := doIndent(
|
||||
b,
|
||||
marshalBuf,
|
||||
string(ctx.Prefix)+strings.Repeat(string(ctx.IndentStr), ctx.BaseIndent+indent),
|
||||
string(ctx.Prefix)+strings.Repeat(string(ctx.IndentStr), ctx.BaseIndent+code.Indent),
|
||||
string(ctx.IndentStr),
|
||||
escape,
|
||||
)
|
||||
|
@ -494,10 +494,10 @@ func AppendStructEnd(b []byte) []byte {
|
|||
return append(b, '}', ',')
|
||||
}
|
||||
|
||||
func AppendStructEndIndent(ctx *RuntimeContext, b []byte, indent int) []byte {
|
||||
func AppendStructEndIndent(ctx *RuntimeContext, code *Opcode, b []byte) []byte {
|
||||
b = append(b, '\n')
|
||||
b = append(b, ctx.Prefix...)
|
||||
indentNum := ctx.BaseIndent + indent
|
||||
indentNum := ctx.BaseIndent + code.Indent - 1
|
||||
for i := 0; i < indentNum; i++ {
|
||||
b = append(b, ctx.IndentStr...)
|
||||
}
|
||||
|
|
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',')
|
||||
}
|
||||
|
||||
func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalJSON(ctx, code, b, v, false)
|
||||
}
|
||||
|
||||
func appendMarshalText(code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalText(code, b, v, false)
|
||||
}
|
||||
|
||||
func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, code.Key...)
|
||||
}
|
||||
|
@ -84,15 +92,15 @@ func appendStructHead(b []byte) []byte {
|
|||
return append(b, '{')
|
||||
}
|
||||
|
||||
func appendStructEnd(b []byte) []byte {
|
||||
func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, '}', ',')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(b []byte) []byte {
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last] == ',' {
|
||||
b[last] = '}'
|
||||
return appendComma(b)
|
||||
}
|
||||
return appendStructEnd(b)
|
||||
return appendStructEnd(ctx, code, b)
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ var (
|
|||
appendString = encoder.AppendString
|
||||
appendByteSlice = encoder.AppendByteSlice
|
||||
appendNumber = encoder.AppendNumber
|
||||
appendMarshalJSON = encoder.AppendMarshalJSON
|
||||
appendMarshalText = encoder.AppendMarshalText
|
||||
errUnsupportedValue = encoder.ErrUnsupportedValue
|
||||
errUnsupportedFloat = encoder.ErrUnsupportedFloat
|
||||
mapiterinit = encoder.MapIterInit
|
||||
|
@ -273,7 +271,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -300,7 +298,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3147,7 +3145,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3192,7 +3190,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3232,7 +3230,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3272,7 +3270,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3316,7 +3314,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3360,7 +3358,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3400,7 +3398,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3440,7 +3438,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4110,7 +4108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4134,7 +4132,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4147,7 +4145,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4160,7 +4158,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4177,7 +4175,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4196,7 +4194,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4209,7 +4207,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4222,7 +4220,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4349,7 +4347,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyInt:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4358,9 +4356,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, u64, code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntString:
|
||||
|
@ -4369,7 +4367,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4380,9 +4378,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtr:
|
||||
|
@ -4394,7 +4392,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4402,9 +4400,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtrString:
|
||||
|
@ -4418,7 +4416,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4428,16 +4426,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4446,9 +4444,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, u64, code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintString:
|
||||
|
@ -4457,7 +4455,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4468,9 +4466,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtr:
|
||||
|
@ -4482,7 +4480,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4490,9 +4488,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtrString:
|
||||
|
@ -4506,7 +4504,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4516,16 +4514,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4533,9 +4531,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32String:
|
||||
|
@ -4544,7 +4542,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4554,9 +4552,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32Ptr:
|
||||
|
@ -4568,7 +4566,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4576,9 +4574,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32PtrString:
|
||||
|
@ -4592,7 +4590,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4602,9 +4600,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64:
|
||||
|
@ -4615,7 +4613,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4626,9 +4624,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64String:
|
||||
|
@ -4641,7 +4639,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4654,9 +4652,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64Ptr:
|
||||
|
@ -4665,7 +4663,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
break
|
||||
}
|
||||
|
@ -4674,7 +4672,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4686,9 +4684,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64PtrString:
|
||||
|
@ -4706,7 +4704,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4720,16 +4718,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4737,9 +4735,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringString:
|
||||
|
@ -4747,7 +4745,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
s := ptrToString(p + code.Offset)
|
||||
b = appendString(b, string(appendString([]byte{}, s)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4755,9 +4753,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtr:
|
||||
|
@ -4769,7 +4767,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, ptrToString(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4777,9 +4775,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtrString:
|
||||
|
@ -4792,7 +4790,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
v := ptrToString(p)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4801,16 +4799,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
v := ptrToString(p)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4818,9 +4816,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolString:
|
||||
|
@ -4829,7 +4827,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4839,9 +4837,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtr:
|
||||
|
@ -4853,7 +4851,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4861,9 +4859,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtrString:
|
||||
|
@ -4877,7 +4875,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4887,16 +4885,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4904,9 +4902,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if len(v) > 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytesPtr:
|
||||
|
@ -4918,7 +4916,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytesPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4926,9 +4924,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumber:
|
||||
|
@ -4938,7 +4936,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumber:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4949,9 +4947,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberString:
|
||||
|
@ -4963,7 +4961,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4976,9 +4974,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtr:
|
||||
|
@ -4994,7 +4992,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = bb
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5005,9 +5003,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtrString:
|
||||
|
@ -5024,7 +5022,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = append(bb, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5037,9 +5035,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpEnd:
|
||||
|
|
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',')
|
||||
}
|
||||
|
||||
func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalJSON(ctx, code, b, v, false)
|
||||
}
|
||||
|
||||
func appendMarshalText(code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalText(code, b, v, false)
|
||||
}
|
||||
|
||||
func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, code.Key...)
|
||||
}
|
||||
|
@ -84,15 +92,15 @@ func appendStructHead(b []byte) []byte {
|
|||
return append(b, '{')
|
||||
}
|
||||
|
||||
func appendStructEnd(b []byte) []byte {
|
||||
func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, '}', ',')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(b []byte) []byte {
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last] == ',' {
|
||||
b[last] = '}'
|
||||
return appendComma(b)
|
||||
}
|
||||
return appendStructEnd(b)
|
||||
return appendStructEnd(ctx, code, b)
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ var (
|
|||
appendString = encoder.AppendString
|
||||
appendByteSlice = encoder.AppendByteSlice
|
||||
appendNumber = encoder.AppendNumber
|
||||
appendMarshalJSON = encoder.AppendMarshalJSON
|
||||
appendMarshalText = encoder.AppendMarshalText
|
||||
errUnsupportedValue = encoder.ErrUnsupportedValue
|
||||
errUnsupportedFloat = encoder.ErrUnsupportedFloat
|
||||
mapiterinit = encoder.MapIterInit
|
||||
|
@ -286,7 +284,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -313,7 +311,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3160,7 +3158,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3205,7 +3203,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3245,7 +3243,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3285,7 +3283,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3329,7 +3327,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3373,7 +3371,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3413,7 +3411,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3453,7 +3451,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4123,7 +4121,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4147,7 +4145,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4160,7 +4158,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4173,7 +4171,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4190,7 +4188,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4209,7 +4207,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4222,7 +4220,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4235,7 +4233,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4362,7 +4360,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyInt:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4371,9 +4369,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, u64, code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntString:
|
||||
|
@ -4382,7 +4380,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4393,9 +4391,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtr:
|
||||
|
@ -4407,7 +4405,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4415,9 +4413,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtrString:
|
||||
|
@ -4431,7 +4429,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4441,16 +4439,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4459,9 +4457,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, u64, code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintString:
|
||||
|
@ -4470,7 +4468,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4481,9 +4479,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtr:
|
||||
|
@ -4495,7 +4493,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4503,9 +4501,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtrString:
|
||||
|
@ -4519,7 +4517,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4529,16 +4527,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4546,9 +4544,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32String:
|
||||
|
@ -4557,7 +4555,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4567,9 +4565,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32Ptr:
|
||||
|
@ -4581,7 +4579,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4589,9 +4587,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32PtrString:
|
||||
|
@ -4605,7 +4603,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4615,9 +4613,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64:
|
||||
|
@ -4628,7 +4626,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4639,9 +4637,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64String:
|
||||
|
@ -4654,7 +4652,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4667,9 +4665,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64Ptr:
|
||||
|
@ -4678,7 +4676,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
break
|
||||
}
|
||||
|
@ -4687,7 +4685,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4699,9 +4697,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64PtrString:
|
||||
|
@ -4719,7 +4717,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4733,16 +4731,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4750,9 +4748,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringString:
|
||||
|
@ -4760,7 +4758,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
s := ptrToString(p + code.Offset)
|
||||
b = appendString(b, string(appendString([]byte{}, s)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4768,9 +4766,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtr:
|
||||
|
@ -4782,7 +4780,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, ptrToString(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4790,9 +4788,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtrString:
|
||||
|
@ -4805,7 +4803,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
v := ptrToString(p)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4814,16 +4812,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
v := ptrToString(p)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4831,9 +4829,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolString:
|
||||
|
@ -4842,7 +4840,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4852,9 +4850,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtr:
|
||||
|
@ -4866,7 +4864,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4874,9 +4872,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtrString:
|
||||
|
@ -4890,7 +4888,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4900,16 +4898,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4917,9 +4915,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if len(v) > 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytesPtr:
|
||||
|
@ -4931,7 +4929,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytesPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4939,9 +4937,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumber:
|
||||
|
@ -4951,7 +4949,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumber:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4962,9 +4960,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberString:
|
||||
|
@ -4976,7 +4974,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4989,9 +4987,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtr:
|
||||
|
@ -5007,7 +5005,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = bb
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5018,9 +5016,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtrString:
|
||||
|
@ -5037,7 +5035,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = append(bb, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5050,9 +5048,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpEnd:
|
||||
|
|
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',')
|
||||
}
|
||||
|
||||
func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalJSON(ctx, code, b, v, true)
|
||||
}
|
||||
|
||||
func appendMarshalText(code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalText(code, b, v, true)
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{')
|
||||
}
|
||||
|
@ -84,15 +92,15 @@ func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte)
|
|||
return append(b, code.EscapedKey...)
|
||||
}
|
||||
|
||||
func appendStructEnd(b []byte) []byte {
|
||||
func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte {
|
||||
return append(b, '}', ',')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(b []byte) []byte {
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last] == ',' {
|
||||
b[last] = '}'
|
||||
return appendComma(b)
|
||||
}
|
||||
return appendStructEnd(b)
|
||||
return appendStructEnd(ctx, code, b)
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ var (
|
|||
appendString = encoder.AppendEscapedString
|
||||
appendByteSlice = encoder.AppendByteSlice
|
||||
appendNumber = encoder.AppendNumber
|
||||
appendMarshalJSON = encoder.AppendMarshalJSON
|
||||
appendMarshalText = encoder.AppendMarshalText
|
||||
errUnsupportedValue = encoder.ErrUnsupportedValue
|
||||
errUnsupportedFloat = encoder.ErrUnsupportedFloat
|
||||
mapiterinit = encoder.MapIterInit
|
||||
|
@ -273,7 +271,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -300,7 +298,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3147,7 +3145,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3192,7 +3190,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3232,7 +3230,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3272,7 +3270,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3316,7 +3314,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3360,7 +3358,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3400,7 +3398,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3440,7 +3438,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4110,7 +4108,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4134,7 +4132,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4147,7 +4145,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4160,7 +4158,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4177,7 +4175,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4196,7 +4194,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4209,7 +4207,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4222,7 +4220,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4349,7 +4347,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyInt:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4358,9 +4356,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, u64, code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntString:
|
||||
|
@ -4369,7 +4367,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4380,9 +4378,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtr:
|
||||
|
@ -4394,7 +4392,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4402,9 +4400,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtrString:
|
||||
|
@ -4418,7 +4416,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4428,16 +4426,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4446,9 +4444,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, u64, code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintString:
|
||||
|
@ -4457,7 +4455,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4468,9 +4466,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtr:
|
||||
|
@ -4482,7 +4480,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4490,9 +4488,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtrString:
|
||||
|
@ -4506,7 +4504,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4516,16 +4514,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4533,9 +4531,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32String:
|
||||
|
@ -4544,7 +4542,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4554,9 +4552,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32Ptr:
|
||||
|
@ -4568,7 +4566,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4576,9 +4574,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32PtrString:
|
||||
|
@ -4592,7 +4590,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4602,9 +4600,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64:
|
||||
|
@ -4615,7 +4613,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4626,9 +4624,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64String:
|
||||
|
@ -4641,7 +4639,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4654,9 +4652,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64Ptr:
|
||||
|
@ -4665,7 +4663,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
break
|
||||
}
|
||||
|
@ -4674,7 +4672,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4686,9 +4684,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64PtrString:
|
||||
|
@ -4706,7 +4704,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4720,16 +4718,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4737,9 +4735,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringString:
|
||||
|
@ -4747,7 +4745,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
s := ptrToString(p + code.Offset)
|
||||
b = appendString(b, string(appendString([]byte{}, s)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4755,9 +4753,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtr:
|
||||
|
@ -4769,7 +4767,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, ptrToString(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4777,9 +4775,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtrString:
|
||||
|
@ -4792,7 +4790,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
v := ptrToString(p)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4801,16 +4799,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
v := ptrToString(p)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4818,9 +4816,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolString:
|
||||
|
@ -4829,7 +4827,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4839,9 +4837,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtr:
|
||||
|
@ -4853,7 +4851,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4861,9 +4859,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtrString:
|
||||
|
@ -4877,7 +4875,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4887,16 +4885,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4904,9 +4902,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if len(v) > 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, v)
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytesPtr:
|
||||
|
@ -4918,7 +4916,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytesPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4926,9 +4924,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumber:
|
||||
|
@ -4938,7 +4936,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumber:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4949,9 +4947,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberString:
|
||||
|
@ -4963,7 +4961,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4976,9 +4974,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtr:
|
||||
|
@ -4994,7 +4992,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = bb
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5005,9 +5003,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(bb)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtrString:
|
||||
|
@ -5024,7 +5022,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = append(bb, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5037,9 +5035,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(b)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(b)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpEnd:
|
||||
|
|
|
@ -76,6 +76,14 @@ func appendComma(b []byte) []byte {
|
|||
return append(b, ',', '\n')
|
||||
}
|
||||
|
||||
func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalJSONIndent(ctx, code, b, v, true)
|
||||
}
|
||||
|
||||
func appendMarshalText(code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalTextIndent(code, b, v, true)
|
||||
}
|
||||
|
||||
func appendStructHead(b []byte) []byte {
|
||||
return append(b, '{', '\n')
|
||||
}
|
||||
|
@ -86,7 +94,7 @@ func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte
|
|||
return append(b, ' ')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
b[last] = '}'
|
||||
|
|
|
@ -26,8 +26,6 @@ var (
|
|||
appendString = encoder.AppendEscapedString
|
||||
appendByteSlice = encoder.AppendByteSlice
|
||||
appendNumber = encoder.AppendNumber
|
||||
appendMarshalJSON = encoder.AppendMarshalJSONIndent
|
||||
appendMarshalText = encoder.AppendMarshalTextIndent
|
||||
appendStructEnd = encoder.AppendStructEndIndent
|
||||
appendIndent = encoder.AppendIndent
|
||||
errUnsupportedValue = encoder.ErrUnsupportedValue
|
||||
|
@ -278,7 +276,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -305,7 +303,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -612,7 +610,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if !code.AnonymousHead {
|
||||
b = appendStructHead(b)
|
||||
}
|
||||
if !code.AnonymousKey && len(code.EscapedKey) > 0 {
|
||||
if !code.AnonymousKey && len(code.Key) > 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
}
|
||||
p += code.Offset
|
||||
|
@ -3170,7 +3168,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3215,7 +3213,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3255,7 +3253,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3295,7 +3293,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3339,7 +3337,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3383,7 +3381,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3423,7 +3421,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3463,7 +3461,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4131,7 +4129,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4155,7 +4153,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4168,7 +4166,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4181,7 +4179,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, true)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4198,7 +4196,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4217,7 +4215,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4230,7 +4228,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4243,7 +4241,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), true)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4388,7 +4386,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyInt:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4397,9 +4395,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, u64, code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntString:
|
||||
|
@ -4408,7 +4406,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4419,9 +4417,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtr:
|
||||
|
@ -4433,7 +4431,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4441,9 +4439,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtrString:
|
||||
|
@ -4457,7 +4455,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4467,16 +4465,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUint:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4485,9 +4483,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, u64, code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintString:
|
||||
|
@ -4496,7 +4494,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4507,9 +4505,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtr:
|
||||
|
@ -4521,7 +4519,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4529,9 +4527,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtrString:
|
||||
|
@ -4545,7 +4543,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4555,16 +4553,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4572,9 +4570,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32String:
|
||||
|
@ -4583,7 +4581,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4593,9 +4591,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32Ptr:
|
||||
|
@ -4607,7 +4605,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4615,9 +4613,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32PtrString:
|
||||
|
@ -4631,7 +4629,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4641,9 +4639,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64:
|
||||
|
@ -4654,7 +4652,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4665,9 +4663,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64String:
|
||||
|
@ -4680,7 +4678,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4693,9 +4691,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64Ptr:
|
||||
|
@ -4711,7 +4709,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendFloat64(b, v)
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4723,9 +4721,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64PtrString:
|
||||
|
@ -4743,7 +4741,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4757,16 +4755,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndString:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendString(b, ptrToString(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4774,9 +4772,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringString:
|
||||
|
@ -4784,7 +4782,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
s := ptrToString(p + code.Offset)
|
||||
b = appendString(b, string(appendString([]byte{}, s)))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4792,9 +4790,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtr:
|
||||
|
@ -4806,7 +4804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, ptrToString(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4814,9 +4812,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtrString:
|
||||
|
@ -4828,7 +4826,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4836,16 +4834,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBool:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4853,9 +4851,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolString:
|
||||
|
@ -4864,7 +4862,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4874,9 +4872,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtr:
|
||||
|
@ -4888,7 +4886,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4896,9 +4894,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtrString:
|
||||
|
@ -4912,7 +4910,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4922,16 +4920,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytes:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4939,9 +4937,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if len(v) > 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytesPtr:
|
||||
|
@ -4953,7 +4951,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytesPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4961,9 +4959,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumber:
|
||||
|
@ -4973,7 +4971,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(ctx, bb, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumber:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4984,9 +4982,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(ctx, bb, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberString:
|
||||
|
@ -4998,7 +4996,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5011,9 +5009,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtr:
|
||||
|
@ -5029,7 +5027,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = bb
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5040,9 +5038,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(ctx, bb, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtrString:
|
||||
|
@ -5059,7 +5057,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = append(bb, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5072,9 +5070,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpEnd:
|
||||
|
|
|
@ -80,13 +80,21 @@ func appendStructHead(b []byte) []byte {
|
|||
return append(b, '{', '\n')
|
||||
}
|
||||
|
||||
func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalJSONIndent(ctx, code, b, v, false)
|
||||
}
|
||||
|
||||
func appendMarshalText(code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) {
|
||||
return encoder.AppendMarshalTextIndent(code, b, v, false)
|
||||
}
|
||||
|
||||
func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
b = appendIndent(ctx, b, code.Indent)
|
||||
b = append(b, code.Key...)
|
||||
return append(b, ' ')
|
||||
}
|
||||
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
|
||||
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
b[last] = '}'
|
||||
|
|
|
@ -26,8 +26,6 @@ var (
|
|||
appendString = encoder.AppendString
|
||||
appendByteSlice = encoder.AppendByteSlice
|
||||
appendNumber = encoder.AppendNumber
|
||||
appendMarshalJSON = encoder.AppendMarshalJSONIndent
|
||||
appendMarshalText = encoder.AppendMarshalTextIndent
|
||||
appendStructEnd = encoder.AppendStructEndIndent
|
||||
appendIndent = encoder.AppendIndent
|
||||
errUnsupportedValue = encoder.ErrUnsupportedValue
|
||||
|
@ -278,7 +276,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -305,7 +303,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if code.IsNilableType && code.Indirect {
|
||||
p = ptrToPtr(p)
|
||||
}
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3170,7 +3168,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3215,7 +3213,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3255,7 +3253,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3295,7 +3293,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3339,7 +3337,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3383,7 +3381,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3423,7 +3421,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3463,7 +3461,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
code = code.NextField
|
||||
} else {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4131,7 +4129,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4155,7 +4153,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, iface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4168,7 +4166,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4181,7 +4179,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
||||
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4198,7 +4196,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 && code.Nilcheck {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4217,7 +4215,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
break
|
||||
}
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4230,7 +4228,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p == 0 {
|
||||
b = appendNull(b)
|
||||
} else {
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4243,7 +4241,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
||||
bb, err := appendMarshalText(code, b, ptrToInterface(code, p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4388,7 +4386,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyInt:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4397,9 +4395,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, u64, code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntString:
|
||||
|
@ -4408,7 +4406,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4419,9 +4417,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtr:
|
||||
|
@ -4433,7 +4431,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4441,9 +4439,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndIntPtrString:
|
||||
|
@ -4457,7 +4455,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyIntPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4467,16 +4465,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendInt(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUint:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUint:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4485,9 +4483,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, u64, code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintString:
|
||||
|
@ -4496,7 +4494,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4507,9 +4505,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, u64, code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtr:
|
||||
|
@ -4521,7 +4519,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4529,9 +4527,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndUintPtrString:
|
||||
|
@ -4545,7 +4543,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyUintPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4555,16 +4553,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendUint(b, ptrToUint64(p), code)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4572,9 +4570,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32String:
|
||||
|
@ -4583,7 +4581,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4593,9 +4591,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32Ptr:
|
||||
|
@ -4607,7 +4605,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4615,9 +4613,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat32PtrString:
|
||||
|
@ -4631,7 +4629,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat32PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4641,9 +4639,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat32(b, ptrToFloat32(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64:
|
||||
|
@ -4654,7 +4652,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4665,9 +4663,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64String:
|
||||
|
@ -4680,7 +4678,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64String:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4693,9 +4691,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64Ptr:
|
||||
|
@ -4711,7 +4709,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendFloat64(b, v)
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64Ptr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4723,9 +4721,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, errUnsupportedFloat(v)
|
||||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndFloat64PtrString:
|
||||
|
@ -4743,7 +4741,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyFloat64PtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4757,16 +4755,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = appendFloat64(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndString:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendString(b, ptrToString(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4774,9 +4772,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringString:
|
||||
|
@ -4784,7 +4782,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendStructKey(ctx, code, b)
|
||||
s := ptrToString(p + code.Offset)
|
||||
b = appendString(b, string(appendString([]byte{}, s)))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4792,9 +4790,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v != "" {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, v)))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtr:
|
||||
|
@ -4806,7 +4804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, ptrToString(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4814,9 +4812,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, ptrToString(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndStringPtrString:
|
||||
|
@ -4828,7 +4826,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyStringPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4836,16 +4834,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBool:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBool:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4853,9 +4851,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if v {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolString:
|
||||
|
@ -4864,7 +4862,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p+code.Offset))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4874,9 +4872,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, v)
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtr:
|
||||
|
@ -4888,7 +4886,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4896,9 +4894,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBoolPtrString:
|
||||
|
@ -4912,7 +4910,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBoolPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4922,16 +4920,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
b = append(b, '"')
|
||||
b = appendBool(b, ptrToBool(p))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytes:
|
||||
b = appendStructKey(ctx, code, b)
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytes:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4939,9 +4937,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if len(v) > 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, v)
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndBytesPtr:
|
||||
|
@ -4953,7 +4951,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
} else {
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyBytesPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4961,9 +4959,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if p != 0 {
|
||||
b = appendStructKey(ctx, code, b)
|
||||
b = appendByteSlice(b, ptrToBytes(p))
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumber:
|
||||
|
@ -4973,7 +4971,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(ctx, bb, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumber:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -4984,9 +4982,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(ctx, bb, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberString:
|
||||
|
@ -4998,7 +4996,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5011,9 +5009,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtr:
|
||||
|
@ -5029,7 +5027,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = bb
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtr:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5040,9 +5038,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = appendStructEnd(ctx, bb, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, bb)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpStructEndNumberPtrString:
|
||||
|
@ -5059,7 +5057,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
}
|
||||
b = append(bb, '"')
|
||||
}
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
code = code.Next
|
||||
case encoder.OpStructEndOmitEmptyNumberPtrString:
|
||||
p := load(ctxptr, code.HeadIdx)
|
||||
|
@ -5072,9 +5070,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
return nil, err
|
||||
}
|
||||
b = append(bb, '"')
|
||||
b = appendStructEnd(ctx, b, code.Indent-1)
|
||||
b = appendStructEnd(ctx, code, b)
|
||||
} else {
|
||||
b = appendStructEndSkipLast(ctx, b, code)
|
||||
b = appendStructEndSkipLast(ctx, code, b)
|
||||
}
|
||||
code = code.Next
|
||||
case encoder.OpEnd:
|
||||
|
|
Loading…
Reference in New Issue