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
30444035
Commit
30444035
authored
Sep 17, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assignment in select
with new select operator R=r OCL=15418 CL=15418
parent
592d2e3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
go.h
src/cmd/gc/go.h
+2
-0
go.y
src/cmd/gc/go.y
+1
-1
walk.c
src/cmd/gc/walk.c
+34
-0
No files found.
src/cmd/gc/go.h
View file @
30444035
...
...
@@ -702,6 +702,8 @@ Node* reorder4(Node*);
Node
*
structlit
(
Node
*
);
Node
*
arraylit
(
Node
*
);
Node
*
maplit
(
Node
*
);
Node
*
selectas
(
Node
*
,
Node
*
);
Node
*
old2new
(
Node
*
,
Type
*
);
/*
* const.c
...
...
src/cmd/gc/go.y
View file @
30444035
...
...
@@ -427,7 +427,7 @@ complex_stmt:
//
right
will
point
to
next
case
//
done
in
casebody
()
poptodcl
();
$$
=
nod
(
OAS
,
colas
($
2
,
$
4
),
$
4
);
$$
=
nod
(
OAS
,
selectas
($
2
,
$
4
),
$
4
);
$$
=
nod
(
OXCASE
,
$$,
N
);
}
|
LDEFAULT
':'
...
...
src/cmd/gc/walk.c
View file @
30444035
...
...
@@ -1232,6 +1232,30 @@ out:
return
r
;
}
Node
*
selectas
(
Node
*
name
,
Node
*
expr
)
{
Node
*
a
;
Type
*
t
;
if
(
expr
==
N
||
expr
->
op
!=
ORECV
)
goto
bad
;
t
=
expr
->
left
->
type
;
if
(
t
==
T
)
goto
bad
;
if
(
isptr
[
t
->
etype
])
t
=
t
->
type
;
if
(
t
==
T
)
goto
bad
;
if
(
t
->
etype
!=
TCHAN
)
goto
bad
;
a
=
old2new
(
name
,
t
->
type
);
return
a
;
bad:
return
name
;
}
void
walkselect
(
Node
*
sel
)
{
...
...
@@ -1270,6 +1294,16 @@ walkselect(Node *sel)
yyerror
(
"select cases must be send or recv"
);
break
;
case
OAS
:
// convert new syntax (a=recv(chan)) to (recv(a,chan))
if
(
n
->
left
->
right
==
N
||
n
->
left
->
right
->
op
!=
ORECV
)
{
yyerror
(
"select cases must be send or recv"
);
break
;
}
n
->
left
->
right
->
right
=
n
->
left
->
right
->
left
;
n
->
left
->
right
->
left
=
n
->
left
->
left
;
n
->
left
=
n
->
left
->
right
;
case
OSEND
:
case
ORECV
:
if
(
oc
!=
N
)
{
...
...
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