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
6d69c02e
Commit
6d69c02e
authored
Apr 27, 2011
by
Ian Lance Taylor
Committed by
Ian Lance Taylor
Apr 27, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use backend interface for struct types.
* go-gcc.cc (Gcc_backend::struct_type): Implement. From-SVN: r173004
parent
dcd83a81
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
9 deletions
+50
-9
gcc/go/ChangeLog
+4
-0
gcc/go/go-gcc.cc
+27
-2
gcc/go/gofrontend/types.cc
+19
-7
No files found.
gcc/go/ChangeLog
View file @
6d69c02e
2011-04-26 Ian Lance Taylor <iant@google.com>
* go-gcc.cc (Gcc_backend::struct_type): Implement.
2011-04-25 Ian Lance Taylor <iant@google.com>
* go-gcc.cc (Gcc_backend::error_type): Implement.
...
...
gcc/go/go-gcc.cc
View file @
6d69c02e
...
...
@@ -158,8 +158,7 @@ class Gcc_backend : public Backend
source_location
);
Btype
*
struct_type
(
const
std
::
vector
<
Btyped_identifier
>&
)
{
gcc_unreachable
();
}
struct_type
(
const
std
::
vector
<
Btyped_identifier
>&
);
Btype
*
array_type
(
const
Btype
*
/* element_type */
,
const
Bexpression
*
/* length */
)
...
...
@@ -449,6 +448,32 @@ Gcc_backend::function_type(const Btyped_identifier& receiver,
return
this
->
make_type
(
build_pointer_type
(
fntype
));
}
// Make a struct type.
Btype
*
Gcc_backend
::
struct_type
(
const
std
::
vector
<
Btyped_identifier
>&
fields
)
{
tree
ret
=
make_node
(
RECORD_TYPE
);
tree
field_trees
=
NULL_TREE
;
tree
*
pp
=
&
field_trees
;
for
(
std
::
vector
<
Btyped_identifier
>::
const_iterator
p
=
fields
.
begin
();
p
!=
fields
.
end
();
++
p
)
{
tree
name_tree
=
get_identifier_from_string
(
p
->
name
);
tree
type_tree
=
p
->
btype
->
get_tree
();
if
(
type_tree
==
error_mark_node
)
return
this
->
error_type
();
tree
field
=
build_decl
(
p
->
location
,
FIELD_DECL
,
name_tree
,
type_tree
);
DECL_CONTEXT
(
field
)
=
ret
;
*
pp
=
field
;
pp
=
&
DECL_CHAIN
(
field
);
}
TYPE_FIELDS
(
ret
)
=
field_trees
;
layout_type
(
ret
);
return
this
->
make_type
(
ret
);
}
// An expression as a statement.
Bstatement
*
...
...
gcc/go/gofrontend/types.cc
View file @
6d69c02e
...
...
@@ -2593,7 +2593,7 @@ Function_type::do_get_tree(Gogo* gogo)
Backend
::
Btyped_identifier
breceiver
;
if
(
this
->
receiver_
!=
NULL
)
{
breceiver
.
name
=
this
->
receiver_
->
name
(
);
breceiver
.
name
=
Gogo
::
unpack_hidden_name
(
this
->
receiver_
->
name
()
);
// We always pass the address of the receiver parameter, in
// order to make interface calls work with unknown types.
...
...
@@ -2613,11 +2613,11 @@ Function_type::do_get_tree(Gogo* gogo)
p
!=
this
->
parameters_
->
end
();
++
p
,
++
i
)
{
bparameters
[
i
].
name
=
p
->
name
(
);
bparameters
[
i
].
name
=
Gogo
::
unpack_hidden_name
(
p
->
name
()
);
bparameters
[
i
].
btype
=
tree_to_type
(
p
->
type
()
->
get_tree
(
gogo
));
bparameters
[
i
].
location
=
p
->
location
();
}
g
cc
_assert
(
i
==
bparameters
.
size
());
g
o
_assert
(
i
==
bparameters
.
size
());
}
std
::
vector
<
Backend
::
Btyped_identifier
>
bresults
;
...
...
@@ -2629,11 +2629,11 @@ Function_type::do_get_tree(Gogo* gogo)
p
!=
this
->
results_
->
end
();
++
p
,
++
i
)
{
bresults
[
i
].
name
=
p
->
name
(
);
bresults
[
i
].
name
=
Gogo
::
unpack_hidden_name
(
p
->
name
()
);
bresults
[
i
].
btype
=
tree_to_type
(
p
->
type
()
->
get_tree
(
gogo
));
bresults
[
i
].
location
=
p
->
location
();
}
g
cc
_assert
(
i
==
bresults
.
size
());
g
o
_assert
(
i
==
bresults
.
size
());
}
Btype
*
fntype
=
gogo
->
backend
()
->
function_type
(
breceiver
,
bparameters
,
...
...
@@ -3753,8 +3753,20 @@ Struct_type::method_function(const std::string& name, bool* is_ambiguous) const
tree
Struct_type
::
do_get_tree
(
Gogo
*
gogo
)
{
tree
type
=
make_node
(
RECORD_TYPE
);
return
this
->
fill_in_tree
(
gogo
,
type
);
std
::
vector
<
Backend
::
Btyped_identifier
>
fields
;
fields
.
resize
(
this
->
fields_
->
size
());
size_t
i
=
0
;
for
(
Struct_field_list
::
const_iterator
p
=
this
->
fields_
->
begin
();
p
!=
this
->
fields_
->
end
();
++
p
,
++
i
)
{
fields
[
i
].
name
=
Gogo
::
unpack_hidden_name
(
p
->
field_name
());
fields
[
i
].
btype
=
tree_to_type
(
p
->
type
()
->
get_tree
(
gogo
));
fields
[
i
].
location
=
p
->
location
();
}
go_assert
(
i
==
this
->
fields_
->
size
());
Btype
*
btype
=
gogo
->
backend
()
->
struct_type
(
fields
);
return
type_to_tree
(
btype
);
}
// Fill in the fields for a struct type.
...
...
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