Parse parses all packages and typechecks them. The returned error may be an Errors error, which contains a list of errors. Idempotent.
()
| 316 | // |
| 317 | // Idempotent. |
| 318 | func (p *Program) Parse() error { |
| 319 | // Parse all packages. |
| 320 | // TODO: do this in parallel. |
| 321 | for _, pkg := range p.sorted { |
| 322 | err := pkg.Parse() |
| 323 | if err != nil { |
| 324 | return err |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | // Typecheck all packages. |
| 329 | for _, pkg := range p.sorted { |
| 330 | err := pkg.Check() |
| 331 | if err != nil { |
| 332 | return err |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | return nil |
| 337 | } |
| 338 | |
| 339 | // OriginalDir returns the real directory name. It is the same as p.Dir except |
| 340 | // that if it is part of the cached GOROOT, its real location is returned. |