github.com/goplus/igop@v0.25.0/types_go117.go (about) 1 //go:build !go1.18 2 // +build !go1.18 3 4 /* 5 * Copyright (c) 2022 The GoPlus Authors (goplus.org). All rights reserved. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package igop 21 22 import ( 23 "go/ast" 24 "go/types" 25 "reflect" 26 27 "golang.org/x/tools/go/ssa" 28 ) 29 30 const ( 31 enabledTypeParam = false 32 ) 33 34 func hasTypeParam(t types.Type) bool { 35 return false 36 } 37 38 type nestedStack struct { 39 } 40 41 func (r *TypesRecord) EnterInstance(fn *ssa.Function) { 42 } 43 func (r *TypesRecord) LeaveInstance(fn *ssa.Function) { 44 } 45 46 func (r *TypesRecord) extractNamed(named *types.Named, totype bool) (pkgpath string, name string, typeargs bool, nested bool) { 47 obj := named.Obj() 48 if pkg := obj.Pkg(); pkg != nil { 49 if pkg.Name() == "main" { 50 pkgpath = "main" 51 } else { 52 pkgpath = pkg.Path() 53 } 54 } 55 name = obj.Name() 56 return 57 } 58 59 func (r *TypesRecord) LookupReflect(typ types.Type) (rt reflect.Type, ok bool, nested bool) { 60 rt, ok = r.loader.LookupReflect(typ) 61 if !ok { 62 if rt := r.tcache.At(typ); rt != nil { 63 return rt.(reflect.Type), true, false 64 } 65 } 66 return 67 } 68 69 func (r *TypesLoader) hasTypeArgs(rt reflect.Type) bool { 70 return false 71 } 72 73 func newTypesInfo() *types.Info { 74 return &types.Info{ 75 Types: make(map[ast.Expr]types.TypeAndValue), 76 Defs: make(map[*ast.Ident]types.Object), 77 Uses: make(map[*ast.Ident]types.Object), 78 Implicits: make(map[ast.Node]types.Object), 79 Scopes: make(map[ast.Node]*types.Scope), 80 Selections: make(map[*ast.SelectorExpr]*types.Selection), 81 } 82 }