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 * type check the whole tree of an expression. | 6 * type check the whole tree of an expression. |
7 * calculates expression types. | 7 * calculates expression types. |
8 * evaluates compile time constants. | 8 * evaluates compile time constants. |
9 * marks variables that escape the local frame. | 9 * marks variables that escape the local frame. |
10 * rewrites n->op to be more specific in some cases. | 10 * rewrites n->op to be more specific in some cases. |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 */ | 517 */ |
518 case OASOP: | 518 case OASOP: |
519 ok |= Etop; | 519 ok |= Etop; |
520 l = typecheck(&n->left, Erv); | 520 l = typecheck(&n->left, Erv); |
521 checkassign(n->left); | 521 checkassign(n->left); |
522 r = typecheck(&n->right, Erv); | 522 r = typecheck(&n->right, Erv); |
523 if(l->type == T || r->type == T) | 523 if(l->type == T || r->type == T) |
524 goto error; | 524 goto error; |
525 op = n->etype; | 525 op = n->etype; |
526 goto arith; | 526 goto arith; |
527 | |
528 case OADDPTR: | |
529 ok |= Erv; | |
530 l = typecheck(&n->left, Erv); | |
531 r = typecheck(&n->right, Erv); | |
532 if(l->type == T || r->type == T) | |
533 goto error; | |
534 if(l->type->etype != tptr) | |
535 fatal("bad OADDPTR left type %E for %N", l->type->etype,
n->left); | |
536 if(r->type->etype != TUINTPTR) | |
537 fatal("bad OADDPTR right type %E for %N", r->type->etype
, n->right); | |
538 n->type = types[tptr]; | |
539 goto ret; | |
540 | 527 |
541 case OADD: | 528 case OADD: |
542 case OAND: | 529 case OAND: |
543 case OANDAND: | 530 case OANDAND: |
544 case OANDNOT: | 531 case OANDNOT: |
545 case ODIV: | 532 case ODIV: |
546 case OEQ: | 533 case OEQ: |
547 case OGE: | 534 case OGE: |
548 case OGT: | 535 case OGT: |
549 case OLE: | 536 case OLE: |
(...skipping 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3527 return 0; | 3514 return 0; |
3528 } | 3515 } |
3529 | 3516 |
3530 void | 3517 void |
3531 checkreturn(Node *fn) | 3518 checkreturn(Node *fn) |
3532 { | 3519 { |
3533 if(fn->type->outtuple && fn->nbody != nil) | 3520 if(fn->type->outtuple && fn->nbody != nil) |
3534 if(!isterminating(fn->nbody, 1)) | 3521 if(!isterminating(fn->nbody, 1)) |
3535 yyerrorl(fn->endlineno, "missing return at end of functi
on"); | 3522 yyerrorl(fn->endlineno, "missing return at end of functi
on"); |
3536 } | 3523 } |
LEFT | RIGHT |