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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 yyerror("invalid use of ... with builtin %#N", l
); | 787 yyerror("invalid use of ... with builtin %#N", l
); |
788 // builtin: OLEN, OCAP, etc. | 788 // builtin: OLEN, OCAP, etc. |
789 n->op = l->etype; | 789 n->op = l->etype; |
790 n->left = n->right; | 790 n->left = n->right; |
791 n->right = N; | 791 n->right = N; |
792 goto reswitch; | 792 goto reswitch; |
793 } | 793 } |
794 defaultlit(&n->left, T); | 794 defaultlit(&n->left, T); |
795 l = n->left; | 795 l = n->left; |
796 if(l->op == OTYPE) { | 796 if(l->op == OTYPE) { |
797 » » » if(n->isddd) | 797 » » » if(n->isddd || l->type->bound == -100) |
798 yyerror("invalid use of ... in type conversion",
l); | 798 yyerror("invalid use of ... in type conversion",
l); |
799 // pick off before type-checking arguments | 799 // pick off before type-checking arguments |
800 ok |= Erv; | 800 ok |= Erv; |
801 // turn CALL(type, arg) into CONV(arg) w/ type | 801 // turn CALL(type, arg) into CONV(arg) w/ type |
802 n->left = N; | 802 n->left = N; |
803 n->op = OCONV; | 803 n->op = OCONV; |
804 n->type = l->type; | 804 n->type = l->type; |
805 if(onearg(n, "conversion to %T", l->type) < 0) | 805 if(onearg(n, "conversion to %T", l->type) < 0) |
806 goto error; | 806 goto error; |
807 goto doconv; | 807 goto doconv; |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2507 return n->type; | 2507 return n->type; |
2508 | 2508 |
2509 // Check for ntype cycle. | 2509 // Check for ntype cycle. |
2510 if((f2 = resolve(f2)) != N && (f1 = resolve(f2->ntype)) != N) { | 2510 if((f2 = resolve(f2)) != N && (f1 = resolve(f2->ntype)) != N) { |
2511 f2 = resolve(f1->ntype); | 2511 f2 = resolve(f1->ntype); |
2512 if(f1 == n || f2 == n) | 2512 if(f1 == n || f2 == n) |
2513 return T; | 2513 return T; |
2514 } | 2514 } |
2515 } | 2515 } |
2516 } | 2516 } |
LEFT | RIGHT |