Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
6c3736a5
Commit
6c3736a5
authored
Jan 14, 2013
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/types: mark completely imported packages as such
R=adonovan CC=golang-dev
https://golang.org/cl/7103055
parent
7f18f811
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
27 deletions
+20
-27
check.go
src/pkg/go/types/check.go
+1
-13
gcimporter.go
src/pkg/go/types/gcimporter.go
+14
-10
objects.go
src/pkg/go/types/objects.go
+5
-4
No files found.
src/pkg/go/types/check.go
View file @
6c3736a5
...
@@ -418,19 +418,7 @@ func check(ctxt *Context, fset *token.FileSet, files []*ast.File) (pkg *Package,
...
@@ -418,19 +418,7 @@ func check(ctxt *Context, fset *token.FileSet, files []*ast.File) (pkg *Package,
// resolve identifiers
// resolve identifiers
imp
:=
ctxt
.
Import
imp
:=
ctxt
.
Import
if
imp
==
nil
{
if
imp
==
nil
{
// wrap GcImport to import packages only once by default.
imp
=
GcImport
// TODO(gri) move this into resolve
imported
:=
make
(
map
[
string
]
bool
)
imp
=
func
(
imports
map
[
string
]
*
Package
,
path
string
)
(
*
Package
,
error
)
{
if
imported
[
path
]
&&
imports
[
path
]
!=
nil
{
return
imports
[
path
],
nil
}
pkg
,
err
:=
GcImport
(
imports
,
path
)
if
err
==
nil
{
imported
[
path
]
=
true
}
return
pkg
,
err
}
}
}
pkg
,
methods
:=
check
.
resolve
(
imp
)
pkg
,
methods
:=
check
.
resolve
(
imp
)
check
.
pkg
=
pkg
check
.
pkg
=
pkg
...
...
src/pkg/go/types/gcimporter.go
View file @
6c3736a5
...
@@ -77,10 +77,13 @@ func FindPkg(path, srcDir string) (filename, id string) {
...
@@ -77,10 +77,13 @@ func FindPkg(path, srcDir string) (filename, id string) {
// adds the corresponding package object to the imports map indexed by id,
// adds the corresponding package object to the imports map indexed by id,
// and returns the object.
// and returns the object.
//
//
// The imports map must contains all packages already imported, and no map
// The imports map must contains all packages already imported. The data
// entry with id as the key must be present. The data reader position must
// reader position must be the beginning of the export data section. The
// be the beginning of the export data section. The filename is only used
// filename is only used in error messages.
// in error messages.
//
// If imports[id] contains the completely imported package, that package
// can be used directly, and there is no need to call this function (but
// there is also no harm but for extra time used).
//
//
func
GcImportData
(
imports
map
[
string
]
*
Package
,
filename
,
id
string
,
data
*
bufio
.
Reader
)
(
pkg
*
Package
,
err
error
)
{
func
GcImportData
(
imports
map
[
string
]
*
Package
,
filename
,
id
string
,
data
*
bufio
.
Reader
)
(
pkg
*
Package
,
err
error
)
{
// support for gcParser error handling
// support for gcParser error handling
...
@@ -118,12 +121,10 @@ func GcImport(imports map[string]*Package, path string) (pkg *Package, err error
...
@@ -118,12 +121,10 @@ func GcImport(imports map[string]*Package, path string) (pkg *Package, err error
return
return
}
}
// Note: imports[id] may already contain a partially imported package.
// no need to re-import if the package was imported completely before
// We must continue doing the full import here since we don't
if
pkg
=
imports
[
id
];
pkg
!=
nil
&&
pkg
.
Complete
{
// know if something is missing.
return
// TODO: There's no need to re-import a package if we know that we
}
// have done a full import before. At the moment we cannot
// tell from the available information in this function alone.
// open file
// open file
f
,
err
:=
os
.
Open
(
filename
)
f
,
err
:=
os
.
Open
(
filename
)
...
@@ -900,5 +901,8 @@ func (p *gcParser) parseExport() *Package {
...
@@ -900,5 +901,8 @@ func (p *gcParser) parseExport() *Package {
p
.
errorf
(
"expected no scanner errors, got %d"
,
n
)
p
.
errorf
(
"expected no scanner errors, got %d"
,
n
)
}
}
// package was imported completely and without errors
pkg
.
Complete
=
true
return
pkg
return
pkg
}
}
src/pkg/go/types/objects.go
View file @
6c3736a5
...
@@ -23,10 +23,11 @@ type Object interface {
...
@@ -23,10 +23,11 @@ type Object interface {
// A Package represents the contents (objects) of a Go package.
// A Package represents the contents (objects) of a Go package.
type
Package
struct
{
type
Package
struct
{
Name
string
Name
string
Path
string
// import path, "" for current (non-imported) package
Path
string
// import path, "" for current (non-imported) package
Scope
*
Scope
// package-level scope
Scope
*
Scope
// package-level scope
Imports
map
[
string
]
*
Package
// map of import paths to imported packages
Imports
map
[
string
]
*
Package
// map of import paths to imported packages
Complete
bool
// if set, this package was imported completely
spec
*
ast
.
ImportSpec
spec
*
ast
.
ImportSpec
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment