Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
f21f4773
Commit
f21f4773
authored
Feb 17, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: List imported packages in export information.
From-SVN: r184355
parent
b2c4b7b9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
4 deletions
+74
-4
gcc/go/gofrontend/export.cc
+44
-2
gcc/go/gofrontend/export.h
+6
-0
gcc/go/gofrontend/gogo.cc
+1
-0
gcc/go/gofrontend/import.cc
+17
-2
gcc/go/gofrontend/import.h
+4
-0
gcc/go/gofrontend/unsafe.cc
+2
-0
No files found.
gcc/go/gofrontend/export.cc
View file @
f21f4773
...
...
@@ -93,6 +93,7 @@ void
Export
::
export_globals
(
const
std
::
string
&
package_name
,
const
std
::
string
&
unique_prefix
,
int
package_priority
,
const
std
::
map
<
std
::
string
,
Package
*>&
imports
,
const
std
::
string
&
import_init_fn
,
const
std
::
set
<
Import_init
>&
imported_init_fns
,
const
Bindings
*
bindings
)
...
...
@@ -149,6 +150,8 @@ Export::export_globals(const std::string& package_name,
snprintf
(
buf
,
sizeof
buf
,
"priority %d;
\n
"
,
package_priority
);
this
->
write_c_string
(
buf
);
this
->
write_imports
(
imports
);
this
->
write_imported_init_fns
(
package_name
,
package_priority
,
import_init_fn
,
imported_init_fns
);
...
...
@@ -177,7 +180,46 @@ Export::export_globals(const std::string& package_name,
this
->
stream_
->
write_checksum
(
s
);
}
// Write out the import control variables for this package.
// Sort imported packages.
static
bool
import_compare
(
const
std
::
pair
<
std
::
string
,
Package
*>&
a
,
const
std
::
pair
<
std
::
string
,
Package
*>&
b
)
{
return
a
.
first
<
b
.
first
;
}
// Write out the imported packages.
void
Export
::
write_imports
(
const
std
::
map
<
std
::
string
,
Package
*>&
imports
)
{
// Sort the imports for more consistent output.
std
::
vector
<
std
::
pair
<
std
::
string
,
Package
*>
>
imp
;
for
(
std
::
map
<
std
::
string
,
Package
*>::
const_iterator
p
=
imports
.
begin
();
p
!=
imports
.
end
();
++
p
)
imp
.
push_back
(
std
::
make_pair
(
p
->
first
,
p
->
second
));
std
::
sort
(
imp
.
begin
(),
imp
.
end
(),
import_compare
);
for
(
std
::
vector
<
std
::
pair
<
std
::
string
,
Package
*>
>::
const_iterator
p
=
imp
.
begin
();
p
!=
imp
.
end
();
++
p
)
{
this
->
write_c_string
(
"import "
);
this
->
write_string
(
p
->
second
->
name
());
this
->
write_c_string
(
" "
);
this
->
write_string
(
p
->
second
->
unique_prefix
());
this
->
write_c_string
(
"
\"
"
);
this
->
write_string
(
p
->
first
);
this
->
write_c_string
(
"
\"
;
\n
"
);
}
}
// Write out the initialization functions which need to run for this
// package.
void
Export
::
write_imported_init_fns
(
...
...
@@ -189,7 +231,7 @@ Export::write_imported_init_fns(
if
(
import_init_fn
.
empty
()
&&
imported_init_fns
.
empty
())
return
;
this
->
write_c_string
(
"i
mpor
t"
);
this
->
write_c_string
(
"i
ni
t"
);
if
(
!
import_init_fn
.
empty
())
{
...
...
gcc/go/gofrontend/export.h
View file @
f21f4773
...
...
@@ -14,6 +14,7 @@ class Gogo;
class
Import_init
;
class
Bindings
;
class
Type
;
class
Package
;
// Codes used for the builtin types. These are all negative to make
// them easily distinct from the codes assigned by Export::write_type.
...
...
@@ -126,6 +127,7 @@ class Export : public String_dump
export_globals
(
const
std
::
string
&
package_name
,
const
std
::
string
&
unique_prefix
,
int
package_priority
,
const
std
::
map
<
std
::
string
,
Package
*>&
imports
,
const
std
::
string
&
import_init_fn
,
const
std
::
set
<
Import_init
>&
imported_init_fns
,
const
Bindings
*
bindings
);
...
...
@@ -158,6 +160,10 @@ class Export : public String_dump
Export
(
const
Export
&
);
Export
&
operator
=
(
const
Export
&
);
// Write out the imported packages.
void
write_imports
(
const
std
::
map
<
std
::
string
,
Package
*>&
imports
);
// Write out the imported initialization functions.
void
write_imported_init_fns
(
const
std
::
string
&
package_name
,
int
priority
,
...
...
gcc/go/gofrontend/gogo.cc
View file @
f21f4773
...
...
@@ -2859,6 +2859,7 @@ Gogo::do_exports()
exp
.
export_globals
(
this
->
package_name
(),
this
->
unique_prefix
(),
this
->
package_priority
(),
this
->
imports_
,
(
this
->
need_init_fn_
&&
!
this
->
is_main_package
()
?
this
->
get_init_fn_name
()
:
""
),
...
...
gcc/go/gofrontend/import.cc
View file @
f21f4773
...
...
@@ -304,7 +304,10 @@ Import::import(Gogo* gogo, const std::string& local_name,
this
->
package_
->
set_priority
(
prio
);
this
->
require_c_string
(
";
\n
"
);
if
(
stream
->
match_c_string
(
"import "
))
while
(
stream
->
match_c_string
(
"import"
))
this
->
read_one_import
();
if
(
stream
->
match_c_string
(
"init"
))
this
->
read_import_init_fns
(
gogo
);
// Loop over all the input data for this package.
...
...
@@ -344,12 +347,24 @@ Import::import(Gogo* gogo, const std::string& local_name,
return
this
->
package_
;
}
// Read an import line. We don't actually care about these.
void
Import
::
read_one_import
()
{
this
->
require_c_string
(
"import "
);
Stream
*
stream
=
this
->
stream_
;
while
(
stream
->
peek_char
()
!=
';'
)
stream
->
advance
(
1
);
this
->
require_c_string
(
";
\n
"
);
}
// Read the list of import control functions.
void
Import
::
read_import_init_fns
(
Gogo
*
gogo
)
{
this
->
require_c_string
(
"i
mpor
t"
);
this
->
require_c_string
(
"i
ni
t"
);
while
(
!
this
->
match_c_string
(
";"
))
{
this
->
require_c_string
(
" "
);
...
...
gcc/go/gofrontend/import.h
View file @
f21f4773
...
...
@@ -213,6 +213,10 @@ class Import
find_archive_export_data
(
const
std
::
string
&
filename
,
int
fd
,
Location
);
// Read an import line.
void
read_one_import
();
// Read the import control functions.
void
read_import_init_fns
(
Gogo
*
);
...
...
gcc/go/gofrontend/unsafe.cc
View file @
f21f4773
...
...
@@ -34,6 +34,8 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported,
package
->
set_location
(
location
);
package
->
set_is_imported
();
this
->
imports_
.
insert
(
std
::
make_pair
(
"unsafe"
,
package
));
Bindings
*
bindings
=
package
->
bindings
();
// The type may have already been created by an import.
...
...
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