Source file src/cmd/compile/internal/typecheck/export.go

     1  // Copyright 2009 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 typecheck
     6  
     7  import (
     8  	"cmd/compile/internal/base"
     9  	"cmd/compile/internal/ir"
    10  	"cmd/compile/internal/types"
    11  	"cmd/internal/src"
    12  )
    13  
    14  // importfunc declares symbol s as an imported function with type t.
    15  func importfunc(s *types.Sym, t *types.Type) {
    16  	fn := ir.NewFunc(src.NoXPos, src.NoXPos, s, t)
    17  	importsym(fn.Nname)
    18  }
    19  
    20  // importvar declares symbol s as an imported variable with type t.
    21  func importvar(s *types.Sym, t *types.Type) {
    22  	n := ir.NewNameAt(src.NoXPos, s, t)
    23  	n.Class = ir.PEXTERN
    24  	importsym(n)
    25  }
    26  
    27  func importsym(name *ir.Name) {
    28  	sym := name.Sym()
    29  	if sym.Def != nil {
    30  		base.Fatalf("importsym of symbol that already exists: %v", sym.Def)
    31  	}
    32  	sym.Def = name
    33  }
    34  

View as plain text