github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/pingcap/tidb/parser/opcode/opcode.go (about) 1 // Copyright 2015 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package opcode 15 16 import "fmt" 17 18 // Op is opcode type. 19 type Op int 20 21 // List operators. 22 const ( 23 AndAnd Op = iota + 1 24 LeftShift 25 RightShift 26 OrOr 27 GE 28 LE 29 EQ 30 NE 31 LT 32 GT 33 Plus 34 Minus 35 And 36 Or 37 Mod 38 Xor 39 Div 40 Mul 41 Not 42 BitNeg 43 IntDiv 44 LogicXor 45 NullEQ 46 ) 47 48 var ops = map[Op]string{ 49 AndAnd: "&&", 50 LeftShift: "<<", 51 RightShift: ">>", 52 OrOr: "||", 53 GE: ">=", 54 LE: "<=", 55 EQ: "=", 56 NE: "!=", 57 LT: "<", 58 GT: ">", 59 Plus: "+", 60 Minus: "-", 61 And: "&", 62 Or: "|", 63 Mod: "%", 64 Xor: "^", 65 Div: "/", 66 Mul: "*", 67 Not: "!", 68 BitNeg: "~", 69 IntDiv: "DIV", 70 LogicXor: "XOR", 71 NullEQ: "<=>", 72 } 73 74 // String implements Stringer interface. 75 func (o Op) String() string { 76 str, ok := ops[o] 77 if !ok { 78 panic(fmt.Sprintf("%d", o)) 79 } 80 81 return str 82 }