OLD | NEW |
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 #include "go.h" | 5 #include "go.h" |
6 | 6 |
7 static Node* walkprint(Node*, NodeList**, int); | 7 static Node* walkprint(Node*, NodeList**, int); |
8 static Node* conv(Node*, Type*); | 8 static Node* conv(Node*, Type*); |
9 static Node* mapfn(char*, Type*); | 9 static Node* mapfn(char*, Type*); |
10 static Node* makenewvar(Type*, NodeList**, Node**); | 10 static Node* makenewvar(Type*, NodeList**, Node**); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 void | 60 void |
61 walk(Node *fn) | 61 walk(Node *fn) |
62 { | 62 { |
63 char s[50]; | 63 char s[50]; |
64 NodeList *l; | 64 NodeList *l; |
65 Node *n; | 65 Node *n; |
66 int lno; | 66 int lno; |
67 | 67 |
68 curfn = fn; | 68 curfn = fn; |
| 69 |
69 if(debug['W']) { | 70 if(debug['W']) { |
70 snprint(s, sizeof(s), "\nbefore %S", curfn->nname->sym); | 71 snprint(s, sizeof(s), "\nbefore %S", curfn->nname->sym); |
71 dumplist(s, curfn->nbody); | 72 dumplist(s, curfn->nbody); |
72 } | 73 } |
73 if(curfn->type->outtuple) | 74 if(curfn->type->outtuple) |
74 if(walkret(curfn->nbody)) | 75 if(walkret(curfn->nbody)) |
75 yyerror("function ends without a return statement"); | 76 yyerror("function ends without a return statement"); |
76 » typechecklist(curfn->nbody, Etop); | 77 |
77 lno = lineno; | 78 lno = lineno; |
78 for(l=fn->dcl; l; l=l->next) { | 79 for(l=fn->dcl; l; l=l->next) { |
79 n = l->n; | 80 n = l->n; |
80 if(n->op != ONAME || n->class != PAUTO) | 81 if(n->op != ONAME || n->class != PAUTO) |
81 continue; | 82 continue; |
82 lineno = n->lineno; | 83 lineno = n->lineno; |
83 typecheck(&n, Erv | Easgn); // only needed for unused variab
les | 84 typecheck(&n, Erv | Easgn); // only needed for unused variab
les |
84 if(!n->used && n->sym->name[0] != '&' && !nsyntaxerrors) | 85 if(!n->used && n->sym->name[0] != '&' && !nsyntaxerrors) |
85 yyerror("%S declared and not used", n->sym); | 86 yyerror("%S declared and not used", n->sym); |
86 } | 87 } |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 case OCALLINTER: | 462 case OCALLINTER: |
462 case OCALL: | 463 case OCALL: |
463 case OCALLFUNC: | 464 case OCALLFUNC: |
464 case OSEND: | 465 case OSEND: |
465 case ORECV: | 466 case ORECV: |
466 case OPRINT: | 467 case OPRINT: |
467 case OPRINTN: | 468 case OPRINTN: |
468 case OPANIC: | 469 case OPANIC: |
469 case OEMPTY: | 470 case OEMPTY: |
470 case ORECOVER: | 471 case ORECOVER: |
471 » » if(n->typecheck == 0) | 472 » » if(n->typecheck == 0) { |
| 473 » » » dump("missing typecheck:", n); |
472 fatal("missing typecheck"); | 474 fatal("missing typecheck"); |
| 475 } |
473 init = n->ninit; | 476 init = n->ninit; |
474 n->ninit = nil; | 477 n->ninit = nil; |
475 walkexpr(&n, &init); | 478 walkexpr(&n, &init); |
476 n->ninit = concat(init, n->ninit); | 479 n->ninit = concat(init, n->ninit); |
477 break; | 480 break; |
478 | 481 |
479 case OBREAK: | 482 case OBREAK: |
480 case ODCL: | 483 case ODCL: |
481 case OCONTINUE: | 484 case OCONTINUE: |
482 case OFALL: | 485 case OFALL: |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 l = list(l, nod(OAS, nx, a->n)); // s[n] = arg | 2451 l = list(l, nod(OAS, nx, a->n)); // s[n] = arg |
2449 if (a->next != nil) | 2452 if (a->next != nil) |
2450 l = list(l, nod(OAS, nn, nod(OADD, nn, nodintconst(1))))
; // n = n + 1 | 2453 l = list(l, nod(OAS, nn, nod(OADD, nn, nodintconst(1))))
; // n = n + 1 |
2451 } | 2454 } |
2452 | 2455 |
2453 typechecklist(l, Etop); | 2456 typechecklist(l, Etop); |
2454 walkstmtlist(l); | 2457 walkstmtlist(l); |
2455 *init = concat(*init, l); | 2458 *init = concat(*init, l); |
2456 return ns; | 2459 return ns; |
2457 } | 2460 } |
OLD | NEW |