github.com/cloudwego/frugal@v0.1.15/internal/atm/ssa/constdata.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 ssa 18 19 import ( 20 `fmt` 21 `unsafe` 22 ) 23 24 type _ConstData struct { 25 i bool 26 v int64 27 c Constness 28 p unsafe.Pointer 29 } 30 31 func (self _ConstData) String() string { 32 if self.i { 33 return fmt.Sprintf("(i64) %d", self.v) 34 } else { 35 return fmt.Sprintf("(%s ptr) %p", self.c, self.p) 36 } 37 } 38 39 func constint(v int64) _ConstData { 40 return _ConstData { 41 v: v, 42 i: true, 43 } 44 } 45 46 func constptr(p unsafe.Pointer, cc Constness) _ConstData { 47 return _ConstData { 48 p: p, 49 c: cc, 50 i: false, 51 } 52 }