LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * select | 6 * select |
7 */ | 7 */ |
8 | 8 |
9 #include "go.h" | 9 #include "go.h" |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 n->right = n->right->left; | 52 n->right = n->right->left; |
53 | 53 |
54 if(n->right->op != ORECV) { | 54 if(n->right->op != ORECV) { |
55 yyerror("select assignment must have rec
eive on right hand side"); | 55 yyerror("select assignment must have rec
eive on right hand side"); |
56 break; | 56 break; |
57 } | 57 } |
58 n->op = OSELRECV; | 58 n->op = OSELRECV; |
59 break; | 59 break; |
60 | 60 |
61 case OAS2RECV: | 61 case OAS2RECV: |
62 » » » » // convert x, ok = <-c into OSELRECV(x, <-c) wit
h ntest=ok | 62 » » » » // convert x, ok = <-c into OSELRECV2(x, <-c) wi
th ntest=ok |
63 if(n->right->op != ORECV) { | 63 if(n->right->op != ORECV) { |
64 yyerror("select assignment must have rec
eive on right hand side"); | 64 yyerror("select assignment must have rec
eive on right hand side"); |
65 break; | 65 break; |
66 } | 66 } |
67 n->op = OSELRECV2; | 67 n->op = OSELRECV2; |
68 n->left = n->list->n; | 68 n->left = n->list->n; |
69 n->ntest = n->list->next->n; | 69 n->ntest = n->list->next->n; |
70 n->right = n->rlist->n; | 70 n->right = n->rlist->n; |
71 break; | 71 break; |
72 | 72 |
73 case ORECV: | 73 case ORECV: |
74 // convert <-c into OSELRECV(N, <-c) | 74 // convert <-c into OSELRECV(N, <-c) |
75 n = nod(OSELRECV, N, n); | 75 n = nod(OSELRECV, N, n); |
| 76 n->typecheck = 1; |
76 ncase->left = n; | 77 ncase->left = n; |
77 break; | 78 break; |
78 | 79 |
79 case OSEND: | 80 case OSEND: |
80 break; | 81 break; |
81 } | 82 } |
82 } | 83 } |
83 typechecklist(ncase->nbody, Etop); | 84 typechecklist(ncase->nbody, Etop); |
84 } | 85 } |
85 sel->xoffset = count; | 86 sel->xoffset = count; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // run the select | 343 // run the select |
343 setlineno(sel); | 344 setlineno(sel); |
344 init = list(init, mkcall("selectgo", T, nil, var)); | 345 init = list(init, mkcall("selectgo", T, nil, var)); |
345 sel->nbody = init; | 346 sel->nbody = init; |
346 | 347 |
347 out: | 348 out: |
348 sel->list = nil; | 349 sel->list = nil; |
349 walkstmtlist(sel->nbody); | 350 walkstmtlist(sel->nbody); |
350 lineno = lno; | 351 lineno = lno; |
351 } | 352 } |
LEFT | RIGHT |