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
5f0a5e7a
Commit
5f0a5e7a
authored
Sep 24, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more export
R=r OCL=15771 CL=15771
parent
3f106f97
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
22 deletions
+73
-22
export.c
src/cmd/gc/export.c
+69
-22
go.y
src/cmd/gc/go.y
+4
-0
No files found.
src/cmd/gc/export.c
View file @
5f0a5e7a
...
...
@@ -28,15 +28,11 @@ exportsym(Sym *s)
}
void
reexport
(
Type
*
t
)
makeexportsym
(
Type
*
t
)
{
Sym
*
s
;
if
(
t
==
T
)
fatal
(
"reexport: type nil"
);
s
=
t
->
sym
;
if
(
s
==
S
/* || s->name[0] == '_'*/
)
{
if
(
t
->
sym
==
S
)
{
exportgen
++
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_e%s_%.3ld"
,
filename
,
exportgen
);
s
=
lookup
(
namebuf
);
...
...
@@ -44,6 +40,18 @@ reexport(Type *t)
s
->
otype
=
t
;
t
->
sym
=
s
;
}
}
void
reexport
(
Type
*
t
)
{
Sym
*
s
;
if
(
t
==
T
)
fatal
(
"reexport: type nil"
);
makeexportsym
(
t
);
s
=
t
->
sym
;
dumpexporttype
(
s
);
}
...
...
@@ -164,14 +172,17 @@ dumpexporttype(Sym *s)
case
TPTR32
:
case
TPTR64
:
if
(
t
->
type
!=
T
&&
t
->
type
->
sym
==
S
)
reexport
(
t
->
type
);
if
(
t
->
type
==
T
)
fatal
(
"dumpexporttype: ptr %S"
,
s
);
makeexportsym
(
t
->
type
);
/* forw declare */
/* type 6 */
Bprint
(
bout
,
"
\t
type "
);
if
(
s
->
export
!=
0
)
Bprint
(
bout
,
"!"
);
Bprint
(
bout
,
"%lS *%lS
\n
"
,
s
,
t
->
type
->
sym
);
reexport
(
t
->
type
);
break
;
case
TFUNC
:
...
...
@@ -220,7 +231,7 @@ dumpexporttype(Sym *s)
reexport
(
t
->
type
);
reexport
(
t
->
down
);
/* type
6
*/
/* type
1
*/
Bprint
(
bout
,
"
\t
type "
);
if
(
s
->
export
!=
0
)
Bprint
(
bout
,
"!"
);
...
...
@@ -323,6 +334,50 @@ dumpexport(void)
/*
* ******* import *******
*/
void
checkimports
(
void
)
{
Sym
*
s
;
Type
*
t
,
*
t1
;
uint32
h
;
int
et
;
for
(
h
=
0
;
h
<
NHASH
;
h
++
)
for
(
s
=
hash
[
h
];
s
!=
S
;
s
=
s
->
link
)
{
t
=
s
->
otype
;
if
(
t
==
T
)
continue
;
et
=
t
->
etype
;
switch
(
t
->
etype
)
{
case
TFORW
:
print
(
"ci-1: %S %lT
\n
"
,
s
,
t
);
break
;
case
TPTR32
:
case
TPTR64
:
if
(
t
->
type
==
T
)
{
print
(
"ci-2: %S %lT
\n
"
,
s
,
t
);
break
;
}
t1
=
t
->
type
;
if
(
t1
==
T
)
{
print
(
"ci-3: %S %lT
\n
"
,
s
,
t1
);
break
;
}
et
=
t1
->
etype
;
if
(
et
==
TFORW
)
{
print
(
"%L: ci-4: %S %lT
\n
"
,
lineno
,
s
,
t
);
break
;
}
break
;
}
}
}
void
renamepkg
(
Node
*
n
)
{
...
...
@@ -451,21 +506,13 @@ importaddtyp(Node *ss, Type *t)
Sym
*
s
;
s
=
getimportsym
(
ss
);
if
(
ss
->
etype
){
// exported
if
(
s
->
otype
==
T
||
!
eqtype
(
t
,
s
->
otype
,
0
))
{
if
(
s
->
otype
!=
T
)
print
(
"redeclaring %S %lT => %lT
\n
"
,
s
,
s
->
otype
,
t
);
addtyp
(
newtype
(
s
),
t
,
PEXTERN
);
/*
* mark as export to avoid conflicting export bits
* in multi-file package.
*/
s
->
export
=
1
;
}
}
else
{
if
(
s
->
otype
!=
T
&&
!
eqtype
(
t
,
s
->
otype
,
0
))
{
yyerror
(
"import redeclaration of %S %lT => %lT
\n
"
,
s
,
s
->
otype
,
t
);
s
->
otype
=
t
;
t
->
sym
=
s
;
}
if
(
s
->
otype
==
T
)
addtyp
(
newtype
(
s
),
t
,
PEXTERN
);
}
/*
...
...
src/cmd/gc/go.y
View file @
5f0a5e7a
...
...
@@ -129,9 +129,13 @@ import_package:
import_there
:
hidden_import_list_r
')'
')'
{
checkimports
();
unimportfile
();
}
|
LIMPORT
'('
'('
hidden_import_list_r
')'
')'
{
checkimports
();
}
/*
*
declarations
...
...
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