forked from mirror/go-json
Remove escaped optype
This commit is contained in:
parent
4cfb919183
commit
9c5f6ec0e6
|
@ -14,7 +14,6 @@ import (
|
||||||
type opType struct {
|
type opType struct {
|
||||||
Op string
|
Op string
|
||||||
Code string
|
Code string
|
||||||
Escaped func() string
|
|
||||||
HeadToPtrHead func() string
|
HeadToPtrHead func() string
|
||||||
HeadToNPtrHead func() string
|
HeadToNPtrHead func() string
|
||||||
HeadToAnonymousHead func() string
|
HeadToAnonymousHead func() string
|
||||||
|
@ -27,10 +26,6 @@ type opType struct {
|
||||||
FieldToStringTagField func() string
|
FieldToStringTagField func() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t opType) IsEscaped() bool {
|
|
||||||
return t.Op != t.Escaped()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t opType) IsHeadToPtrHead() bool {
|
func (t opType) IsHeadToPtrHead() bool {
|
||||||
return t.Op != t.HeadToPtrHead()
|
return t.Op != t.HeadToPtrHead()
|
||||||
}
|
}
|
||||||
|
@ -75,7 +70,6 @@ func createOpType(op, code string) opType {
|
||||||
return opType{
|
return opType{
|
||||||
Op: op,
|
Op: op,
|
||||||
Code: code,
|
Code: code,
|
||||||
Escaped: func() string { return op },
|
|
||||||
HeadToPtrHead: func() string { return op },
|
HeadToPtrHead: func() string { return op },
|
||||||
HeadToNPtrHead: func() string { return op },
|
HeadToNPtrHead: func() string { return op },
|
||||||
HeadToAnonymousHead: func() string { return op },
|
HeadToAnonymousHead: func() string { return op },
|
||||||
|
@ -158,31 +152,6 @@ func (t opType) codeType() codeType {
|
||||||
return codeOp
|
return codeOp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t opType) toEscaped() opType {
|
|
||||||
if strings.Index(t.String(), "Escaped") > 0 {
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
if t.String() == "String" {
|
|
||||||
return opType(int(t) + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldHeadIdx := strings.Index(t.String(), "Head")
|
|
||||||
if fieldHeadIdx > 0 && strings.Contains(t.String(), "Struct") {
|
|
||||||
const toEscapedHeadOffset = 36
|
|
||||||
return opType(int(t) + toEscapedHeadOffset)
|
|
||||||
}
|
|
||||||
fieldIdx := strings.Index(t.String(), "Field")
|
|
||||||
if fieldIdx > 0 && strings.Contains(t.String(), "Struct") {
|
|
||||||
const toEscapedFieldOffset = 3
|
|
||||||
return opType(int(t) + toEscapedFieldOffset)
|
|
||||||
}
|
|
||||||
if strings.Contains(t.String(), "StructEnd") {
|
|
||||||
const toEscapedEndOffset = 3
|
|
||||||
return opType(int(t) + toEscapedEndOffset)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t opType) headToPtrHead() opType {
|
func (t opType) headToPtrHead() opType {
|
||||||
if strings.Index(t.String(), "PtrHead") > 0 {
|
if strings.Index(t.String(), "PtrHead") > 0 {
|
||||||
return t
|
return t
|
||||||
|
@ -325,16 +294,16 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
primitiveTypes := []string{
|
primitiveTypes := []string{
|
||||||
"int", "int8", "int16", "int32", "int64",
|
"int", "int8", "int16", "int32", "int64",
|
||||||
"uint", "uint8", "uint16", "uint32", "uint64",
|
"uint", "uint8", "uint16", "uint32", "uint64",
|
||||||
"float32", "float64", "bool", "string", "escapedString", "bytes",
|
"float32", "float64", "bool", "string", "bytes",
|
||||||
"array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive",
|
"array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive",
|
||||||
"intString", "int8String", "int16String", "int32String", "int64String",
|
"intString", "int8String", "int16String", "int32String", "int64String",
|
||||||
"uintString", "uint8String", "uint16String", "uint32String", "uint64String",
|
"uintString", "uint8String", "uint16String", "uint32String", "uint64String",
|
||||||
"intPtr", "int8Ptr", "int16Ptr", "int32Ptr", "int64Ptr",
|
"intPtr", "int8Ptr", "int16Ptr", "int32Ptr", "int64Ptr",
|
||||||
"uintPtr", "uint8Ptr", "uint16Ptr", "uint32Ptr", "uint64Ptr",
|
"uintPtr", "uint8Ptr", "uint16Ptr", "uint32Ptr", "uint64Ptr",
|
||||||
"float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "escapedStringPtr", "bytesPtr",
|
"float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr",
|
||||||
"intNPtr", "int8NPtr", "int16NPtr", "int32NPtr", "int64NPtr",
|
"intNPtr", "int8NPtr", "int16NPtr", "int32NPtr", "int64NPtr",
|
||||||
"uintNPtr", "uint8NPtr", "uint16NPtr", "uint32NPtr", "uint64NPtr",
|
"uintNPtr", "uint8NPtr", "uint16NPtr", "uint32NPtr", "uint64NPtr",
|
||||||
"float32NPtr", "float64NPtr", "boolNPtr", "stringNPtr", "escapedStringNPtr", "bytesNPtr",
|
"float32NPtr", "float64NPtr", "boolNPtr", "stringNPtr", "bytesNPtr",
|
||||||
}
|
}
|
||||||
primitiveTypesUpper := []string{}
|
primitiveTypesUpper := []string{}
|
||||||
for _, typ := range primitiveTypes {
|
for _, typ := range primitiveTypes {
|
||||||
|
@ -364,41 +333,21 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
}
|
}
|
||||||
for _, typ := range primitiveTypesUpper {
|
for _, typ := range primitiveTypesUpper {
|
||||||
typ := typ
|
typ := typ
|
||||||
optype := createOpType(typ, "Op")
|
opTypes = append(opTypes, createOpType(typ, "Op"))
|
||||||
switch typ {
|
|
||||||
case "String", "StringPtr", "StringNPtr":
|
|
||||||
optype.Escaped = func() string {
|
|
||||||
return fmt.Sprintf("Escaped%s", typ)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opTypes = append(opTypes, optype)
|
|
||||||
}
|
}
|
||||||
for _, typ := range append(primitiveTypesUpper, "") {
|
for _, typ := range append(primitiveTypesUpper, "") {
|
||||||
if typ == "EscapedString" || typ == "EscapedStringPtr" || typ == "EscapedStringNPtr" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, escapedOrNot := range []string{"", "Escaped"} {
|
|
||||||
for _, ptrOrNot := range []string{"", "Ptr", "NPtr"} {
|
for _, ptrOrNot := range []string{"", "Ptr", "NPtr"} {
|
||||||
for _, headType := range []string{"", "Anonymous"} {
|
for _, headType := range []string{"", "Anonymous"} {
|
||||||
for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
|
for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
|
||||||
for _, onlyOrNot := range []string{"", "Only"} {
|
for _, onlyOrNot := range []string{"", "Only"} {
|
||||||
escapedOrNot := escapedOrNot
|
|
||||||
ptrOrNot := ptrOrNot
|
ptrOrNot := ptrOrNot
|
||||||
headType := headType
|
headType := headType
|
||||||
opt := opt
|
opt := opt
|
||||||
typ := typ
|
typ := typ
|
||||||
onlyOrNot := onlyOrNot
|
onlyOrNot := onlyOrNot
|
||||||
|
|
||||||
isEscaped := escapedOrNot != ""
|
|
||||||
isString := typ == "String" || typ == "StringPtr" || typ == "StringNPtr"
|
|
||||||
|
|
||||||
if isEscaped && isString {
|
|
||||||
typ = "Escaped" + typ
|
|
||||||
}
|
|
||||||
|
|
||||||
op := fmt.Sprintf(
|
op := fmt.Sprintf(
|
||||||
"Struct%sField%s%sHead%s%s%s",
|
"StructField%s%sHead%s%s%s",
|
||||||
escapedOrNot,
|
|
||||||
ptrOrNot,
|
ptrOrNot,
|
||||||
headType,
|
headType,
|
||||||
opt,
|
opt,
|
||||||
|
@ -408,31 +357,9 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
opTypes = append(opTypes, opType{
|
opTypes = append(opTypes, opType{
|
||||||
Op: op,
|
Op: op,
|
||||||
Code: "StructField",
|
Code: "StructField",
|
||||||
Escaped: func() string {
|
|
||||||
switch typ {
|
|
||||||
case "String", "StringPtr", "StringNPtr":
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"StructEscapedField%s%sHead%sEscaped%s%s",
|
|
||||||
ptrOrNot,
|
|
||||||
headType,
|
|
||||||
opt,
|
|
||||||
typ,
|
|
||||||
onlyOrNot,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"StructEscapedField%s%sHead%s%s%s",
|
|
||||||
ptrOrNot,
|
|
||||||
headType,
|
|
||||||
opt,
|
|
||||||
typ,
|
|
||||||
onlyOrNot,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
HeadToPtrHead: func() string {
|
HeadToPtrHead: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sFieldPtr%sHead%s%s%s",
|
"StructFieldPtr%sHead%s%s%s",
|
||||||
escapedOrNot,
|
|
||||||
headType,
|
headType,
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
|
@ -441,8 +368,7 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
},
|
},
|
||||||
HeadToNPtrHead: func() string {
|
HeadToNPtrHead: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sFieldNPtr%sHead%s%s%s",
|
"StructFieldNPtr%sHead%s%s%s",
|
||||||
escapedOrNot,
|
|
||||||
headType,
|
headType,
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
|
@ -451,8 +377,7 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
},
|
},
|
||||||
HeadToAnonymousHead: func() string {
|
HeadToAnonymousHead: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sField%sAnonymousHead%s%s%s",
|
"StructField%sAnonymousHead%s%s%s",
|
||||||
escapedOrNot,
|
|
||||||
ptrOrNot,
|
ptrOrNot,
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
|
@ -461,8 +386,7 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
},
|
},
|
||||||
HeadToOmitEmptyHead: func() string {
|
HeadToOmitEmptyHead: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sField%s%sHeadOmitEmpty%s%s",
|
"StructField%s%sHeadOmitEmpty%s%s",
|
||||||
escapedOrNot,
|
|
||||||
ptrOrNot,
|
ptrOrNot,
|
||||||
headType,
|
headType,
|
||||||
typ,
|
typ,
|
||||||
|
@ -471,8 +395,7 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
},
|
},
|
||||||
HeadToStringTagHead: func() string {
|
HeadToStringTagHead: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sField%s%sHeadStringTag%s%s",
|
"StructField%s%sHeadStringTag%s%s",
|
||||||
escapedOrNot,
|
|
||||||
ptrOrNot,
|
ptrOrNot,
|
||||||
headType,
|
headType,
|
||||||
typ,
|
typ,
|
||||||
|
@ -488,8 +411,7 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
return op
|
return op
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sField%s%sHead%s%sOnly",
|
"StructField%s%sHead%s%sOnly",
|
||||||
escapedOrNot,
|
|
||||||
ptrOrNot,
|
ptrOrNot,
|
||||||
headType,
|
headType,
|
||||||
opt,
|
opt,
|
||||||
|
@ -498,8 +420,7 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
},
|
},
|
||||||
PtrHeadToHead: func() string {
|
PtrHeadToHead: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sField%sHead%s%s%s",
|
"StructField%sHead%s%s%s",
|
||||||
escapedOrNot,
|
|
||||||
headType,
|
headType,
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
|
@ -515,48 +436,19 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for _, typ := range append(primitiveTypesUpper, "") {
|
for _, typ := range append(primitiveTypesUpper, "") {
|
||||||
if typ == "EscapedString" || typ == "EscapedStringPtr" || typ == "EscapedStringNPtr" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, escapedOrNot := range []string{"", "Escaped"} {
|
|
||||||
for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
|
for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
|
||||||
escapedOrNot := escapedOrNot
|
|
||||||
opt := opt
|
opt := opt
|
||||||
typ := typ
|
typ := typ
|
||||||
|
|
||||||
isEscaped := escapedOrNot != ""
|
|
||||||
isString := typ == "String" || typ == "StringPtr" || typ == "StringNPtr"
|
|
||||||
|
|
||||||
if isEscaped && isString {
|
|
||||||
typ = "Escaped" + typ
|
|
||||||
}
|
|
||||||
|
|
||||||
op := fmt.Sprintf(
|
op := fmt.Sprintf(
|
||||||
"Struct%sField%s%s",
|
"StructField%s%s",
|
||||||
escapedOrNot,
|
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
)
|
)
|
||||||
opTypes = append(opTypes, opType{
|
opTypes = append(opTypes, opType{
|
||||||
Op: op,
|
Op: op,
|
||||||
Code: "StructField",
|
Code: "StructField",
|
||||||
Escaped: func() string {
|
|
||||||
switch typ {
|
|
||||||
case "String", "StringPtr", "StringNPtr":
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"StructEscapedField%sEscaped%s",
|
|
||||||
opt,
|
|
||||||
typ,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"StructEscapedField%s%s",
|
|
||||||
opt,
|
|
||||||
typ,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
HeadToPtrHead: func() string { return op },
|
HeadToPtrHead: func() string { return op },
|
||||||
HeadToNPtrHead: func() string { return op },
|
HeadToNPtrHead: func() string { return op },
|
||||||
HeadToAnonymousHead: func() string { return op },
|
HeadToAnonymousHead: func() string { return op },
|
||||||
|
@ -570,71 +462,39 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
return op
|
return op
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sEnd%s%s",
|
"StructEnd%s%s",
|
||||||
escapedOrNot,
|
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
FieldToOmitEmptyField: func() string {
|
FieldToOmitEmptyField: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sFieldOmitEmpty%s",
|
"StructFieldOmitEmpty%s",
|
||||||
escapedOrNot,
|
|
||||||
typ,
|
typ,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
FieldToStringTagField: func() string {
|
FieldToStringTagField: func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"Struct%sFieldStringTag%s",
|
"StructFieldStringTag%s",
|
||||||
escapedOrNot,
|
|
||||||
typ,
|
typ,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for _, typ := range append(primitiveTypesUpper, "") {
|
for _, typ := range append(primitiveTypesUpper, "") {
|
||||||
if typ == "EscapedString" || typ == "EscapedStringPtr" || typ == "EscapedStringNPtr" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, escapedOrNot := range []string{"", "Escaped"} {
|
|
||||||
for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
|
for _, opt := range []string{"", "OmitEmpty", "StringTag"} {
|
||||||
escapedOrNot := escapedOrNot
|
|
||||||
opt := opt
|
opt := opt
|
||||||
typ := typ
|
typ := typ
|
||||||
|
|
||||||
isEscaped := escapedOrNot != ""
|
|
||||||
isString := typ == "String" || typ == "StringPtr" || typ == "StringNPtr"
|
|
||||||
|
|
||||||
if isEscaped && isString {
|
|
||||||
typ = "Escaped" + typ
|
|
||||||
}
|
|
||||||
|
|
||||||
op := fmt.Sprintf(
|
op := fmt.Sprintf(
|
||||||
"Struct%sEnd%s%s",
|
"StructEnd%s%s",
|
||||||
escapedOrNot,
|
|
||||||
opt,
|
opt,
|
||||||
typ,
|
typ,
|
||||||
)
|
)
|
||||||
opTypes = append(opTypes, opType{
|
opTypes = append(opTypes, opType{
|
||||||
Op: op,
|
Op: op,
|
||||||
Code: "StructEnd",
|
Code: "StructEnd",
|
||||||
Escaped: func() string {
|
|
||||||
switch typ {
|
|
||||||
case "String", "StringPtr", "StringNPtr":
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"StructEscapedEnd%sEscaped%s",
|
|
||||||
opt,
|
|
||||||
typ,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"StructEscapedEnd%s%s",
|
|
||||||
opt,
|
|
||||||
typ,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
HeadToPtrHead: func() string { return op },
|
HeadToPtrHead: func() string { return op },
|
||||||
HeadToNPtrHead: func() string { return op },
|
HeadToNPtrHead: func() string { return op },
|
||||||
HeadToAnonymousHead: func() string { return op },
|
HeadToAnonymousHead: func() string { return op },
|
||||||
|
@ -648,7 +508,6 @@ func (t opType) fieldToStringTagField() opType {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
if err := tmpl.Execute(&b, struct {
|
if err := tmpl.Execute(&b, struct {
|
||||||
CodeTypes []string
|
CodeTypes []string
|
||||||
|
|
10
encode.go
10
encode.go
|
@ -42,7 +42,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type opcodeSet struct {
|
type opcodeSet struct {
|
||||||
escapedCode *opcode
|
|
||||||
code *opcode
|
code *opcode
|
||||||
codeLength int
|
codeLength int
|
||||||
}
|
}
|
||||||
|
@ -198,13 +197,13 @@ func (e *Encoder) encode(header *interfaceHeader, isNil bool) ([]byte, error) {
|
||||||
|
|
||||||
if e.enabledIndent {
|
if e.enabledIndent {
|
||||||
if e.enabledHTMLEscape {
|
if e.enabledHTMLEscape {
|
||||||
return e.runEscapedIndent(ctx, b, codeSet.escapedCode)
|
return e.runEscapedIndent(ctx, b, codeSet.code)
|
||||||
} else {
|
} else {
|
||||||
return e.runIndent(ctx, b, codeSet.code)
|
return e.runIndent(ctx, b, codeSet.code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if e.enabledHTMLEscape {
|
if e.enabledHTMLEscape {
|
||||||
return e.runEscaped(ctx, b, codeSet.escapedCode)
|
return e.runEscaped(ctx, b, codeSet.code)
|
||||||
}
|
}
|
||||||
return e.run(ctx, b, codeSet.code)
|
return e.run(ctx, b, codeSet.code)
|
||||||
}
|
}
|
||||||
|
@ -223,7 +222,6 @@ func (e *Encoder) encode(header *interfaceHeader, isNil bool) ([]byte, error) {
|
||||||
code = copyOpcode(code)
|
code = copyOpcode(code)
|
||||||
codeLength := code.totalLength()
|
codeLength := code.totalLength()
|
||||||
codeSet := &opcodeSet{
|
codeSet := &opcodeSet{
|
||||||
escapedCode: toEscaped(code),
|
|
||||||
code: code,
|
code: code,
|
||||||
codeLength: codeLength,
|
codeLength: codeLength,
|
||||||
}
|
}
|
||||||
|
@ -235,13 +233,13 @@ func (e *Encoder) encode(header *interfaceHeader, isNil bool) ([]byte, error) {
|
||||||
|
|
||||||
if e.enabledIndent {
|
if e.enabledIndent {
|
||||||
if e.enabledHTMLEscape {
|
if e.enabledHTMLEscape {
|
||||||
return e.runEscapedIndent(ctx, b, codeSet.escapedCode)
|
return e.runEscapedIndent(ctx, b, codeSet.code)
|
||||||
} else {
|
} else {
|
||||||
return e.runIndent(ctx, b, codeSet.code)
|
return e.runIndent(ctx, b, codeSet.code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if e.enabledHTMLEscape {
|
if e.enabledHTMLEscape {
|
||||||
return e.runEscaped(ctx, b, codeSet.escapedCode)
|
return e.runEscaped(ctx, b, codeSet.code)
|
||||||
}
|
}
|
||||||
return e.run(ctx, b, codeSet.code)
|
return e.run(ctx, b, codeSet.code)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,20 +53,6 @@ func copyOpcode(code *opcode) *opcode {
|
||||||
return code.copy(codeMap)
|
return code.copy(codeMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toEscaped(c *opcode) *opcode {
|
|
||||||
c = copyOpcode(c)
|
|
||||||
for code := c; code.op != opEnd; {
|
|
||||||
code.op = code.op.toEscaped()
|
|
||||||
switch code.op.codeType() {
|
|
||||||
case codeArrayElem, codeSliceElem, codeMapKey:
|
|
||||||
code = code.end
|
|
||||||
default:
|
|
||||||
code = code.next
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func newOpCodeWithNext(ctx *encodeCompileContext, op opType, next *opcode) *opcode {
|
func newOpCodeWithNext(ctx *encodeCompileContext, op opType, next *opcode) *opcode {
|
||||||
return &opcode{
|
return &opcode{
|
||||||
op: op,
|
op: op,
|
||||||
|
|
13914
encode_optype.go
13914
encode_optype.go
File diff suppressed because it is too large
Load Diff
1047
encode_vm_escaped.go
1047
encode_vm_escaped.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue