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
5649c23c
Commit
5649c23c
authored
Aug 10, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed op=, ++ and -- on maps (bug060)
R=r DELTA=22 (21 added, 0 deleted, 1 changed) OCL=14049 CL=14049
parent
258c817a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
walk.c
src/cmd/gc/walk.c
+21
-0
No files found.
src/cmd/gc/walk.c
View file @
5649c23c
...
...
@@ -458,7 +458,13 @@ loop:
if
(
top
!=
Etop
)
goto
nottop
;
walktype
(
n
->
left
,
Elv
);
l
=
n
->
left
;
if
(
l
->
op
!=
OINDEX
)
goto
com
;
if
(
!
isptrto
(
l
->
left
->
type
,
TMAP
))
goto
com
;
*
n
=
*
mapop
(
n
,
top
);
goto
loop
;
case
OLSH
:
case
ORSH
:
...
...
@@ -1875,6 +1881,21 @@ mapop(Node *n, int top)
r
=
n
;
break
;
case
OASOP
:
// rewrite map[index] op= right
// into tmpi := index; map[tmpi] = map[tmpi] op right
t
=
n
->
left
->
left
->
type
->
type
;
a
=
nod
(
OXXX
,
N
,
N
);
tempname
(
a
,
t
->
down
);
// tmpi
r
=
nod
(
OAS
,
a
,
n
->
left
->
right
);
// tmpi := index
n
->
left
->
right
=
a
;
// m[tmpi]
a
=
nod
(
OXXX
,
N
,
N
);
*
a
=
*
n
->
left
;
// copy of map[tmpi]
a
=
nod
(
n
->
etype
,
a
,
n
->
right
);
// m[tmpi] op right
a
=
nod
(
OAS
,
n
->
left
,
a
);
// map[tmpi] = map[tmpi] op right
r
=
nod
(
OLIST
,
r
,
a
);
}
return
r
;
...
...
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