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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 ok |= Etype; | 452 ok |= Etype; |
453 n->op = OTYPE; | 453 n->op = OTYPE; |
454 n->type = tointerface(n->list); | 454 n->type = tointerface(n->list); |
455 if(n->type == T) | 455 if(n->type == T) |
456 goto error; | 456 goto error; |
457 break; | 457 break; |
458 | 458 |
459 case OTFUNC: | 459 case OTFUNC: |
460 ok |= Etype; | 460 ok |= Etype; |
461 n->op = OTYPE; | 461 n->op = OTYPE; |
462 » » n->type = functype(n->left, n->list, n->rlist); | 462 » » n->type = makefunctype(n->left, n->list, n->rlist); |
463 if(n->type == T) | 463 if(n->type == T) |
464 goto error; | 464 goto error; |
465 break; | 465 break; |
466 | 466 |
467 /* | 467 /* |
468 * type or expr | 468 * type or expr |
469 */ | 469 */ |
470 case OIND: | 470 case OIND: |
471 ntop = Erv | Etype; | 471 ntop = Erv | Etype; |
472 if(!(top & Eaddr)) // The *x in &*x is not an indir
ect. | 472 if(!(top & Eaddr)) // The *x in &*x is not an indir
ect. |
(...skipping 2530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 fatal("got %T for %N", n->type, n); | 3003 fatal("got %T for %N", n->type, n); |
3004 if(typecheckdefstack->n != n) | 3004 if(typecheckdefstack->n != n) |
3005 fatal("typecheckdefstack mismatch"); | 3005 fatal("typecheckdefstack mismatch"); |
3006 l = typecheckdefstack; | 3006 l = typecheckdefstack; |
3007 typecheckdefstack = l->next; | 3007 typecheckdefstack = l->next; |
3008 | 3008 |
3009 lineno = lno; | 3009 lineno = lno; |
3010 n->walkdef = 1; | 3010 n->walkdef = 1; |
3011 return n; | 3011 return n; |
3012 } | 3012 } |
LEFT | RIGHT |