mirror of https://github.com/goccy/go-json.git
Merge pull request #82 from goccy/feature/coverage
Add test cases of omitempty/string tag for int type
This commit is contained in:
commit
66ced55701
1948
coverage_test.go
1948
coverage_test.go
File diff suppressed because it is too large
Load Diff
|
@ -105,7 +105,17 @@ func (e *Encoder) convertHeadOnlyCode(c *opcode, isPtrHead bool) {
|
|||
}
|
||||
c.op = opStructFieldHeadOnly
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
return
|
||||
e.convertHeadOnlyCode(c.next, false)
|
||||
if !strings.Contains(c.next.op.String(), "Only") {
|
||||
return
|
||||
}
|
||||
c.op = opStructFieldHeadOmitEmptyOnly
|
||||
case opStructFieldHeadStringTag:
|
||||
e.convertHeadOnlyCode(c.next, false)
|
||||
if !strings.Contains(c.next.op.String(), "Only") {
|
||||
return
|
||||
}
|
||||
c.op = opStructFieldHeadStringTagOnly
|
||||
case opStructFieldPtrHead:
|
||||
}
|
||||
|
||||
|
|
554
encode_vm.go
554
encode_vm.go
|
@ -301,11 +301,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
if err != nil {
|
||||
return nil, errMarshaler(code, err)
|
||||
}
|
||||
if e.enabledHTMLEscape {
|
||||
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
} else {
|
||||
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
}
|
||||
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
|
@ -619,7 +615,30 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
case opStructFieldHeadOnly:
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
if !code.anonymousKey {
|
||||
|
@ -628,6 +647,19 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
case opStructFieldHeadOmitEmptyOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
if !code.anonymousKey {
|
||||
if ptr != 0 {
|
||||
b = append(b, code.key...)
|
||||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
}
|
||||
case opStructFieldAnonymousHead:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
|
@ -636,6 +668,26 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, ptr)
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -652,6 +704,51 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
|
@ -659,6 +756,25 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
v := int64(e.ptrToInt(p))
|
||||
if v != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, v)
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -681,6 +797,49 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p = e.ptrToPtr(p)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -702,6 +861,48 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtrOnly:
|
||||
b = append(b, '{')
|
||||
p := load(ctxptr, code.idx)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldHeadIntNPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -736,6 +937,45 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
|
@ -746,6 +986,33 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -764,6 +1031,44 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
b = append(b, code.key...)
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -782,6 +1087,44 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, code.key...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadInt8:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -2655,94 +2998,6 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -3501,7 +3756,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
}
|
||||
b = append(b, code.key...)
|
||||
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
|
@ -3532,7 +3787,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
}
|
||||
b = append(b, code.key...)
|
||||
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
|
@ -3571,45 +3826,6 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, ptr+code.offset)
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -5027,6 +5243,29 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
code = code.next
|
||||
case opStructAnonymousEnd:
|
||||
code = code.next
|
||||
case opStructEndInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndIntPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -5038,6 +5277,28 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyIntPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagIntPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndIntNPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -5055,12 +5316,6 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndInt8Ptr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -5326,15 +5581,6 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = appendInt(b, int64(v))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt8(ptr + code.offset)
|
||||
|
@ -5496,14 +5742,6 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
|
|
@ -577,15 +577,49 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
case opStructFieldHeadOnly:
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
if !code.anonymousKey {
|
||||
b = append(b, code.escapedKey...)
|
||||
}
|
||||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
case opStructFieldHeadOmitEmptyOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
if !code.anonymousKey {
|
||||
if p != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
}
|
||||
case opStructFieldAnonymousHead:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
|
@ -594,6 +628,26 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, ptr)
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -610,6 +664,51 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
|
@ -617,6 +716,25 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
v := int64(e.ptrToInt(p))
|
||||
if v != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, v)
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -639,6 +757,49 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p = e.ptrToPtr(p)
|
||||
if p != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.escapedKey...)
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -660,6 +821,48 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtrOnly:
|
||||
b = append(b, '{')
|
||||
p := load(ctxptr, code.idx)
|
||||
if p != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
b = append(b, code.escapedKey...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldHeadIntNPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -694,6 +897,45 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
|
@ -704,6 +946,33 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -722,6 +991,44 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
b = append(b, code.escapedKey...)
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -740,6 +1047,44 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, code.escapedKey...)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadInt8:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -2620,115 +2965,6 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -3557,45 +3793,6 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, ptr+code.offset)
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{')
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -5072,6 +5269,29 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
code = code.next
|
||||
case opStructAnonymousEnd:
|
||||
code = code.next
|
||||
case opStructEndInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndIntPtr:
|
||||
b = append(b, code.escapedKey...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -5083,6 +5303,28 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyIntPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagIntPtr:
|
||||
b = append(b, code.escapedKey...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndIntNPtr:
|
||||
b = append(b, code.escapedKey...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -5100,12 +5342,6 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndInt8Ptr:
|
||||
b = append(b, code.escapedKey...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
|
@ -5371,15 +5607,6 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = appendInt(b, int64(v))
|
||||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt8(ptr + code.offset)
|
||||
|
@ -5541,14 +5768,6 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = appendStructEnd(b)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.escapedKey...)
|
||||
|
|
|
@ -617,7 +617,34 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
case opStructFieldHeadOnly:
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, '{', '\n')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
if !code.anonymousKey {
|
||||
|
@ -628,6 +655,19 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
case opStructFieldHeadOmitEmptyOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
if !code.anonymousKey && ptr != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
case opStructFieldPtrHeadInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -646,6 +686,54 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
|
@ -655,6 +743,28 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
v := int64(e.ptrToInt(p))
|
||||
if v != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, v)
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -679,6 +789,53 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
p = e.ptrToPtr(p)
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -702,6 +859,52 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldHeadIntNPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -740,6 +943,43 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
|
@ -752,6 +992,37 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -772,6 +1043,48 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -792,6 +1105,48 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadInt8:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -2692,61 +3047,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, '{', '\n')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, '{', '\n')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -3151,7 +3451,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
case opStructFieldHeadStringTag:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
|
@ -3164,29 +3463,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -4209,6 +4485,35 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
} else {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
// doesn't exist any fields
|
||||
b[last] = '}'
|
||||
} else {
|
||||
b = append(b, '}')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndIntPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
|
@ -4222,6 +4527,41 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyIntPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
} else {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
// doesn't exist any fields
|
||||
b[last] = '}'
|
||||
} else {
|
||||
b = append(b, '}')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructEndStringTagIntPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndInt8:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
|
@ -4503,17 +4843,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = append(b, buf.Bytes()...)
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt8(ptr + code.offset)
|
||||
|
@ -4671,15 +5000,6 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
|
|
|
@ -617,7 +617,34 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
case opStructFieldHeadOnly:
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, '{', '\n')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldHeadOnly, opStructFieldHeadStringTagOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
if !code.anonymousKey {
|
||||
|
@ -628,6 +655,19 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
case opStructFieldHeadOmitEmptyOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
if !code.anonymousKey && ptr != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
p := ptr + code.offset
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
} else {
|
||||
code = code.nextField
|
||||
}
|
||||
case opStructFieldPtrHeadInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -646,6 +686,54 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadIntOnly, opStructFieldHeadIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
|
@ -655,6 +743,28 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
v := int64(e.ptrToInt(p))
|
||||
if v != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, v)
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntOnly, opStructFieldHeadStringTagIntOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -679,6 +789,53 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
p = e.ptrToPtr(p)
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -702,6 +859,52 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldHeadIntNPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -740,6 +943,43 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagInt:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntOnly, opStructFieldAnonymousHeadIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
|
@ -752,6 +992,37 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntOnly, opStructFieldAnonymousHeadOmitEmptyIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntOnly, opStructFieldAnonymousHeadStringTagIntOnly:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -772,6 +1043,48 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtr:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtr:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
p = e.ptrToPtr(p)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
|
@ -792,6 +1105,48 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadOmitEmptyIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
if p == 0 {
|
||||
code = code.end.next
|
||||
break
|
||||
}
|
||||
store(ctxptr, code.idx, e.ptrToPtr(p))
|
||||
fallthrough
|
||||
case opStructFieldAnonymousHeadStringTagIntPtrOnly:
|
||||
p := load(ctxptr, code.idx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p+code.offset)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldPtrHeadInt8:
|
||||
store(ctxptr, code.idx, e.ptrToPtr(load(ctxptr, code.idx)))
|
||||
fallthrough
|
||||
|
@ -2692,61 +3047,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmpty:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, '{', '\n')
|
||||
p := ptr + code.offset
|
||||
if p == 0 || *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(&p))) == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, '{', '\n')
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v == 0 {
|
||||
code = code.nextField
|
||||
} else {
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
}
|
||||
case opStructFieldPtrHeadOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -3151,7 +3451,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
case opStructFieldHeadStringTag:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
|
@ -3164,29 +3463,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
code = code.next
|
||||
store(ctxptr, code.idx, p)
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
store(ctxptr, code.idx, e.ptrToPtr(ptr))
|
||||
}
|
||||
fallthrough
|
||||
case opStructFieldHeadStringTagInt:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr == 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = encodeNull(b)
|
||||
b = encodeIndentComma(b)
|
||||
code = code.end.next
|
||||
} else {
|
||||
b = append(b, '{', '\n')
|
||||
b = e.encodeIndent(b, code.indent+1)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
}
|
||||
case opStructFieldPtrHeadStringTagInt8:
|
||||
ptr := load(ctxptr, code.idx)
|
||||
if ptr != 0 {
|
||||
|
@ -4165,7 +4441,7 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = encodeEscapedString(b, buf.String())
|
||||
b = encodeNoEscapedString(b, buf.String())
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldStringTagMarshalText:
|
||||
|
@ -4209,6 +4485,35 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
} else {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
// doesn't exist any fields
|
||||
b[last] = '}'
|
||||
} else {
|
||||
b = append(b, '}')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndIntPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
|
@ -4222,6 +4527,41 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyIntPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
} else {
|
||||
last := len(b) - 1
|
||||
if b[last-1] == '{' {
|
||||
// doesn't exist any fields
|
||||
b[last] = '}'
|
||||
} else {
|
||||
b = append(b, '}')
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructEndStringTagIntPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = append(b, '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(p)))
|
||||
b = append(b, '"')
|
||||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndInt8:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
|
@ -4503,17 +4843,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = append(b, buf.Bytes()...)
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt(ptr + code.offset)
|
||||
if v != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = appendInt(b, int64(v))
|
||||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndOmitEmptyInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
v := e.ptrToInt8(ptr + code.offset)
|
||||
|
@ -4671,15 +5000,6 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
}
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ', '"')
|
||||
b = appendInt(b, int64(e.ptrToInt(ptr+code.offset)))
|
||||
b = append(b, '"')
|
||||
b = e.appendStructEndIndent(b, code.indent-1)
|
||||
code = code.next
|
||||
case opStructEndStringTagInt8:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
|
|
Loading…
Reference in New Issue