}
func (p *importer) obj(tag int) {
+ var aliasPos token.Pos
+ var aliasName string
+ if tag == aliasTag {
+ aliasPos = p.pos()
+ aliasName = p.string()
+ tag = p.tagOrIndex()
+ }
+
+ var obj types.Object
switch tag {
case constTag:
pos := p.pos()
pkg, name := p.qualifiedName()
typ := p.typ(nil)
val := p.value()
- p.declare(types.NewConst(pos, pkg, name, typ, val))
+ obj = types.NewConst(pos, pkg, name, typ, val)
+ p.declare(obj)
case typeTag:
- _ = p.typ(nil)
+ obj = p.typ(nil).(*types.Named).Obj()
case varTag:
pos := p.pos()
pkg, name := p.qualifiedName()
typ := p.typ(nil)
- p.declare(types.NewVar(pos, pkg, name, typ))
+ obj = types.NewVar(pos, pkg, name, typ)
+ p.declare(obj)
case funcTag:
pos := p.pos()
params, isddd := p.paramList()
result, _ := p.paramList()
sig := types.NewSignature(nil, params, result, isddd)
- p.declare(types.NewFunc(pos, pkg, name, sig))
+ obj = types.NewFunc(pos, pkg, name, sig)
+ p.declare(obj)
default:
errorf("unexpected object tag %d", tag)
}
+
+ if aliasName != "" {
+ p.declare(types.NewAlias(aliasPos, p.pkgList[0], aliasName, 0, obj))
+ }
}
func (p *importer) pos() token.Pos {
fractionTag // not used by gc
complexTag
stringTag
+ nilTag // only used by gc (appears in exported inlined function bodies)
unknownTag // not used by gc (only appears in packages with errors)
+
+ // Aliases
+ aliasTag
)
var predeclared = []types.Type{
import (
"go/ast"
+ "go/build"
+ "math"
)
// Issue 3682: Correctly read dotted identifiers from export data.
C7 = `bar\n`
)
+const (
+ C8 => math.Pi
+)
+
type (
T1 int
T2 [10]int
T28 func(T28) T28
)
+type (
+ T29 => ast.File
+ T30 => build.Context
+)
+
var (
V0 int
- V1 = -991.0
+ V1 = -991.0
+ V2 float32 = 1.2
+)
+
+var (
+ V3 => build.Default
)
func F1() {}
func F5(a, b, c int, u, v, w struct{ x, y T1 }, more ...interface{}) (p, q, r chan<- T10)
func (p *T1) M1()
+
+func F6 => math.Sin
+func F7 => ast.IsExported
+func F8 => build.Import