1
2 package encoder
3
4 import (
5 "strings"
6 )
7
8 type CodeType int
9
10 const (
11 CodeOp CodeType = 0
12 CodeArrayHead CodeType = 1
13 CodeArrayElem CodeType = 2
14 CodeSliceHead CodeType = 3
15 CodeSliceElem CodeType = 4
16 CodeMapHead CodeType = 5
17 CodeMapKey CodeType = 6
18 CodeMapValue CodeType = 7
19 CodeMapEnd CodeType = 8
20 CodeRecursive CodeType = 9
21 CodeStructField CodeType = 10
22 CodeStructEnd CodeType = 11
23 )
24
25 var opTypeStrings = [400]string{
26 "End",
27 "Interface",
28 "Ptr",
29 "SliceElem",
30 "SliceEnd",
31 "ArrayElem",
32 "ArrayEnd",
33 "MapKey",
34 "MapValue",
35 "MapEnd",
36 "Recursive",
37 "RecursivePtr",
38 "RecursiveEnd",
39 "InterfaceEnd",
40 "Int",
41 "Uint",
42 "Float32",
43 "Float64",
44 "Bool",
45 "String",
46 "Bytes",
47 "Number",
48 "Array",
49 "Map",
50 "Slice",
51 "Struct",
52 "MarshalJSON",
53 "MarshalText",
54 "IntString",
55 "UintString",
56 "Float32String",
57 "Float64String",
58 "BoolString",
59 "StringString",
60 "NumberString",
61 "IntPtr",
62 "UintPtr",
63 "Float32Ptr",
64 "Float64Ptr",
65 "BoolPtr",
66 "StringPtr",
67 "BytesPtr",
68 "NumberPtr",
69 "ArrayPtr",
70 "MapPtr",
71 "SlicePtr",
72 "MarshalJSONPtr",
73 "MarshalTextPtr",
74 "InterfacePtr",
75 "IntPtrString",
76 "UintPtrString",
77 "Float32PtrString",
78 "Float64PtrString",
79 "BoolPtrString",
80 "StringPtrString",
81 "NumberPtrString",
82 "StructHeadInt",
83 "StructHeadOmitEmptyInt",
84 "StructPtrHeadInt",
85 "StructPtrHeadOmitEmptyInt",
86 "StructHeadUint",
87 "StructHeadOmitEmptyUint",
88 "StructPtrHeadUint",
89 "StructPtrHeadOmitEmptyUint",
90 "StructHeadFloat32",
91 "StructHeadOmitEmptyFloat32",
92 "StructPtrHeadFloat32",
93 "StructPtrHeadOmitEmptyFloat32",
94 "StructHeadFloat64",
95 "StructHeadOmitEmptyFloat64",
96 "StructPtrHeadFloat64",
97 "StructPtrHeadOmitEmptyFloat64",
98 "StructHeadBool",
99 "StructHeadOmitEmptyBool",
100 "StructPtrHeadBool",
101 "StructPtrHeadOmitEmptyBool",
102 "StructHeadString",
103 "StructHeadOmitEmptyString",
104 "StructPtrHeadString",
105 "StructPtrHeadOmitEmptyString",
106 "StructHeadBytes",
107 "StructHeadOmitEmptyBytes",
108 "StructPtrHeadBytes",
109 "StructPtrHeadOmitEmptyBytes",
110 "StructHeadNumber",
111 "StructHeadOmitEmptyNumber",
112 "StructPtrHeadNumber",
113 "StructPtrHeadOmitEmptyNumber",
114 "StructHeadArray",
115 "StructHeadOmitEmptyArray",
116 "StructPtrHeadArray",
117 "StructPtrHeadOmitEmptyArray",
118 "StructHeadMap",
119 "StructHeadOmitEmptyMap",
120 "StructPtrHeadMap",
121 "StructPtrHeadOmitEmptyMap",
122 "StructHeadSlice",
123 "StructHeadOmitEmptySlice",
124 "StructPtrHeadSlice",
125 "StructPtrHeadOmitEmptySlice",
126 "StructHeadStruct",
127 "StructHeadOmitEmptyStruct",
128 "StructPtrHeadStruct",
129 "StructPtrHeadOmitEmptyStruct",
130 "StructHeadMarshalJSON",
131 "StructHeadOmitEmptyMarshalJSON",
132 "StructPtrHeadMarshalJSON",
133 "StructPtrHeadOmitEmptyMarshalJSON",
134 "StructHeadMarshalText",
135 "StructHeadOmitEmptyMarshalText",
136 "StructPtrHeadMarshalText",
137 "StructPtrHeadOmitEmptyMarshalText",
138 "StructHeadIntString",
139 "StructHeadOmitEmptyIntString",
140 "StructPtrHeadIntString",
141 "StructPtrHeadOmitEmptyIntString",
142 "StructHeadUintString",
143 "StructHeadOmitEmptyUintString",
144 "StructPtrHeadUintString",
145 "StructPtrHeadOmitEmptyUintString",
146 "StructHeadFloat32String",
147 "StructHeadOmitEmptyFloat32String",
148 "StructPtrHeadFloat32String",
149 "StructPtrHeadOmitEmptyFloat32String",
150 "StructHeadFloat64String",
151 "StructHeadOmitEmptyFloat64String",
152 "StructPtrHeadFloat64String",
153 "StructPtrHeadOmitEmptyFloat64String",
154 "StructHeadBoolString",
155 "StructHeadOmitEmptyBoolString",
156 "StructPtrHeadBoolString",
157 "StructPtrHeadOmitEmptyBoolString",
158 "StructHeadStringString",
159 "StructHeadOmitEmptyStringString",
160 "StructPtrHeadStringString",
161 "StructPtrHeadOmitEmptyStringString",
162 "StructHeadNumberString",
163 "StructHeadOmitEmptyNumberString",
164 "StructPtrHeadNumberString",
165 "StructPtrHeadOmitEmptyNumberString",
166 "StructHeadIntPtr",
167 "StructHeadOmitEmptyIntPtr",
168 "StructPtrHeadIntPtr",
169 "StructPtrHeadOmitEmptyIntPtr",
170 "StructHeadUintPtr",
171 "StructHeadOmitEmptyUintPtr",
172 "StructPtrHeadUintPtr",
173 "StructPtrHeadOmitEmptyUintPtr",
174 "StructHeadFloat32Ptr",
175 "StructHeadOmitEmptyFloat32Ptr",
176 "StructPtrHeadFloat32Ptr",
177 "StructPtrHeadOmitEmptyFloat32Ptr",
178 "StructHeadFloat64Ptr",
179 "StructHeadOmitEmptyFloat64Ptr",
180 "StructPtrHeadFloat64Ptr",
181 "StructPtrHeadOmitEmptyFloat64Ptr",
182 "StructHeadBoolPtr",
183 "StructHeadOmitEmptyBoolPtr",
184 "StructPtrHeadBoolPtr",
185 "StructPtrHeadOmitEmptyBoolPtr",
186 "StructHeadStringPtr",
187 "StructHeadOmitEmptyStringPtr",
188 "StructPtrHeadStringPtr",
189 "StructPtrHeadOmitEmptyStringPtr",
190 "StructHeadBytesPtr",
191 "StructHeadOmitEmptyBytesPtr",
192 "StructPtrHeadBytesPtr",
193 "StructPtrHeadOmitEmptyBytesPtr",
194 "StructHeadNumberPtr",
195 "StructHeadOmitEmptyNumberPtr",
196 "StructPtrHeadNumberPtr",
197 "StructPtrHeadOmitEmptyNumberPtr",
198 "StructHeadArrayPtr",
199 "StructHeadOmitEmptyArrayPtr",
200 "StructPtrHeadArrayPtr",
201 "StructPtrHeadOmitEmptyArrayPtr",
202 "StructHeadMapPtr",
203 "StructHeadOmitEmptyMapPtr",
204 "StructPtrHeadMapPtr",
205 "StructPtrHeadOmitEmptyMapPtr",
206 "StructHeadSlicePtr",
207 "StructHeadOmitEmptySlicePtr",
208 "StructPtrHeadSlicePtr",
209 "StructPtrHeadOmitEmptySlicePtr",
210 "StructHeadMarshalJSONPtr",
211 "StructHeadOmitEmptyMarshalJSONPtr",
212 "StructPtrHeadMarshalJSONPtr",
213 "StructPtrHeadOmitEmptyMarshalJSONPtr",
214 "StructHeadMarshalTextPtr",
215 "StructHeadOmitEmptyMarshalTextPtr",
216 "StructPtrHeadMarshalTextPtr",
217 "StructPtrHeadOmitEmptyMarshalTextPtr",
218 "StructHeadInterfacePtr",
219 "StructHeadOmitEmptyInterfacePtr",
220 "StructPtrHeadInterfacePtr",
221 "StructPtrHeadOmitEmptyInterfacePtr",
222 "StructHeadIntPtrString",
223 "StructHeadOmitEmptyIntPtrString",
224 "StructPtrHeadIntPtrString",
225 "StructPtrHeadOmitEmptyIntPtrString",
226 "StructHeadUintPtrString",
227 "StructHeadOmitEmptyUintPtrString",
228 "StructPtrHeadUintPtrString",
229 "StructPtrHeadOmitEmptyUintPtrString",
230 "StructHeadFloat32PtrString",
231 "StructHeadOmitEmptyFloat32PtrString",
232 "StructPtrHeadFloat32PtrString",
233 "StructPtrHeadOmitEmptyFloat32PtrString",
234 "StructHeadFloat64PtrString",
235 "StructHeadOmitEmptyFloat64PtrString",
236 "StructPtrHeadFloat64PtrString",
237 "StructPtrHeadOmitEmptyFloat64PtrString",
238 "StructHeadBoolPtrString",
239 "StructHeadOmitEmptyBoolPtrString",
240 "StructPtrHeadBoolPtrString",
241 "StructPtrHeadOmitEmptyBoolPtrString",
242 "StructHeadStringPtrString",
243 "StructHeadOmitEmptyStringPtrString",
244 "StructPtrHeadStringPtrString",
245 "StructPtrHeadOmitEmptyStringPtrString",
246 "StructHeadNumberPtrString",
247 "StructHeadOmitEmptyNumberPtrString",
248 "StructPtrHeadNumberPtrString",
249 "StructPtrHeadOmitEmptyNumberPtrString",
250 "StructHead",
251 "StructHeadOmitEmpty",
252 "StructPtrHead",
253 "StructPtrHeadOmitEmpty",
254 "StructFieldInt",
255 "StructFieldOmitEmptyInt",
256 "StructEndInt",
257 "StructEndOmitEmptyInt",
258 "StructFieldUint",
259 "StructFieldOmitEmptyUint",
260 "StructEndUint",
261 "StructEndOmitEmptyUint",
262 "StructFieldFloat32",
263 "StructFieldOmitEmptyFloat32",
264 "StructEndFloat32",
265 "StructEndOmitEmptyFloat32",
266 "StructFieldFloat64",
267 "StructFieldOmitEmptyFloat64",
268 "StructEndFloat64",
269 "StructEndOmitEmptyFloat64",
270 "StructFieldBool",
271 "StructFieldOmitEmptyBool",
272 "StructEndBool",
273 "StructEndOmitEmptyBool",
274 "StructFieldString",
275 "StructFieldOmitEmptyString",
276 "StructEndString",
277 "StructEndOmitEmptyString",
278 "StructFieldBytes",
279 "StructFieldOmitEmptyBytes",
280 "StructEndBytes",
281 "StructEndOmitEmptyBytes",
282 "StructFieldNumber",
283 "StructFieldOmitEmptyNumber",
284 "StructEndNumber",
285 "StructEndOmitEmptyNumber",
286 "StructFieldArray",
287 "StructFieldOmitEmptyArray",
288 "StructEndArray",
289 "StructEndOmitEmptyArray",
290 "StructFieldMap",
291 "StructFieldOmitEmptyMap",
292 "StructEndMap",
293 "StructEndOmitEmptyMap",
294 "StructFieldSlice",
295 "StructFieldOmitEmptySlice",
296 "StructEndSlice",
297 "StructEndOmitEmptySlice",
298 "StructFieldStruct",
299 "StructFieldOmitEmptyStruct",
300 "StructEndStruct",
301 "StructEndOmitEmptyStruct",
302 "StructFieldMarshalJSON",
303 "StructFieldOmitEmptyMarshalJSON",
304 "StructEndMarshalJSON",
305 "StructEndOmitEmptyMarshalJSON",
306 "StructFieldMarshalText",
307 "StructFieldOmitEmptyMarshalText",
308 "StructEndMarshalText",
309 "StructEndOmitEmptyMarshalText",
310 "StructFieldIntString",
311 "StructFieldOmitEmptyIntString",
312 "StructEndIntString",
313 "StructEndOmitEmptyIntString",
314 "StructFieldUintString",
315 "StructFieldOmitEmptyUintString",
316 "StructEndUintString",
317 "StructEndOmitEmptyUintString",
318 "StructFieldFloat32String",
319 "StructFieldOmitEmptyFloat32String",
320 "StructEndFloat32String",
321 "StructEndOmitEmptyFloat32String",
322 "StructFieldFloat64String",
323 "StructFieldOmitEmptyFloat64String",
324 "StructEndFloat64String",
325 "StructEndOmitEmptyFloat64String",
326 "StructFieldBoolString",
327 "StructFieldOmitEmptyBoolString",
328 "StructEndBoolString",
329 "StructEndOmitEmptyBoolString",
330 "StructFieldStringString",
331 "StructFieldOmitEmptyStringString",
332 "StructEndStringString",
333 "StructEndOmitEmptyStringString",
334 "StructFieldNumberString",
335 "StructFieldOmitEmptyNumberString",
336 "StructEndNumberString",
337 "StructEndOmitEmptyNumberString",
338 "StructFieldIntPtr",
339 "StructFieldOmitEmptyIntPtr",
340 "StructEndIntPtr",
341 "StructEndOmitEmptyIntPtr",
342 "StructFieldUintPtr",
343 "StructFieldOmitEmptyUintPtr",
344 "StructEndUintPtr",
345 "StructEndOmitEmptyUintPtr",
346 "StructFieldFloat32Ptr",
347 "StructFieldOmitEmptyFloat32Ptr",
348 "StructEndFloat32Ptr",
349 "StructEndOmitEmptyFloat32Ptr",
350 "StructFieldFloat64Ptr",
351 "StructFieldOmitEmptyFloat64Ptr",
352 "StructEndFloat64Ptr",
353 "StructEndOmitEmptyFloat64Ptr",
354 "StructFieldBoolPtr",
355 "StructFieldOmitEmptyBoolPtr",
356 "StructEndBoolPtr",
357 "StructEndOmitEmptyBoolPtr",
358 "StructFieldStringPtr",
359 "StructFieldOmitEmptyStringPtr",
360 "StructEndStringPtr",
361 "StructEndOmitEmptyStringPtr",
362 "StructFieldBytesPtr",
363 "StructFieldOmitEmptyBytesPtr",
364 "StructEndBytesPtr",
365 "StructEndOmitEmptyBytesPtr",
366 "StructFieldNumberPtr",
367 "StructFieldOmitEmptyNumberPtr",
368 "StructEndNumberPtr",
369 "StructEndOmitEmptyNumberPtr",
370 "StructFieldArrayPtr",
371 "StructFieldOmitEmptyArrayPtr",
372 "StructEndArrayPtr",
373 "StructEndOmitEmptyArrayPtr",
374 "StructFieldMapPtr",
375 "StructFieldOmitEmptyMapPtr",
376 "StructEndMapPtr",
377 "StructEndOmitEmptyMapPtr",
378 "StructFieldSlicePtr",
379 "StructFieldOmitEmptySlicePtr",
380 "StructEndSlicePtr",
381 "StructEndOmitEmptySlicePtr",
382 "StructFieldMarshalJSONPtr",
383 "StructFieldOmitEmptyMarshalJSONPtr",
384 "StructEndMarshalJSONPtr",
385 "StructEndOmitEmptyMarshalJSONPtr",
386 "StructFieldMarshalTextPtr",
387 "StructFieldOmitEmptyMarshalTextPtr",
388 "StructEndMarshalTextPtr",
389 "StructEndOmitEmptyMarshalTextPtr",
390 "StructFieldInterfacePtr",
391 "StructFieldOmitEmptyInterfacePtr",
392 "StructEndInterfacePtr",
393 "StructEndOmitEmptyInterfacePtr",
394 "StructFieldIntPtrString",
395 "StructFieldOmitEmptyIntPtrString",
396 "StructEndIntPtrString",
397 "StructEndOmitEmptyIntPtrString",
398 "StructFieldUintPtrString",
399 "StructFieldOmitEmptyUintPtrString",
400 "StructEndUintPtrString",
401 "StructEndOmitEmptyUintPtrString",
402 "StructFieldFloat32PtrString",
403 "StructFieldOmitEmptyFloat32PtrString",
404 "StructEndFloat32PtrString",
405 "StructEndOmitEmptyFloat32PtrString",
406 "StructFieldFloat64PtrString",
407 "StructFieldOmitEmptyFloat64PtrString",
408 "StructEndFloat64PtrString",
409 "StructEndOmitEmptyFloat64PtrString",
410 "StructFieldBoolPtrString",
411 "StructFieldOmitEmptyBoolPtrString",
412 "StructEndBoolPtrString",
413 "StructEndOmitEmptyBoolPtrString",
414 "StructFieldStringPtrString",
415 "StructFieldOmitEmptyStringPtrString",
416 "StructEndStringPtrString",
417 "StructEndOmitEmptyStringPtrString",
418 "StructFieldNumberPtrString",
419 "StructFieldOmitEmptyNumberPtrString",
420 "StructEndNumberPtrString",
421 "StructEndOmitEmptyNumberPtrString",
422 "StructField",
423 "StructFieldOmitEmpty",
424 "StructEnd",
425 "StructEndOmitEmpty",
426 }
427
428 type OpType uint16
429
430 const (
431 OpEnd OpType = 0
432 OpInterface OpType = 1
433 OpPtr OpType = 2
434 OpSliceElem OpType = 3
435 OpSliceEnd OpType = 4
436 OpArrayElem OpType = 5
437 OpArrayEnd OpType = 6
438 OpMapKey OpType = 7
439 OpMapValue OpType = 8
440 OpMapEnd OpType = 9
441 OpRecursive OpType = 10
442 OpRecursivePtr OpType = 11
443 OpRecursiveEnd OpType = 12
444 OpInterfaceEnd OpType = 13
445 OpInt OpType = 14
446 OpUint OpType = 15
447 OpFloat32 OpType = 16
448 OpFloat64 OpType = 17
449 OpBool OpType = 18
450 OpString OpType = 19
451 OpBytes OpType = 20
452 OpNumber OpType = 21
453 OpArray OpType = 22
454 OpMap OpType = 23
455 OpSlice OpType = 24
456 OpStruct OpType = 25
457 OpMarshalJSON OpType = 26
458 OpMarshalText OpType = 27
459 OpIntString OpType = 28
460 OpUintString OpType = 29
461 OpFloat32String OpType = 30
462 OpFloat64String OpType = 31
463 OpBoolString OpType = 32
464 OpStringString OpType = 33
465 OpNumberString OpType = 34
466 OpIntPtr OpType = 35
467 OpUintPtr OpType = 36
468 OpFloat32Ptr OpType = 37
469 OpFloat64Ptr OpType = 38
470 OpBoolPtr OpType = 39
471 OpStringPtr OpType = 40
472 OpBytesPtr OpType = 41
473 OpNumberPtr OpType = 42
474 OpArrayPtr OpType = 43
475 OpMapPtr OpType = 44
476 OpSlicePtr OpType = 45
477 OpMarshalJSONPtr OpType = 46
478 OpMarshalTextPtr OpType = 47
479 OpInterfacePtr OpType = 48
480 OpIntPtrString OpType = 49
481 OpUintPtrString OpType = 50
482 OpFloat32PtrString OpType = 51
483 OpFloat64PtrString OpType = 52
484 OpBoolPtrString OpType = 53
485 OpStringPtrString OpType = 54
486 OpNumberPtrString OpType = 55
487 OpStructHeadInt OpType = 56
488 OpStructHeadOmitEmptyInt OpType = 57
489 OpStructPtrHeadInt OpType = 58
490 OpStructPtrHeadOmitEmptyInt OpType = 59
491 OpStructHeadUint OpType = 60
492 OpStructHeadOmitEmptyUint OpType = 61
493 OpStructPtrHeadUint OpType = 62
494 OpStructPtrHeadOmitEmptyUint OpType = 63
495 OpStructHeadFloat32 OpType = 64
496 OpStructHeadOmitEmptyFloat32 OpType = 65
497 OpStructPtrHeadFloat32 OpType = 66
498 OpStructPtrHeadOmitEmptyFloat32 OpType = 67
499 OpStructHeadFloat64 OpType = 68
500 OpStructHeadOmitEmptyFloat64 OpType = 69
501 OpStructPtrHeadFloat64 OpType = 70
502 OpStructPtrHeadOmitEmptyFloat64 OpType = 71
503 OpStructHeadBool OpType = 72
504 OpStructHeadOmitEmptyBool OpType = 73
505 OpStructPtrHeadBool OpType = 74
506 OpStructPtrHeadOmitEmptyBool OpType = 75
507 OpStructHeadString OpType = 76
508 OpStructHeadOmitEmptyString OpType = 77
509 OpStructPtrHeadString OpType = 78
510 OpStructPtrHeadOmitEmptyString OpType = 79
511 OpStructHeadBytes OpType = 80
512 OpStructHeadOmitEmptyBytes OpType = 81
513 OpStructPtrHeadBytes OpType = 82
514 OpStructPtrHeadOmitEmptyBytes OpType = 83
515 OpStructHeadNumber OpType = 84
516 OpStructHeadOmitEmptyNumber OpType = 85
517 OpStructPtrHeadNumber OpType = 86
518 OpStructPtrHeadOmitEmptyNumber OpType = 87
519 OpStructHeadArray OpType = 88
520 OpStructHeadOmitEmptyArray OpType = 89
521 OpStructPtrHeadArray OpType = 90
522 OpStructPtrHeadOmitEmptyArray OpType = 91
523 OpStructHeadMap OpType = 92
524 OpStructHeadOmitEmptyMap OpType = 93
525 OpStructPtrHeadMap OpType = 94
526 OpStructPtrHeadOmitEmptyMap OpType = 95
527 OpStructHeadSlice OpType = 96
528 OpStructHeadOmitEmptySlice OpType = 97
529 OpStructPtrHeadSlice OpType = 98
530 OpStructPtrHeadOmitEmptySlice OpType = 99
531 OpStructHeadStruct OpType = 100
532 OpStructHeadOmitEmptyStruct OpType = 101
533 OpStructPtrHeadStruct OpType = 102
534 OpStructPtrHeadOmitEmptyStruct OpType = 103
535 OpStructHeadMarshalJSON OpType = 104
536 OpStructHeadOmitEmptyMarshalJSON OpType = 105
537 OpStructPtrHeadMarshalJSON OpType = 106
538 OpStructPtrHeadOmitEmptyMarshalJSON OpType = 107
539 OpStructHeadMarshalText OpType = 108
540 OpStructHeadOmitEmptyMarshalText OpType = 109
541 OpStructPtrHeadMarshalText OpType = 110
542 OpStructPtrHeadOmitEmptyMarshalText OpType = 111
543 OpStructHeadIntString OpType = 112
544 OpStructHeadOmitEmptyIntString OpType = 113
545 OpStructPtrHeadIntString OpType = 114
546 OpStructPtrHeadOmitEmptyIntString OpType = 115
547 OpStructHeadUintString OpType = 116
548 OpStructHeadOmitEmptyUintString OpType = 117
549 OpStructPtrHeadUintString OpType = 118
550 OpStructPtrHeadOmitEmptyUintString OpType = 119
551 OpStructHeadFloat32String OpType = 120
552 OpStructHeadOmitEmptyFloat32String OpType = 121
553 OpStructPtrHeadFloat32String OpType = 122
554 OpStructPtrHeadOmitEmptyFloat32String OpType = 123
555 OpStructHeadFloat64String OpType = 124
556 OpStructHeadOmitEmptyFloat64String OpType = 125
557 OpStructPtrHeadFloat64String OpType = 126
558 OpStructPtrHeadOmitEmptyFloat64String OpType = 127
559 OpStructHeadBoolString OpType = 128
560 OpStructHeadOmitEmptyBoolString OpType = 129
561 OpStructPtrHeadBoolString OpType = 130
562 OpStructPtrHeadOmitEmptyBoolString OpType = 131
563 OpStructHeadStringString OpType = 132
564 OpStructHeadOmitEmptyStringString OpType = 133
565 OpStructPtrHeadStringString OpType = 134
566 OpStructPtrHeadOmitEmptyStringString OpType = 135
567 OpStructHeadNumberString OpType = 136
568 OpStructHeadOmitEmptyNumberString OpType = 137
569 OpStructPtrHeadNumberString OpType = 138
570 OpStructPtrHeadOmitEmptyNumberString OpType = 139
571 OpStructHeadIntPtr OpType = 140
572 OpStructHeadOmitEmptyIntPtr OpType = 141
573 OpStructPtrHeadIntPtr OpType = 142
574 OpStructPtrHeadOmitEmptyIntPtr OpType = 143
575 OpStructHeadUintPtr OpType = 144
576 OpStructHeadOmitEmptyUintPtr OpType = 145
577 OpStructPtrHeadUintPtr OpType = 146
578 OpStructPtrHeadOmitEmptyUintPtr OpType = 147
579 OpStructHeadFloat32Ptr OpType = 148
580 OpStructHeadOmitEmptyFloat32Ptr OpType = 149
581 OpStructPtrHeadFloat32Ptr OpType = 150
582 OpStructPtrHeadOmitEmptyFloat32Ptr OpType = 151
583 OpStructHeadFloat64Ptr OpType = 152
584 OpStructHeadOmitEmptyFloat64Ptr OpType = 153
585 OpStructPtrHeadFloat64Ptr OpType = 154
586 OpStructPtrHeadOmitEmptyFloat64Ptr OpType = 155
587 OpStructHeadBoolPtr OpType = 156
588 OpStructHeadOmitEmptyBoolPtr OpType = 157
589 OpStructPtrHeadBoolPtr OpType = 158
590 OpStructPtrHeadOmitEmptyBoolPtr OpType = 159
591 OpStructHeadStringPtr OpType = 160
592 OpStructHeadOmitEmptyStringPtr OpType = 161
593 OpStructPtrHeadStringPtr OpType = 162
594 OpStructPtrHeadOmitEmptyStringPtr OpType = 163
595 OpStructHeadBytesPtr OpType = 164
596 OpStructHeadOmitEmptyBytesPtr OpType = 165
597 OpStructPtrHeadBytesPtr OpType = 166
598 OpStructPtrHeadOmitEmptyBytesPtr OpType = 167
599 OpStructHeadNumberPtr OpType = 168
600 OpStructHeadOmitEmptyNumberPtr OpType = 169
601 OpStructPtrHeadNumberPtr OpType = 170
602 OpStructPtrHeadOmitEmptyNumberPtr OpType = 171
603 OpStructHeadArrayPtr OpType = 172
604 OpStructHeadOmitEmptyArrayPtr OpType = 173
605 OpStructPtrHeadArrayPtr OpType = 174
606 OpStructPtrHeadOmitEmptyArrayPtr OpType = 175
607 OpStructHeadMapPtr OpType = 176
608 OpStructHeadOmitEmptyMapPtr OpType = 177
609 OpStructPtrHeadMapPtr OpType = 178
610 OpStructPtrHeadOmitEmptyMapPtr OpType = 179
611 OpStructHeadSlicePtr OpType = 180
612 OpStructHeadOmitEmptySlicePtr OpType = 181
613 OpStructPtrHeadSlicePtr OpType = 182
614 OpStructPtrHeadOmitEmptySlicePtr OpType = 183
615 OpStructHeadMarshalJSONPtr OpType = 184
616 OpStructHeadOmitEmptyMarshalJSONPtr OpType = 185
617 OpStructPtrHeadMarshalJSONPtr OpType = 186
618 OpStructPtrHeadOmitEmptyMarshalJSONPtr OpType = 187
619 OpStructHeadMarshalTextPtr OpType = 188
620 OpStructHeadOmitEmptyMarshalTextPtr OpType = 189
621 OpStructPtrHeadMarshalTextPtr OpType = 190
622 OpStructPtrHeadOmitEmptyMarshalTextPtr OpType = 191
623 OpStructHeadInterfacePtr OpType = 192
624 OpStructHeadOmitEmptyInterfacePtr OpType = 193
625 OpStructPtrHeadInterfacePtr OpType = 194
626 OpStructPtrHeadOmitEmptyInterfacePtr OpType = 195
627 OpStructHeadIntPtrString OpType = 196
628 OpStructHeadOmitEmptyIntPtrString OpType = 197
629 OpStructPtrHeadIntPtrString OpType = 198
630 OpStructPtrHeadOmitEmptyIntPtrString OpType = 199
631 OpStructHeadUintPtrString OpType = 200
632 OpStructHeadOmitEmptyUintPtrString OpType = 201
633 OpStructPtrHeadUintPtrString OpType = 202
634 OpStructPtrHeadOmitEmptyUintPtrString OpType = 203
635 OpStructHeadFloat32PtrString OpType = 204
636 OpStructHeadOmitEmptyFloat32PtrString OpType = 205
637 OpStructPtrHeadFloat32PtrString OpType = 206
638 OpStructPtrHeadOmitEmptyFloat32PtrString OpType = 207
639 OpStructHeadFloat64PtrString OpType = 208
640 OpStructHeadOmitEmptyFloat64PtrString OpType = 209
641 OpStructPtrHeadFloat64PtrString OpType = 210
642 OpStructPtrHeadOmitEmptyFloat64PtrString OpType = 211
643 OpStructHeadBoolPtrString OpType = 212
644 OpStructHeadOmitEmptyBoolPtrString OpType = 213
645 OpStructPtrHeadBoolPtrString OpType = 214
646 OpStructPtrHeadOmitEmptyBoolPtrString OpType = 215
647 OpStructHeadStringPtrString OpType = 216
648 OpStructHeadOmitEmptyStringPtrString OpType = 217
649 OpStructPtrHeadStringPtrString OpType = 218
650 OpStructPtrHeadOmitEmptyStringPtrString OpType = 219
651 OpStructHeadNumberPtrString OpType = 220
652 OpStructHeadOmitEmptyNumberPtrString OpType = 221
653 OpStructPtrHeadNumberPtrString OpType = 222
654 OpStructPtrHeadOmitEmptyNumberPtrString OpType = 223
655 OpStructHead OpType = 224
656 OpStructHeadOmitEmpty OpType = 225
657 OpStructPtrHead OpType = 226
658 OpStructPtrHeadOmitEmpty OpType = 227
659 OpStructFieldInt OpType = 228
660 OpStructFieldOmitEmptyInt OpType = 229
661 OpStructEndInt OpType = 230
662 OpStructEndOmitEmptyInt OpType = 231
663 OpStructFieldUint OpType = 232
664 OpStructFieldOmitEmptyUint OpType = 233
665 OpStructEndUint OpType = 234
666 OpStructEndOmitEmptyUint OpType = 235
667 OpStructFieldFloat32 OpType = 236
668 OpStructFieldOmitEmptyFloat32 OpType = 237
669 OpStructEndFloat32 OpType = 238
670 OpStructEndOmitEmptyFloat32 OpType = 239
671 OpStructFieldFloat64 OpType = 240
672 OpStructFieldOmitEmptyFloat64 OpType = 241
673 OpStructEndFloat64 OpType = 242
674 OpStructEndOmitEmptyFloat64 OpType = 243
675 OpStructFieldBool OpType = 244
676 OpStructFieldOmitEmptyBool OpType = 245
677 OpStructEndBool OpType = 246
678 OpStructEndOmitEmptyBool OpType = 247
679 OpStructFieldString OpType = 248
680 OpStructFieldOmitEmptyString OpType = 249
681 OpStructEndString OpType = 250
682 OpStructEndOmitEmptyString OpType = 251
683 OpStructFieldBytes OpType = 252
684 OpStructFieldOmitEmptyBytes OpType = 253
685 OpStructEndBytes OpType = 254
686 OpStructEndOmitEmptyBytes OpType = 255
687 OpStructFieldNumber OpType = 256
688 OpStructFieldOmitEmptyNumber OpType = 257
689 OpStructEndNumber OpType = 258
690 OpStructEndOmitEmptyNumber OpType = 259
691 OpStructFieldArray OpType = 260
692 OpStructFieldOmitEmptyArray OpType = 261
693 OpStructEndArray OpType = 262
694 OpStructEndOmitEmptyArray OpType = 263
695 OpStructFieldMap OpType = 264
696 OpStructFieldOmitEmptyMap OpType = 265
697 OpStructEndMap OpType = 266
698 OpStructEndOmitEmptyMap OpType = 267
699 OpStructFieldSlice OpType = 268
700 OpStructFieldOmitEmptySlice OpType = 269
701 OpStructEndSlice OpType = 270
702 OpStructEndOmitEmptySlice OpType = 271
703 OpStructFieldStruct OpType = 272
704 OpStructFieldOmitEmptyStruct OpType = 273
705 OpStructEndStruct OpType = 274
706 OpStructEndOmitEmptyStruct OpType = 275
707 OpStructFieldMarshalJSON OpType = 276
708 OpStructFieldOmitEmptyMarshalJSON OpType = 277
709 OpStructEndMarshalJSON OpType = 278
710 OpStructEndOmitEmptyMarshalJSON OpType = 279
711 OpStructFieldMarshalText OpType = 280
712 OpStructFieldOmitEmptyMarshalText OpType = 281
713 OpStructEndMarshalText OpType = 282
714 OpStructEndOmitEmptyMarshalText OpType = 283
715 OpStructFieldIntString OpType = 284
716 OpStructFieldOmitEmptyIntString OpType = 285
717 OpStructEndIntString OpType = 286
718 OpStructEndOmitEmptyIntString OpType = 287
719 OpStructFieldUintString OpType = 288
720 OpStructFieldOmitEmptyUintString OpType = 289
721 OpStructEndUintString OpType = 290
722 OpStructEndOmitEmptyUintString OpType = 291
723 OpStructFieldFloat32String OpType = 292
724 OpStructFieldOmitEmptyFloat32String OpType = 293
725 OpStructEndFloat32String OpType = 294
726 OpStructEndOmitEmptyFloat32String OpType = 295
727 OpStructFieldFloat64String OpType = 296
728 OpStructFieldOmitEmptyFloat64String OpType = 297
729 OpStructEndFloat64String OpType = 298
730 OpStructEndOmitEmptyFloat64String OpType = 299
731 OpStructFieldBoolString OpType = 300
732 OpStructFieldOmitEmptyBoolString OpType = 301
733 OpStructEndBoolString OpType = 302
734 OpStructEndOmitEmptyBoolString OpType = 303
735 OpStructFieldStringString OpType = 304
736 OpStructFieldOmitEmptyStringString OpType = 305
737 OpStructEndStringString OpType = 306
738 OpStructEndOmitEmptyStringString OpType = 307
739 OpStructFieldNumberString OpType = 308
740 OpStructFieldOmitEmptyNumberString OpType = 309
741 OpStructEndNumberString OpType = 310
742 OpStructEndOmitEmptyNumberString OpType = 311
743 OpStructFieldIntPtr OpType = 312
744 OpStructFieldOmitEmptyIntPtr OpType = 313
745 OpStructEndIntPtr OpType = 314
746 OpStructEndOmitEmptyIntPtr OpType = 315
747 OpStructFieldUintPtr OpType = 316
748 OpStructFieldOmitEmptyUintPtr OpType = 317
749 OpStructEndUintPtr OpType = 318
750 OpStructEndOmitEmptyUintPtr OpType = 319
751 OpStructFieldFloat32Ptr OpType = 320
752 OpStructFieldOmitEmptyFloat32Ptr OpType = 321
753 OpStructEndFloat32Ptr OpType = 322
754 OpStructEndOmitEmptyFloat32Ptr OpType = 323
755 OpStructFieldFloat64Ptr OpType = 324
756 OpStructFieldOmitEmptyFloat64Ptr OpType = 325
757 OpStructEndFloat64Ptr OpType = 326
758 OpStructEndOmitEmptyFloat64Ptr OpType = 327
759 OpStructFieldBoolPtr OpType = 328
760 OpStructFieldOmitEmptyBoolPtr OpType = 329
761 OpStructEndBoolPtr OpType = 330
762 OpStructEndOmitEmptyBoolPtr OpType = 331
763 OpStructFieldStringPtr OpType = 332
764 OpStructFieldOmitEmptyStringPtr OpType = 333
765 OpStructEndStringPtr OpType = 334
766 OpStructEndOmitEmptyStringPtr OpType = 335
767 OpStructFieldBytesPtr OpType = 336
768 OpStructFieldOmitEmptyBytesPtr OpType = 337
769 OpStructEndBytesPtr OpType = 338
770 OpStructEndOmitEmptyBytesPtr OpType = 339
771 OpStructFieldNumberPtr OpType = 340
772 OpStructFieldOmitEmptyNumberPtr OpType = 341
773 OpStructEndNumberPtr OpType = 342
774 OpStructEndOmitEmptyNumberPtr OpType = 343
775 OpStructFieldArrayPtr OpType = 344
776 OpStructFieldOmitEmptyArrayPtr OpType = 345
777 OpStructEndArrayPtr OpType = 346
778 OpStructEndOmitEmptyArrayPtr OpType = 347
779 OpStructFieldMapPtr OpType = 348
780 OpStructFieldOmitEmptyMapPtr OpType = 349
781 OpStructEndMapPtr OpType = 350
782 OpStructEndOmitEmptyMapPtr OpType = 351
783 OpStructFieldSlicePtr OpType = 352
784 OpStructFieldOmitEmptySlicePtr OpType = 353
785 OpStructEndSlicePtr OpType = 354
786 OpStructEndOmitEmptySlicePtr OpType = 355
787 OpStructFieldMarshalJSONPtr OpType = 356
788 OpStructFieldOmitEmptyMarshalJSONPtr OpType = 357
789 OpStructEndMarshalJSONPtr OpType = 358
790 OpStructEndOmitEmptyMarshalJSONPtr OpType = 359
791 OpStructFieldMarshalTextPtr OpType = 360
792 OpStructFieldOmitEmptyMarshalTextPtr OpType = 361
793 OpStructEndMarshalTextPtr OpType = 362
794 OpStructEndOmitEmptyMarshalTextPtr OpType = 363
795 OpStructFieldInterfacePtr OpType = 364
796 OpStructFieldOmitEmptyInterfacePtr OpType = 365
797 OpStructEndInterfacePtr OpType = 366
798 OpStructEndOmitEmptyInterfacePtr OpType = 367
799 OpStructFieldIntPtrString OpType = 368
800 OpStructFieldOmitEmptyIntPtrString OpType = 369
801 OpStructEndIntPtrString OpType = 370
802 OpStructEndOmitEmptyIntPtrString OpType = 371
803 OpStructFieldUintPtrString OpType = 372
804 OpStructFieldOmitEmptyUintPtrString OpType = 373
805 OpStructEndUintPtrString OpType = 374
806 OpStructEndOmitEmptyUintPtrString OpType = 375
807 OpStructFieldFloat32PtrString OpType = 376
808 OpStructFieldOmitEmptyFloat32PtrString OpType = 377
809 OpStructEndFloat32PtrString OpType = 378
810 OpStructEndOmitEmptyFloat32PtrString OpType = 379
811 OpStructFieldFloat64PtrString OpType = 380
812 OpStructFieldOmitEmptyFloat64PtrString OpType = 381
813 OpStructEndFloat64PtrString OpType = 382
814 OpStructEndOmitEmptyFloat64PtrString OpType = 383
815 OpStructFieldBoolPtrString OpType = 384
816 OpStructFieldOmitEmptyBoolPtrString OpType = 385
817 OpStructEndBoolPtrString OpType = 386
818 OpStructEndOmitEmptyBoolPtrString OpType = 387
819 OpStructFieldStringPtrString OpType = 388
820 OpStructFieldOmitEmptyStringPtrString OpType = 389
821 OpStructEndStringPtrString OpType = 390
822 OpStructEndOmitEmptyStringPtrString OpType = 391
823 OpStructFieldNumberPtrString OpType = 392
824 OpStructFieldOmitEmptyNumberPtrString OpType = 393
825 OpStructEndNumberPtrString OpType = 394
826 OpStructEndOmitEmptyNumberPtrString OpType = 395
827 OpStructField OpType = 396
828 OpStructFieldOmitEmpty OpType = 397
829 OpStructEnd OpType = 398
830 OpStructEndOmitEmpty OpType = 399
831 )
832
833 func (t OpType) String() string {
834 if int(t) >= 400 {
835 return ""
836 }
837 return opTypeStrings[int(t)]
838 }
839
840 func (t OpType) CodeType() CodeType {
841 if strings.Contains(t.String(), "Struct") {
842 if strings.Contains(t.String(), "End") {
843 return CodeStructEnd
844 }
845 return CodeStructField
846 }
847 switch t {
848 case OpArray, OpArrayPtr:
849 return CodeArrayHead
850 case OpArrayElem:
851 return CodeArrayElem
852 case OpSlice, OpSlicePtr:
853 return CodeSliceHead
854 case OpSliceElem:
855 return CodeSliceElem
856 case OpMap, OpMapPtr:
857 return CodeMapHead
858 case OpMapKey:
859 return CodeMapKey
860 case OpMapValue:
861 return CodeMapValue
862 case OpMapEnd:
863 return CodeMapEnd
864 }
865
866 return CodeOp
867 }
868
869 func (t OpType) HeadToPtrHead() OpType {
870 if strings.Index(t.String(), "PtrHead") > 0 {
871 return t
872 }
873
874 idx := strings.Index(t.String(), "Head")
875 if idx == -1 {
876 return t
877 }
878 suffix := "PtrHead" + t.String()[idx+len("Head"):]
879
880 const toPtrOffset = 2
881 if strings.Contains(OpType(int(t)+toPtrOffset).String(), suffix) {
882 return OpType(int(t) + toPtrOffset)
883 }
884 return t
885 }
886
887 func (t OpType) HeadToOmitEmptyHead() OpType {
888 const toOmitEmptyOffset = 1
889 if strings.Contains(OpType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") {
890 return OpType(int(t) + toOmitEmptyOffset)
891 }
892
893 return t
894 }
895
896 func (t OpType) PtrHeadToHead() OpType {
897 idx := strings.Index(t.String(), "PtrHead")
898 if idx == -1 {
899 return t
900 }
901 suffix := t.String()[idx+len("Ptr"):]
902
903 const toPtrOffset = 2
904 if strings.Contains(OpType(int(t)-toPtrOffset).String(), suffix) {
905 return OpType(int(t) - toPtrOffset)
906 }
907 return t
908 }
909
910 func (t OpType) FieldToEnd() OpType {
911 idx := strings.Index(t.String(), "Field")
912 if idx == -1 {
913 return t
914 }
915 suffix := t.String()[idx+len("Field"):]
916 if suffix == "" || suffix == "OmitEmpty" {
917 return t
918 }
919 const toEndOffset = 2
920 if strings.Contains(OpType(int(t)+toEndOffset).String(), "End"+suffix) {
921 return OpType(int(t) + toEndOffset)
922 }
923 return t
924 }
925
926 func (t OpType) FieldToOmitEmptyField() OpType {
927 const toOmitEmptyOffset = 1
928 if strings.Contains(OpType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") {
929 return OpType(int(t) + toOmitEmptyOffset)
930 }
931 return t
932 }
933
View as plain text