Add pointer operation

This commit is contained in:
Masaaki Goshima 2021-02-23 15:57:32 +09:00
parent c8f6acaa2b
commit ae68eaf96b
4 changed files with 609 additions and 1 deletions

View File

@ -87,10 +87,58 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opIntPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opIntNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opUint: case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opUintPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opUintNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opIntString: case opIntString:
b = append(b, '"') b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
@ -107,6 +155,30 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx))) b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opFloat32Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeComma(b)
code = code.next
case opFloat32NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeComma(b)
code = code.next
case opFloat64: case opFloat64:
v := ptrToFloat64(load(ctxptr, code.idx)) v := ptrToFloat64(load(ctxptr, code.idx))
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -115,18 +187,98 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
b = encodeFloat64(b, v) b = encodeFloat64(b, v)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opFloat64Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
case opFloat64NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
case opString: case opString:
b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx))) b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStringPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeComma(b)
code = code.next
case opStringNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeComma(b)
code = code.next
case opBool: case opBool:
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx))) b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opBoolPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeComma(b)
code = code.next
case opBoolNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeComma(b)
code = code.next
case opBytes: case opBytes:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
slice := ptrToSlice(ptr) slice := ptrToSlice(ptr)
if ptr == 0 || uintptr(slice.data) == 0 { if ptr == 0 || slice.data == nil {
b = encodeNull(b) b = encodeNull(b)
} else { } else {
b = encodeByteSlice(b, ptrToBytes(ptr)) b = encodeByteSlice(b, ptrToBytes(ptr))

View File

@ -30,10 +30,58 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opIntPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opIntNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opUint: case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opUintPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opUintNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opIntString: case opIntString:
b = append(b, '"') b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
@ -50,6 +98,30 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx))) b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opFloat32Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeComma(b)
code = code.next
case opFloat32NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeComma(b)
code = code.next
case opFloat64: case opFloat64:
v := ptrToFloat64(load(ctxptr, code.idx)) v := ptrToFloat64(load(ctxptr, code.idx))
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -58,14 +130,94 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = encodeFloat64(b, v) b = encodeFloat64(b, v)
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opFloat64Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
case opFloat64NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeComma(b)
code = code.next
case opString: case opString:
b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx))) b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opStringPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeComma(b)
code = code.next
case opStringNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeComma(b)
code = code.next
case opBool: case opBool:
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx))) b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
case opBoolPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeComma(b)
code = code.next
case opBoolNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeComma(b)
code = code.next
case opBytes: case opBytes:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
slice := ptrToSlice(ptr) slice := ptrToSlice(ptr)

View File

@ -29,10 +29,58 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opIntPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opIntNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opUint: case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opUintPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opUintNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opIntString: case opIntString:
b = append(b, '"') b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
@ -49,6 +97,30 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx))) b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opFloat32Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeIndentComma(b)
code = code.next
case opFloat32NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeIndentComma(b)
code = code.next
case opFloat64: case opFloat64:
v := ptrToFloat64(load(ctxptr, code.idx)) v := ptrToFloat64(load(ctxptr, code.idx))
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -57,14 +129,94 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
b = encodeFloat64(b, v) b = encodeFloat64(b, v)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opFloat64Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeIndentComma(b)
code = code.next
case opFloat64NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeIndentComma(b)
code = code.next
case opString: case opString:
b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx))) b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx)))
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStringPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeIndentComma(b)
code = code.next
case opStringNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeIndentComma(b)
code = code.next
case opBool: case opBool:
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx))) b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opBoolPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeIndentComma(b)
code = code.next
case opBoolNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeIndentComma(b)
code = code.next
case opBytes: case opBytes:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
slice := ptrToSlice(ptr) slice := ptrToSlice(ptr)

View File

@ -29,10 +29,58 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opIntPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opIntNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opUint: case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opUintPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opUintNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeIndentComma(b)
code = code.next
case opIntString: case opIntString:
b = append(b, '"') b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code) b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
@ -49,6 +97,30 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx))) b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opFloat32Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeIndentComma(b)
code = code.next
case opFloat32NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeIndentComma(b)
code = code.next
case opFloat64: case opFloat64:
v := ptrToFloat64(load(ctxptr, code.idx)) v := ptrToFloat64(load(ctxptr, code.idx))
if math.IsInf(v, 0) || math.IsNaN(v) { if math.IsInf(v, 0) || math.IsNaN(v) {
@ -57,14 +129,94 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
b = encodeFloat64(b, v) b = encodeFloat64(b, v)
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opFloat64Ptr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeIndentComma(b)
code = code.next
case opFloat64NPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
}
b = encodeIndentComma(b)
code = code.next
case opString: case opString:
b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx))) b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx)))
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStringPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeIndentComma(b)
code = code.next
case opStringNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeEscapedString(b, ptrToString(p))
}
b = encodeIndentComma(b)
code = code.next
case opBool: case opBool:
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx))) b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opBoolPtr:
p := ptrToPtr(load(ctxptr, code.idx))
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeIndentComma(b)
code = code.next
case opBoolNPtr:
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
if p == 0 {
b = encodeNull(b)
} else {
b = encodeBool(b, ptrToBool(p))
}
b = encodeIndentComma(b)
code = code.next
case opBytes: case opBytes:
ptr := load(ctxptr, code.idx) ptr := load(ctxptr, code.idx)
slice := ptrToSlice(ptr) slice := ptrToSlice(ptr)