@@ -81,13 +81,31 @@ type object struct {
8181 scopePos_ token.Pos
8282}
8383
84- func (obj * object ) Parent () * Scope { return obj .parent }
85- func (obj * object ) Pos () token.Pos { return obj .pos }
86- func (obj * object ) Pkg () * Package { return obj .pkg }
87- func (obj * object ) Name () string { return obj .name }
88- func (obj * object ) Type () Type { return obj .typ }
89- func (obj * object ) Exported () bool { return ast .IsExported (obj .name ) }
90- func (obj * object ) Id () string { return Id (obj .pkg , obj .name ) }
84+ // Parent returns the scope in which the object is declared.
85+ // The result is nil for methods and struct fields.
86+ func (obj * object ) Parent () * Scope { return obj .parent }
87+
88+ // Pos returns the declaration position of the object's identifier.
89+ func (obj * object ) Pos () token.Pos { return obj .pos }
90+
91+ // Pkg returns the package to which the object belongs.
92+ // The result is nil for labels and objects in the Universe scope.
93+ func (obj * object ) Pkg () * Package { return obj .pkg }
94+
95+ // Name returns the object's (package-local, unqualified) name.
96+ func (obj * object ) Name () string { return obj .name }
97+
98+ // Type returns the object's type.
99+ func (obj * object ) Type () Type { return obj .typ }
100+
101+ // Exported reports whether the object is exported (starts with a capital letter).
102+ // It doesn't take into account whether the object is in a local (function) scope
103+ // or not.
104+ func (obj * object ) Exported () bool { return ast .IsExported (obj .name ) }
105+
106+ // Id is a wrapper for Id(obj.Pkg(), obj.Name()).
107+ func (obj * object ) Id () string { return Id (obj .pkg , obj .name ) }
108+
91109func (obj * object ) String () string { panic ("abstract" ) }
92110func (obj * object ) order () uint32 { return obj .order_ }
93111func (obj * object ) scopePos () token.Pos { return obj .scopePos_ }
@@ -149,10 +167,12 @@ func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.V
149167 return & Const {object {nil , pos , pkg , name , typ , 0 , token .NoPos }, val , false }
150168}
151169
170+ // Val returns the constant's value.
152171func (obj * Const ) Val () constant.Value { return obj .val }
153- func (* Const ) isDependency () {} // a constant may be a dependency of an initialization expression
154172
155- // A TypeName represents a name for a (named or alias) type.
173+ func (* Const ) isDependency () {} // a constant may be a dependency of an initialization expression
174+
175+ // A TypeName represents a name for a (defined or alias) type.
156176type TypeName struct {
157177 object
158178}
0 commit comments