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
e6f8e590
Commit
e6f8e590
authored
Sep 21, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support nil maps.
From-SVN: r179054
parent
bd352290
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
12 deletions
+27
-12
gcc/go/gofrontend/runtime.def
+2
-2
gcc/go/gofrontend/statements.cc
+7
-5
libgo/runtime/go-map-delete.c
+4
-0
libgo/runtime/go-map-index.c
+8
-0
libgo/runtime/map.goc
+6
-5
No files found.
gcc/go/gofrontend/runtime.def
View file @
e6f8e590
...
...
@@ -87,8 +87,8 @@ DEF_GO_RUNTIME(MAP_INDEX, "__go_map_index", P3(MAP, POINTER, BOOL),
R1(POINTER))
// Look up a key in a map returning whether it is present.
DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2",
P3(MAP, POINTER, POINTER),
R1(BOOL))
DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2",
P4(TYPE, MAP, POINTER, POINTER),
R1(BOOL))
// Tuple assignment to a map element.
DEF_GO_RUNTIME(MAPASSIGN2, "runtime.mapassign2",
...
...
gcc/go/gofrontend/statements.cc
View file @
e6f8e590
...
...
@@ -1085,14 +1085,16 @@ Tuple_map_assignment_statement::do_lower(Gogo*, Named_object*,
Statement
::
make_temporary
(
Type
::
lookup_bool_type
(),
NULL
,
loc
);
b
->
add_statement
(
present_temp
);
// present_temp = mapaccess2(MAP, &key_temp, &val_temp)
// present_temp = mapaccess2(DESCRIPTOR, MAP, &key_temp, &val_temp)
Expression
*
a1
=
Expression
::
make_type_descriptor
(
map_type
,
loc
);
Expression
*
a2
=
map_index
->
map
();
Temporary_reference_expression
*
ref
=
Expression
::
make_temporary_reference
(
key_temp
,
loc
);
Expression
*
a
1
=
Expression
::
make_unary
(
OPERATOR_AND
,
ref
,
loc
);
Expression
*
a
3
=
Expression
::
make_unary
(
OPERATOR_AND
,
ref
,
loc
);
ref
=
Expression
::
make_temporary_reference
(
val_temp
,
loc
);
Expression
*
a
2
=
Expression
::
make_unary
(
OPERATOR_AND
,
ref
,
loc
);
Expression
*
call
=
Runtime
::
make_call
(
Runtime
::
MAPACCESS2
,
loc
,
3
,
map_index
->
map
(),
a1
,
a2
);
Expression
*
a
4
=
Expression
::
make_unary
(
OPERATOR_AND
,
ref
,
loc
);
Expression
*
call
=
Runtime
::
make_call
(
Runtime
::
MAPACCESS2
,
loc
,
4
,
a1
,
a2
,
a3
,
a4
);
ref
=
Expression
::
make_temporary_reference
(
present_temp
,
loc
);
ref
->
set_is_lvalue
();
...
...
libgo/runtime/go-map-delete.c
View file @
e6f8e590
...
...
@@ -9,6 +9,7 @@
#include "go-alloc.h"
#include "go-assert.h"
#include "go-panic.h"
#include "map.h"
/* Delete the entry matching KEY from MAP. */
...
...
@@ -25,6 +26,9 @@ __go_map_delete (struct __go_map *map, const void *key)
size_t
bucket_index
;
void
**
pentry
;
if
(
map
==
NULL
)
__go_panic_msg
(
"assignment to entry in nil map"
);
descriptor
=
map
->
__descriptor
;
key_descriptor
=
descriptor
->
__map_descriptor
->
__key_type
;
...
...
libgo/runtime/go-map-index.c
View file @
e6f8e590
...
...
@@ -9,6 +9,7 @@
#include "go-alloc.h"
#include "go-assert.h"
#include "go-panic.h"
#include "map.h"
/* Rehash MAP to a larger size. */
...
...
@@ -85,6 +86,13 @@ __go_map_index (struct __go_map *map, const void *key, _Bool insert)
size_t
bucket_index
;
char
*
entry
;
if
(
map
==
NULL
)
{
if
(
insert
)
__go_panic_msg
(
"assignment to entry in nil map"
);
return
NULL
;
}
descriptor
=
map
->
__descriptor
;
key_descriptor
=
descriptor
->
__map_descriptor
->
__key_type
;
...
...
libgo/runtime/map.goc
View file @
e6f8e590
...
...
@@ -9,17 +9,18 @@ package runtime
typedef
unsigned
char
byte
;
typedef
_Bool
bool
;
typedef
struct
__go_map
hmap
;
typedef
struct
__go_map_type
MapType
;
typedef
struct
__go_map
Hmap
;
typedef
struct
__go_hash_iter
hiter
;
/*
Access
a
value
in
a
map
,
returning
a
value
and
a
presence
indicator
.
*/
func
mapaccess2
(
h
*
h
map
,
key
*
byte
,
val
*
byte
)
(
present
bool
)
{
func
mapaccess2
(
t
*
MapType
,
h
*
H
map
,
key
*
byte
,
val
*
byte
)
(
present
bool
)
{
byte
*
mapval
;
size_t
valsize
;
mapval
=
__go_map_index
(
h
,
key
,
0
);
valsize
=
h
->
__descriptor
->
__map_descriptor
->
__val_type
->
__size
;
valsize
=
t
->
__val_type
->
__size
;
if
(
mapval
==
nil
)
{
__builtin_memset
(
val
,
0
,
valsize
);
present
=
0
;
...
...
@@ -31,7 +32,7 @@ func mapaccess2(h *hmap, key *byte, val *byte) (present bool) {
/*
Optionally
assign
a
value
to
a
map
(
m
[
k
]
=
v
,
p
).
*/
func
mapassign2
(
h
*
h
map
,
key
*
byte
,
val
*
byte
,
p
bool
)
{
func
mapassign2
(
h
*
H
map
,
key
*
byte
,
val
*
byte
,
p
bool
)
{
if
(
!p) {
__go_map_delete
(
h
,
key
);
}
else
{
...
...
@@ -46,7 +47,7 @@ func mapassign2(h *hmap, key *byte, val *byte, p bool) {
/*
Initialize
a
range
over
a
map
.
*/
func
mapiterinit
(
h
*
h
map
,
it
*
hiter
)
{
func
mapiterinit
(
h
*
H
map
,
it
*
hiter
)
{
__go_mapiterinit
(
h
,
it
);
}
...
...
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