Commit 09004913 authored by Robert Griesemer's avatar Robert Griesemer

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
parent b06514bb
...@@ -20,6 +20,7 @@ func define(kind ast.ObjKind, name string) *ast.Object { ...@@ -20,6 +20,7 @@ func define(kind ast.ObjKind, name string) *ast.Object {
if scope.Insert(obj) != nil { if scope.Insert(obj) != nil {
panic("types internal error: double declaration") panic("types internal error: double declaration")
} }
obj.Decl = scope
return obj return obj
} }
......
...@@ -80,7 +80,7 @@ func (s *Scope) String() string { ...@@ -80,7 +80,7 @@ func (s *Scope) String() string {
type Object struct { type Object struct {
Kind ObjKind Kind ObjKind
Name string // declared name 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 Data interface{} // object-specific data; or nil
Type interface{} // place holder for type information; may be nil Type interface{} // place holder for type information; may be nil
} }
...@@ -131,6 +131,8 @@ func (obj *Object) Pos() token.Pos { ...@@ -131,6 +131,8 @@ func (obj *Object) Pos() token.Pos {
return ident.Pos() return ident.Pos()
} }
} }
case *Scope:
// predeclared object - nothing to do for now
} }
return token.NoPos return token.NoPos
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment