Source File
resolve.go
Belonging Package
go/ast
package ast
import (
)
type pkgBuilder struct {
fset *token.FileSet
errors scanner.ErrorList
}
func ( *pkgBuilder) ( token.Pos, string) {
.errors.Add(.fset.Position(), )
}
func ( *pkgBuilder) ( token.Pos, string, ...interface{}) {
.error(, fmt.Sprintf(, ...))
}
func ( *pkgBuilder) (, *Scope, *Object) {
:= .Insert()
= .Lookup(.Name)
}
if != nil {
:= ""
if := .Pos(); .IsValid() {
= fmt.Sprintf("\n\tprevious declaration at %s", .fset.Position())
}
.error(.Pos(), fmt.Sprintf("%s redeclared in this block%s", .Name, ))
}
}
func ( *Scope, *Ident) bool {
for ; != nil; = .Outer {
if := .Lookup(.Name); != nil {
.Obj =
return true
}
}
return false
}
:= ""
:= NewScope()
.Outer = nil
}
:= 0
for , := range .Unresolved {
if !resolve(, ) {
.errorf(.Pos(), "undeclared name: %s", .Name)
.Unresolved[] =
++
}
}
.Unresolved = .Unresolved[0:]
.Outer = // reset universe scope
}
.errors.Sort()
return &Package{, , , }, .errors.Err()
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |