github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/cmd/compile/internal/gc/bimport.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package gc 6 7 import ( 8 "cmd/compile/internal/types" 9 "cmd/internal/src" 10 ) 11 12 // numImport tracks how often a package with a given name is imported. 13 // It is used to provide a better error message (by using the package 14 // path to disambiguate) if a package that appears multiple times with 15 // the same name appears in an error message. 16 var numImport = make(map[string]int) 17 18 func idealType(typ *types.Type) *types.Type { 19 switch typ { 20 case types.Idealint, types.Idealrune, types.Idealfloat, types.Idealcomplex: 21 // canonicalize ideal types 22 typ = types.Types[TIDEAL] 23 } 24 return typ 25 } 26 27 func npos(pos src.XPos, n *Node) *Node { 28 n.Pos = pos 29 return n 30 } 31 32 func builtinCall(op Op) *Node { 33 return nod(OCALL, mkname(builtinpkg.Lookup(goopnames[op])), nil) 34 }