1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:34:40 -07:00

go/ast: predeclared objects have the Universe/Unsafe scope as Decl

Makes it possible to easily detect if an Object was predeclared
(as opposed to unresolved).

R=rsc
CC=golang-dev
https://golang.org/cl/5530072
This commit is contained in:
Robert Griesemer 2012-01-10 18:30:06 -08:00
parent b06514bb34
commit 090049130e
2 changed files with 4 additions and 1 deletions

View File

@ -20,6 +20,7 @@ func define(kind ast.ObjKind, name string) *ast.Object {
if scope.Insert(obj) != nil {
panic("types internal error: double declaration")
}
obj.Decl = scope
return obj
}

View File

@ -80,7 +80,7 @@ func (s *Scope) String() string {
type Object struct {
Kind ObjKind
Name string // declared name
Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, or AssignStmt; or nil
Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
Data interface{} // object-specific data; or nil
Type interface{} // place holder for type information; may be nil
}
@ -131,6 +131,8 @@ func (obj *Object) Pos() token.Pos {
return ident.Pos()
}
}
case *Scope:
// predeclared object - nothing to do for now
}
return token.NoPos
}