]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: predeclared objects have the Universe/Unsafe scope as Decl
authorRobert Griesemer <gri@golang.org>
Wed, 11 Jan 2012 02:30:06 +0000 (18:30 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 11 Jan 2012 02:30:06 +0000 (18:30 -0800)
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

src/pkg/exp/types/universe.go
src/pkg/go/ast/scope.go

index 780b82625f5f8208296f526074e7273a04c83858..46cff31bce84e8e833483d5e7cbbd96d61bf9c20 100644 (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
 }
 
index fbe4779671ec8fc67b857d89eae1c6e6cb01422a..11e6b13f169b807095b0ee40abe76a7b296c66d5 100644 (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
 }