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
f22f4fc1
Commit
f22f4fc1
authored
Feb 02, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Permit importing a method to a type being defined.
From-SVN: r183840
parent
5ee770bf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
13 deletions
+32
-13
gcc/go/gofrontend/gogo.cc
+4
-3
gcc/go/gofrontend/gogo.h
+2
-2
gcc/go/gofrontend/import.cc
+23
-6
gcc/go/gofrontend/types.cc
+2
-1
gcc/go/gofrontend/types.h
+1
-1
No files found.
gcc/go/gofrontend/gogo.cc
View file @
f22f4fc1
...
@@ -880,7 +880,7 @@ Gogo::declare_function(const std::string& name, Function_type* type,
...
@@ -880,7 +880,7 @@ Gogo::declare_function(const std::string& name, Function_type* type,
else
if
(
rtype
->
forward_declaration_type
()
!=
NULL
)
else
if
(
rtype
->
forward_declaration_type
()
!=
NULL
)
{
{
Forward_declaration_type
*
ftype
=
rtype
->
forward_declaration_type
();
Forward_declaration_type
*
ftype
=
rtype
->
forward_declaration_type
();
return
ftype
->
add_method_declaration
(
name
,
type
,
location
);
return
ftype
->
add_method_declaration
(
name
,
NULL
,
type
,
location
);
}
}
else
else
go_unreachable
();
go_unreachable
();
...
@@ -4325,11 +4325,12 @@ Type_declaration::add_method(const std::string& name, Function* function)
...
@@ -4325,11 +4325,12 @@ Type_declaration::add_method(const std::string& name, Function* function)
Named_object
*
Named_object
*
Type_declaration
::
add_method_declaration
(
const
std
::
string
&
name
,
Type_declaration
::
add_method_declaration
(
const
std
::
string
&
name
,
Package
*
package
,
Function_type
*
type
,
Function_type
*
type
,
Location
location
)
Location
location
)
{
{
Named_object
*
ret
=
Named_object
::
make_function_declaration
(
name
,
NULL
,
typ
e
,
Named_object
*
ret
=
Named_object
::
make_function_declaration
(
name
,
packag
e
,
location
);
type
,
location
);
this
->
methods_
.
push_back
(
ret
);
this
->
methods_
.
push_back
(
ret
);
return
ret
;
return
ret
;
}
}
...
...
gcc/go/gofrontend/gogo.h
View file @
f22f4fc1
...
@@ -1621,8 +1621,8 @@ class Type_declaration
...
@@ -1621,8 +1621,8 @@ class Type_declaration
// Add a method declaration to this type.
// Add a method declaration to this type.
Named_object
*
Named_object
*
add_method_declaration
(
const
std
::
string
&
name
,
Function_type
*
type
,
add_method_declaration
(
const
std
::
string
&
name
,
Package
*
,
Location
location
);
Function_type
*
type
,
Location
location
);
// Return whether any methods were defined.
// Return whether any methods were defined.
bool
bool
...
...
gcc/go/gofrontend/import.cc
View file @
f22f4fc1
...
@@ -441,12 +441,29 @@ Import::import_func(Package* package)
...
@@ -441,12 +441,29 @@ Import::import_func(Package* package)
Named_object
*
no
;
Named_object
*
no
;
if
(
fntype
->
is_method
())
if
(
fntype
->
is_method
())
{
{
Type
*
rtype
=
receiver
->
type
()
->
deref
();
Type
*
rtype
=
receiver
->
type
();
// We may still be reading the definition of RTYPE, so we have
// to be careful to avoid calling base or convert. If RTYPE is
// a named type or a forward declaration, then we know that it
// is not a pointer, because we are reading a method on RTYPE
// and named pointers can't have methods.
if
(
rtype
->
classification
()
==
Type
::
TYPE_POINTER
)
rtype
=
rtype
->
points_to
();
if
(
rtype
->
is_error_type
())
if
(
rtype
->
is_error_type
())
return
NULL
;
return
NULL
;
Named_type
*
named_rtype
=
rtype
->
named_type
();
else
if
(
rtype
->
named_type
()
!=
NULL
)
go_assert
(
named_rtype
!=
NULL
);
no
=
rtype
->
named_type
()
->
add_method_declaration
(
name
,
package
,
fntype
,
no
=
named_rtype
->
add_method_declaration
(
name
,
package
,
fntype
,
loc
);
loc
);
else
if
(
rtype
->
forward_declaration_type
()
!=
NULL
)
no
=
rtype
->
forward_declaration_type
()
->
add_method_declaration
(
name
,
package
,
fntype
,
loc
);
else
go_unreachable
();
}
}
else
else
{
{
...
@@ -647,8 +664,8 @@ Import::read_type()
...
@@ -647,8 +664,8 @@ Import::read_type()
{
{
// We have seen this type before. FIXME: it would be a good
// We have seen this type before. FIXME: it would be a good
// idea to check that the two imported types are identical,
// idea to check that the two imported types are identical,
// but we have not finalized the methds yet, which means
// but we have not finalized the meth
o
ds yet, which means
// that we can nt reliably compare interface types.
// that we can n
o
t reliably compare interface types.
type
=
no
->
type_value
();
type
=
no
->
type_value
();
// Don't change the visibility of the existing type.
// Don't change the visibility of the existing type.
...
...
gcc/go/gofrontend/types.cc
View file @
f22f4fc1
...
@@ -9115,6 +9115,7 @@ Forward_declaration_type::add_method(const std::string& name,
...
@@ -9115,6 +9115,7 @@ Forward_declaration_type::add_method(const std::string& name,
Named_object
*
Named_object
*
Forward_declaration_type
::
add_method_declaration
(
const
std
::
string
&
name
,
Forward_declaration_type
::
add_method_declaration
(
const
std
::
string
&
name
,
Package
*
package
,
Function_type
*
type
,
Function_type
*
type
,
Location
location
)
Location
location
)
{
{
...
@@ -9122,7 +9123,7 @@ Forward_declaration_type::add_method_declaration(const std::string& name,
...
@@ -9122,7 +9123,7 @@ Forward_declaration_type::add_method_declaration(const std::string& name,
if
(
no
->
is_unknown
())
if
(
no
->
is_unknown
())
no
->
declare_as_type
();
no
->
declare_as_type
();
Type_declaration
*
td
=
no
->
type_declaration_value
();
Type_declaration
*
td
=
no
->
type_declaration_value
();
return
td
->
add_method_declaration
(
name
,
type
,
location
);
return
td
->
add_method_declaration
(
name
,
package
,
type
,
location
);
}
}
// Traversal.
// Traversal.
...
...
gcc/go/gofrontend/types.h
View file @
f22f4fc1
...
@@ -2937,7 +2937,7 @@ class Forward_declaration_type : public Type
...
@@ -2937,7 +2937,7 @@ class Forward_declaration_type : public Type
// Add a method declaration to this type.
// Add a method declaration to this type.
Named_object
*
Named_object
*
add_method_declaration
(
const
std
::
string
&
name
,
Function_type
*
,
add_method_declaration
(
const
std
::
string
&
name
,
Package
*
,
Function_type
*
,
Location
);
Location
);
protected
:
protected
:
...
...
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