github.com/cloudwego/frugal@v0.1.15/internal/binary/decoder/opcode.go (about) 1 /* 2 * Copyright 2022 ByteDance Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package decoder 18 19 import ( 20 `fmt` 21 ) 22 23 type OpCode uint8 24 25 const ( 26 OP_int OpCode = iota 27 OP_str 28 OP_str_nocopy 29 OP_bin 30 OP_bin_nocopy 31 OP_enum 32 OP_size 33 OP_type 34 OP_seek 35 OP_deref 36 OP_ctr_load 37 OP_ctr_decr 38 OP_ctr_is_zero 39 OP_map_alloc 40 OP_map_close 41 OP_map_set_i8 42 OP_map_set_i16 43 OP_map_set_i32 44 OP_map_set_i64 45 OP_map_set_str 46 OP_map_set_enum 47 OP_map_set_pointer 48 OP_list_alloc 49 OP_struct_skip 50 OP_struct_ignore 51 OP_struct_bitmap 52 OP_struct_switch 53 OP_struct_require 54 OP_struct_is_stop 55 OP_struct_mark_tag 56 OP_struct_read_type 57 OP_struct_check_type 58 OP_make_state 59 OP_drop_state 60 OP_construct 61 OP_initialize 62 OP_defer 63 OP_goto 64 OP_halt 65 ) 66 67 var _OpNames = [256]string { 68 OP_int : "int", 69 OP_str : "str", 70 OP_str_nocopy : "str_nocopy", 71 OP_bin : "bin", 72 OP_bin_nocopy : "bin_nocopy", 73 OP_enum : "enum", 74 OP_size : "size", 75 OP_type : "type", 76 OP_seek : "seek", 77 OP_deref : "deref", 78 OP_ctr_load : "ctr_load", 79 OP_ctr_decr : "ctr_decr", 80 OP_ctr_is_zero : "ctr_is_zero", 81 OP_map_alloc : "map_alloc", 82 OP_map_close : "map_close", 83 OP_map_set_i8 : "map_set_i8", 84 OP_map_set_i16 : "map_set_i16", 85 OP_map_set_i32 : "map_set_i32", 86 OP_map_set_i64 : "map_set_i64", 87 OP_map_set_str : "map_set_str", 88 OP_map_set_enum : "map_set_enum", 89 OP_map_set_pointer : "map_set_pointer", 90 OP_list_alloc : "list_alloc", 91 OP_struct_skip : "struct_skip", 92 OP_struct_ignore : "struct_ignore", 93 OP_struct_bitmap : "struct_bitmap", 94 OP_struct_switch : "struct_switch", 95 OP_struct_require : "struct_require", 96 OP_struct_is_stop : "struct_is_stop", 97 OP_struct_mark_tag : "struct_mark_tag", 98 OP_struct_read_type : "struct_read_type", 99 OP_struct_check_type : "struct_check_type", 100 OP_make_state : "make_state", 101 OP_drop_state : "drop_state", 102 OP_construct : "construct", 103 OP_initialize : "initialize", 104 OP_defer : "defer", 105 OP_goto : "goto", 106 OP_halt : "halt", 107 } 108 109 var _OpBranches = [256]bool { 110 OP_ctr_is_zero : true, 111 OP_struct_switch : true, 112 OP_struct_is_stop : true, 113 OP_struct_check_type : true, 114 OP_goto : true, 115 } 116 117 func (self OpCode) String() string { 118 if _OpNames[self] != "" { 119 return _OpNames[self] 120 } else { 121 return fmt.Sprintf("OpCode(%d)", self) 122 } 123 }