From a324a292560ef7ae8166d605102b185ce7f3bbe1 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Fri, 19 Feb 2021 15:03:52 +0900 Subject: [PATCH] Pass test --- encode_compile.go | 34 +++++- encode_int.go | 44 +++++-- encode_vm.go | 222 ++++++++++++++++------------------- encode_vm_escaped.go | 228 ++++++++++++++++-------------------- encode_vm_escaped_indent.go | 214 ++++++++++++++++----------------- encode_vm_indent.go | 214 ++++++++++++++++----------------- 6 files changed, 475 insertions(+), 481 deletions(-) diff --git a/encode_compile.go b/encode_compile.go index 8262d91..474cabf 100644 --- a/encode_compile.go +++ b/encode_compile.go @@ -508,60 +508,92 @@ func encodeCompileUint64(ctx *encodeCompileContext) (*opcode, error) { func encodeCompileIntString(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opIntString) + switch intSize { + case 32: + code.mask = math.MaxUint32 + code.rshiftNum = 31 + default: + code.mask = math.MaxUint64 + code.rshiftNum = 63 + } ctx.incIndex() return code, nil } func encodeCompileInt8String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opIntString) + code.mask = math.MaxUint8 + code.rshiftNum = 7 ctx.incIndex() return code, nil } func encodeCompileInt16String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opIntString) + code.mask = math.MaxUint16 + code.rshiftNum = 15 ctx.incIndex() return code, nil } func encodeCompileInt32String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opIntString) + code.mask = math.MaxUint32 + code.rshiftNum = 31 ctx.incIndex() return code, nil } func encodeCompileInt64String(ctx *encodeCompileContext) (*opcode, error) { - code := newOpCode(ctx, opInt64String) + code := newOpCode(ctx, opIntString) + code.mask = math.MaxUint64 + code.rshiftNum = 63 ctx.incIndex() return code, nil } func encodeCompileUintString(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opUintString) + switch intSize { + case 32: + code.mask = math.MaxUint32 + code.rshiftNum = 31 + default: + code.mask = math.MaxUint64 + code.rshiftNum = 63 + } ctx.incIndex() return code, nil } func encodeCompileUint8String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opUintString) + code.mask = math.MaxUint8 + code.rshiftNum = 7 ctx.incIndex() return code, nil } func encodeCompileUint16String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opUintString) + code.mask = math.MaxUint16 + code.rshiftNum = 15 ctx.incIndex() return code, nil } func encodeCompileUint32String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opUintString) + code.mask = math.MaxUint32 + code.rshiftNum = 31 ctx.incIndex() return code, nil } func encodeCompileUint64String(ctx *encodeCompileContext) (*opcode, error) { code := newOpCode(ctx, opUintString) + code.mask = math.MaxUint64 + code.rshiftNum = 63 ctx.incIndex() return code, nil } diff --git a/encode_int.go b/encode_int.go index d38132b..993b9d1 100644 --- a/encode_int.go +++ b/encode_int.go @@ -49,13 +49,9 @@ var intBELookup = [100]uint16{ var intLookup = [2]*[100]uint16{&intLELookup, &intBELookup} -var appendInt = formatInteger - -func appendUint(b []byte, n uint64) []byte { - return formatInteger(b, n, false) -} - -func formatInteger(out []byte, n uint64, negative bool) []byte { +func appendInt(out []byte, u64 uint64, code *opcode) []byte { + n := u64 & code.mask + negative := (u64>>code.rshiftNum)&1 == 1 if !negative { if n < 10 { return append(out, byte(n+'0')) @@ -64,7 +60,7 @@ func formatInteger(out []byte, n uint64, negative bool) []byte { return append(out, byte(u), byte(u>>8)) } } else { - n = -n + n = -n & code.mask } lookup := intLookup[endianness] @@ -94,3 +90,35 @@ func formatInteger(out []byte, n uint64, negative bool) []byte { return append(out, b[i:]...) } + +func appendUint(out []byte, u64 uint64, code *opcode) []byte { + n := u64 & code.mask + if n < 10 { + return append(out, byte(n+'0')) + } else if n < 100 { + u := intLELookup[n] + return append(out, byte(u), byte(u>>8)) + } + + lookup := intLookup[endianness] + + var b [22]byte + u := (*[11]uint16)(unsafe.Pointer(&b)) + i := 11 + + for n >= 100 { + j := n % 100 + n /= 100 + i-- + u[i] = lookup[j] + } + + i-- + u[i] = lookup[n] + + i *= 2 // convert to byte index + if n < 10 { + i++ // remove leading zero + } + return append(out, b[i:]...) +} diff --git a/encode_vm.go b/encode_vm.go index 10ccaba..9c3789b 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -93,12 +93,23 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.next store(ctxptr, code.idx, ptrToPtr(ptr)) case opInt: - u64 := ptrToUint64(load(ctxptr, code.idx)) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = encodeComma(b) code = code.next case opUint: - b = appendUint(b, ptrToUint64(load(ctxptr, code.idx))&code.mask) + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = encodeComma(b) + code = code.next + case opIntString: + b = append(b, '"') + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opUintString: + b = append(b, '"') + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') b = encodeComma(b) code = code.next case opFloat32: @@ -605,8 +616,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, '{') b = append(b, code.key...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -630,7 +640,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - b = appendInt(b, v, v>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } @@ -651,8 +661,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = append(b, '{') b = append(b, code.key...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -661,8 +670,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := load(ctxptr, code.idx) b = append(b, '{') b = append(b, code.key...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: @@ -672,7 +680,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco v := u64 & code.mask if v != 0 { b = append(b, code.key...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) } code = code.next @@ -681,8 +689,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = append(b, '{') b = append(b, code.key...) b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -703,8 +710,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -723,8 +729,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p = ptrToPtr(p + code.offset) if p != 0 { b = append(b, code.key...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -747,8 +752,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -771,8 +775,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -791,8 +794,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := load(ctxptr, code.idx) if p != 0 { b = append(b, code.key...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -814,8 +816,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -836,8 +837,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -851,8 +851,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.end.next } else { b = append(b, code.key...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -873,7 +872,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } @@ -891,8 +890,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, code.key...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -903,8 +901,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.end.next } else { b = append(b, code.key...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -919,7 +916,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } @@ -931,8 +928,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, code.key...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -951,8 +947,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -970,8 +965,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next } @@ -990,8 +984,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -1010,8 +1003,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -1029,8 +1021,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) code = code.next } @@ -1049,8 +1040,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) b = append(b, '"') } b = encodeComma(b) @@ -1067,7 +1057,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, '{') b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -1085,12 +1075,13 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.end.next } else { b = append(b, '{') - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = append(b, code.key...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) code = code.next } @@ -1111,7 +1102,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = append(b, '{') b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1120,16 +1111,17 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := load(ctxptr, code.idx) b = append(b, '{') b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: p := load(ctxptr, code.idx) b = append(b, '{') - v := ptrToUint64(p) & code.mask + u64 := ptrToUint64(p) + v := u64 & code.mask if v != 0 { b = append(b, code.key...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) } code = code.next @@ -1138,7 +1130,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = append(b, '{') b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1159,7 +1151,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -1178,7 +1170,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p = ptrToPtr(p + code.offset) if p != 0 { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -1201,7 +1193,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -1224,7 +1216,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -1243,7 +1235,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := load(ctxptr, code.idx) if p != 0 { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) } code = code.next @@ -1265,7 +1257,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') } b = encodeComma(b) @@ -1286,7 +1278,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -1300,7 +1292,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.end.next } else { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -1315,12 +1307,13 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = append(b, code.key...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) code = code.next } @@ -1338,7 +1331,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1349,7 +1342,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.end.next } else { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -1358,12 +1351,13 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = append(b, code.key...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) code = code.next } @@ -1375,7 +1369,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } else { b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1394,7 +1388,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -1412,7 +1406,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next } @@ -1431,7 +1425,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -1450,7 +1444,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -1468,7 +1462,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.nextField } else { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) code = code.next } @@ -1487,7 +1481,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') } b = encodeComma(b) @@ -4032,8 +4026,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco case opStructFieldInt: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next case opStructFieldOmitEmptyInt: @@ -4042,7 +4035,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco v := u64 & code.mask if v != 0 { b = append(b, code.key...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) } code = code.next @@ -4050,8 +4043,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -4062,8 +4054,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -4072,8 +4063,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.key...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -4085,8 +4075,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -4104,23 +4093,23 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next case opStructFieldUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next case opStructFieldOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = append(b, code.key...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) } code = code.next @@ -4128,7 +4117,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -4139,7 +4128,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -4148,7 +4137,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -4160,7 +4149,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -4653,8 +4642,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco case opStructEndInt: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = appendStructEnd(b) code = code.next case opStructEndOmitEmptyInt: @@ -4663,7 +4651,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco v := u64 & code.mask if v != 0 { b = append(b, code.key...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4679,8 +4667,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEnd(b) code = code.next @@ -4691,8 +4678,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next @@ -4701,8 +4687,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.key...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4722,8 +4707,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEnd(b) @@ -4741,23 +4725,23 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next case opStructEndUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = appendStructEnd(b) code = code.next case opStructEndOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = append(b, code.key...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4773,7 +4757,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEnd(b) code = code.next @@ -4784,7 +4768,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next @@ -4793,7 +4777,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.key...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4813,7 +4797,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEnd(b) @@ -4831,7 +4815,7 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index a06e0b8..2c2c6d0 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -27,18 +27,23 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next store(ctxptr, code.idx, ptrToPtr(ptr)) case opInt: - p := load(ctxptr, code.idx) - u64 := ptrToUint64(p) - if (u64>>code.rshiftNum)&1 == 1 { - v := ^u64&code.mask + 1 - b = appendInt(b, -v, true) - } else { - b = appendInt(b, u64&code.mask, (u64>>code.rshiftNum)&1 == 1) - } + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = encodeComma(b) code = code.next case opUint: - b = appendUint(b, ptrToUint64(load(ctxptr, code.idx))&code.mask) + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = encodeComma(b) + code = code.next + case opIntString: + b = append(b, '"') + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opUintString: + b = append(b, '"') + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') b = encodeComma(b) code = code.next case opFloat32: @@ -542,8 +547,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, '{') b = append(b, code.escapedKey...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -567,7 +571,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendInt(b, v, v>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } @@ -588,8 +592,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = append(b, '{') b = append(b, code.escapedKey...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -598,8 +601,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := load(ctxptr, code.idx) b = append(b, '{') b = append(b, code.escapedKey...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: @@ -609,7 +611,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o v := u64 & code.mask if v != 0 { b = append(b, code.escapedKey...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) } code = code.next @@ -618,8 +620,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = append(b, '{') b = append(b, code.escapedKey...) b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -640,8 +641,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -660,8 +660,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p = ptrToPtr(p + code.offset) if p != 0 { b = append(b, code.escapedKey...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -684,8 +683,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -708,8 +706,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -728,8 +725,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := load(ctxptr, code.idx) if p != 0 { b = append(b, code.escapedKey...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -751,8 +747,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -773,8 +768,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -788,8 +782,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.end.next } else { b = append(b, code.escapedKey...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -810,7 +803,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } @@ -828,8 +821,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, code.escapedKey...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -840,8 +832,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.end.next } else { b = append(b, code.escapedKey...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -856,7 +847,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) code = code.next } @@ -868,8 +859,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, code.escapedKey...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -888,8 +878,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -907,8 +896,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next } @@ -927,8 +915,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -947,8 +934,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -966,8 +952,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) code = code.next } @@ -986,8 +971,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p+code.offset), code) b = append(b, '"') } b = encodeComma(b) @@ -1004,7 +988,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, '{') b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -1022,12 +1006,13 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.end.next } else { b = append(b, '{') - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) code = code.next } @@ -1048,7 +1033,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = append(b, '{') b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1057,16 +1042,17 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := load(ctxptr, code.idx) b = append(b, '{') b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: p := load(ctxptr, code.idx) b = append(b, '{') - v := ptrToUint64(p) & code.mask + u64 := ptrToUint64(p) + v := u64 & code.mask if v != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) } code = code.next @@ -1075,7 +1061,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = append(b, '{') b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1096,7 +1082,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -1115,7 +1101,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p = ptrToPtr(p + code.offset) if p != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -1138,7 +1124,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -1161,7 +1147,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -1180,7 +1166,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := load(ctxptr, code.idx) if p != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) } code = code.next @@ -1202,7 +1188,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') } b = encodeComma(b) @@ -1223,7 +1209,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeComma(b) @@ -1237,7 +1223,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.end.next } else { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -1252,12 +1238,13 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) code = code.next } @@ -1275,7 +1262,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1286,7 +1273,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.end.next } else { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next } @@ -1295,12 +1282,13 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) code = code.next } @@ -1312,7 +1300,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } else { b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -1331,7 +1319,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -1349,7 +1337,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) code = code.next } @@ -1368,7 +1356,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -1387,7 +1375,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) } b = encodeComma(b) code = code.next @@ -1405,7 +1393,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.nextField } else { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = encodeComma(b) code = code.next } @@ -1424,7 +1412,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(p+code.offset), code) b = append(b, '"') } b = encodeComma(b) @@ -3972,8 +3960,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o case opStructFieldInt: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next case opStructFieldOmitEmptyInt: @@ -3982,7 +3969,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o v := u64 & code.mask if v != 0 { b = append(b, code.escapedKey...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeComma(b) } code = code.next @@ -3990,8 +3977,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -4002,8 +3988,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -4012,8 +3997,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.escapedKey...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -4025,8 +4009,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -4044,23 +4027,23 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next case opStructFieldUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeComma(b) code = code.next case opStructFieldOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeComma(b) } code = code.next @@ -4068,7 +4051,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeComma(b) code = code.next @@ -4079,7 +4062,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeComma(b) code = code.next @@ -4088,7 +4071,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeComma(b) } code = code.next @@ -4100,7 +4083,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeComma(b) @@ -4602,8 +4585,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o case opStructEndInt: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = appendStructEnd(b) code = code.next case opStructEndOmitEmptyInt: @@ -4612,7 +4594,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o v := u64 & code.mask if v != 0 { b = append(b, code.escapedKey...) - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4628,8 +4610,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEnd(b) code = code.next @@ -4640,8 +4621,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next @@ -4650,8 +4630,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.escapedKey...) - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4671,8 +4650,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEnd(b) @@ -4690,23 +4668,23 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next case opStructEndUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = appendStructEnd(b) code = code.next case opStructEndOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, v) + b = appendUint(b, u64, code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4722,7 +4700,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEnd(b) code = code.next @@ -4733,7 +4711,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next @@ -4742,7 +4720,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o p := ptrToPtr(ptr + code.offset) if p != 0 { b = append(b, code.escapedKey...) - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = appendStructEnd(b) } else { last := len(b) - 1 @@ -4762,7 +4740,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEnd(b) @@ -4780,7 +4758,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = appendStructEnd(b) code = code.next diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go index 6792f1e..0a24438 100644 --- a/encode_vm_escaped_indent.go +++ b/encode_vm_escaped_indent.go @@ -26,12 +26,23 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next store(ctxptr, code.idx, ptrToPtr(ptr)) case opInt: - u64 := ptrToUint64(load(ctxptr, code.idx)) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = encodeIndentComma(b) code = code.next case opUint: - b = appendUint(b, ptrToUint64(load(ctxptr, code.idx))&code.mask) + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = encodeIndentComma(b) + code = code.next + case opIntString: + b = append(b, '"') + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + case opUintString: + b = append(b, '"') + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') b = encodeIndentComma(b) code = code.next case opFloat32: @@ -568,8 +579,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -595,7 +605,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -617,8 +627,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -629,8 +638,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: @@ -642,7 +650,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -652,8 +660,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -676,8 +683,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -698,8 +704,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -724,8 +729,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -750,8 +754,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -772,8 +775,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -797,8 +799,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -821,8 +822,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -838,8 +838,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -859,7 +858,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -876,8 +875,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -890,8 +888,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -908,7 +905,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -922,8 +919,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') b = append(b, '"') - u64 := ptrToUint64(ptr) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -944,8 +940,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -965,8 +960,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -987,8 +981,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1009,8 +1002,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1030,8 +1022,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -1052,8 +1043,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1072,7 +1062,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -1090,14 +1080,15 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.end.next } else { b = append(b, '{', '\n') - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -1119,7 +1110,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1130,18 +1121,19 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: p := load(ctxptr, code.idx) b = append(b, '{', '\n') - v := ptrToUint64(p) & code.mask + u64 := ptrToUint64(p) + v := u64 & code.mask if v != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -1151,7 +1143,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1174,7 +1166,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -1195,7 +1187,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -1220,7 +1212,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -1245,7 +1237,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1266,7 +1258,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -1290,7 +1282,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1313,7 +1305,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -1329,7 +1321,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -1341,14 +1333,15 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -1365,7 +1358,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1378,7 +1371,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr)&code.mask) + b = appendUint(b, ptrToUint64(ptr), code) b = encodeIndentComma(b) code = code.next } @@ -1387,14 +1380,15 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr) & code.mask + u64 := ptrToUint64(ptr) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -1408,7 +1402,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr)&code.mask) + b = appendUint(b, ptrToUint64(ptr), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1429,7 +1423,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1449,7 +1443,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -1470,7 +1464,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1491,7 +1485,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1511,7 +1505,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -1532,7 +1526,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -3661,8 +3655,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next case opStructFieldOmitEmptyInt: @@ -3673,7 +3666,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -3682,8 +3675,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -3696,8 +3688,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -3708,8 +3699,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -3723,8 +3713,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -3734,17 +3723,18 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next case opStructFieldOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -3753,7 +3743,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -3766,7 +3756,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -3777,7 +3767,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -3791,7 +3781,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -4404,8 +4394,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next case opStructEndOmitEmptyInt: @@ -4416,7 +4405,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4439,8 +4428,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4453,8 +4441,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4465,8 +4452,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4494,8 +4480,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEndIndent(ctx, b, code.indent-1) @@ -4505,17 +4490,18 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, code.escapedKey...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next case opStructEndOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4538,7 +4524,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4551,7 +4537,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4562,7 +4548,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4590,7 +4576,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEndIndent(ctx, b, code.indent-1) diff --git a/encode_vm_indent.go b/encode_vm_indent.go index de5763e..a05bc9e 100644 --- a/encode_vm_indent.go +++ b/encode_vm_indent.go @@ -26,12 +26,23 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next store(ctxptr, code.idx, ptrToPtr(ptr)) case opInt: - u64 := ptrToUint64(load(ctxptr, code.idx)) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = encodeIndentComma(b) code = code.next case opUint: - b = appendUint(b, ptrToUint64(load(ctxptr, code.idx))&code.mask) + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = encodeIndentComma(b) + code = code.next + case opIntString: + b = append(b, '"') + b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + case opUintString: + b = append(b, '"') + b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) + b = append(b, '"') b = encodeIndentComma(b) code = code.next case opFloat32: @@ -568,8 +579,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -595,7 +605,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -617,8 +627,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ', '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -629,8 +638,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyIntOnly, opStructFieldHeadOmitEmptyIntOnly: @@ -642,7 +650,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -652,8 +660,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ', '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -676,8 +683,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -698,8 +704,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -724,8 +729,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -750,8 +754,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -772,8 +775,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -797,8 +799,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -821,8 +822,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -838,8 +838,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -859,7 +858,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -876,8 +875,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') b = append(b, '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -890,8 +888,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -908,7 +905,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -922,8 +919,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') b = append(b, '"') - u64 := ptrToUint64(ptr) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -944,8 +940,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -965,8 +960,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -987,8 +981,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1009,8 +1002,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1030,8 +1022,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -1052,8 +1043,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1072,7 +1062,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -1090,14 +1080,15 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.end.next } else { b = append(b, '{', '\n') - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -1119,7 +1110,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1130,18 +1121,19 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next case opStructFieldPtrHeadOmitEmptyUintOnly, opStructFieldHeadOmitEmptyUintOnly: p := load(ctxptr, code.idx) b = append(b, '{', '\n') - v := ptrToUint64(p) & code.mask + u64 := ptrToUint64(p) + v := u64 & code.mask if v != 0 { b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -1151,7 +1143,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1174,7 +1166,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -1195,7 +1187,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -1220,7 +1212,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } } @@ -1245,7 +1237,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1266,7 +1258,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -1290,7 +1282,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1313,7 +1305,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } } b = encodeIndentComma(b) @@ -1329,7 +1321,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next } @@ -1341,14 +1333,15 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -1365,7 +1358,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1378,7 +1371,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(ptr)&code.mask) + b = appendUint(b, ptrToUint64(ptr), code) b = encodeIndentComma(b) code = code.next } @@ -1387,14 +1380,15 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if ptr == 0 { code = code.end.next } else { - v := ptrToUint64(ptr) & code.mask + u64 := ptrToUint64(ptr) + v := u64 & code.mask if v == 0 { code = code.nextField } else { b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) code = code.next } @@ -1408,7 +1402,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') b = append(b, '"') - b = appendUint(b, ptrToUint64(ptr)&code.mask) + b = appendUint(b, ptrToUint64(ptr), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -1429,7 +1423,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1449,7 +1443,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -1470,7 +1464,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -1491,7 +1485,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -1511,7 +1505,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) code = code.next } @@ -1532,7 +1526,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -3661,8 +3655,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next case opStructFieldOmitEmptyInt: @@ -3673,7 +3666,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -3682,8 +3675,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ', '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -3696,8 +3688,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -3708,8 +3699,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -3723,8 +3713,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -3734,17 +3723,18 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = encodeIndentComma(b) code = code.next case opStructFieldOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = encodeIndentComma(b) } code = code.next @@ -3753,7 +3743,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = encodeIndentComma(b) code = code.next @@ -3766,7 +3756,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = encodeIndentComma(b) code = code.next @@ -3777,7 +3767,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = encodeIndentComma(b) } code = code.next @@ -3791,7 +3781,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = encodeIndentComma(b) @@ -4403,8 +4393,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next case opStructEndOmitEmptyInt: @@ -4415,7 +4404,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendInt(b, v, u64>>code.rshiftNum == 1) + b = appendInt(b, u64, code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4438,8 +4427,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ', '"') - u64 := ptrToUint64(ptr + code.offset) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4452,8 +4440,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) } b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4464,8 +4451,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4493,8 +4479,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, u64>>code.rshiftNum == 1) + b = appendInt(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEndIndent(ctx, b, code.indent-1) @@ -4504,17 +4489,18 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, code.key...) b = append(b, ' ') ptr := load(ctxptr, code.headIdx) - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next case opStructEndOmitEmptyUint: ptr := load(ctxptr, code.headIdx) - v := ptrToUint64(ptr+code.offset) & code.mask + u64 := ptrToUint64(ptr + code.offset) + v := u64 & code.mask if v != 0 { b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, v) + b = appendUint(b, u64, code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4537,7 +4523,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ', '"') - b = appendUint(b, ptrToUint64(ptr+code.offset)&code.mask) + b = appendUint(b, ptrToUint64(ptr+code.offset), code) b = append(b, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4550,7 +4536,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) } b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next @@ -4561,7 +4547,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) b = append(b, ' ') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = appendStructEndIndent(ctx, b, code.indent-1) } else { last := len(b) - 1 @@ -4589,7 +4575,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeNull(b) } else { b = append(b, '"') - b = appendUint(b, ptrToUint64(p)&code.mask) + b = appendUint(b, ptrToUint64(p), code) b = append(b, '"') } b = appendStructEndIndent(ctx, b, code.indent-1)