Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(205)

Delta Between Two Patch Sets: src/cmd/gc/typecheck.c

Issue 5316043: code review 5316043: gc: clean up printing. (Closed)
Left Patch Set: diff -r 5a6c90d25d31 https://go.googlecode.com/hg/ Created 13 years, 5 months ago
Right Patch Set: diff -r 01516e31b4f0 https://go.googlecode.com/hg/ Created 13 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/gc/subr.c ('k') | src/cmd/gc/unsafe.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1693
1694 if(nl != nil && nl->next == nil && (n = nl->n)->type != T) 1694 if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
1695 if(n->type->etype == TSTRUCT && n->type->funarg) { 1695 if(n->type->etype == TSTRUCT && n->type->funarg) {
1696 tn = n->type->type; 1696 tn = n->type->type;
1697 for(tl=tstruct->type; tl; tl=tl->down) { 1697 for(tl=tstruct->type; tl; tl=tl->down) {
1698 if(tl->isddd) { 1698 if(tl->isddd) {
1699 for(; tn; tn=tn->down) { 1699 for(; tn; tn=tn->down) {
1700 exportassignok(tn->type, desc); 1700 exportassignok(tn->type, desc);
1701 if(assignop(tn->type, tl->type->type, &w hy) == 0) { 1701 if(assignop(tn->type, tl->type->type, &w hy) == 0) {
1702 if(call != N) 1702 if(call != N)
1703 » » » » » » » yyerror("cannot use %T a s type %T in argument to %N%s", tn->type, tl->type->type, call, why); 1703 » » » » » » » yyerror("cannot use %T a s type %T in argument to %N%s", tn->type, tl->type, call, why);
1704 else 1704 else
1705 » » » » » » » yyerror("cannot use %T a s type %T in %s%s", tn->type, tl->type->type, desc, why); 1705 » » » » » » » yyerror("cannot use %T a s type %T in %s%s", tn->type, tl->type, desc, why);
1706 } 1706 }
1707 } 1707 }
1708 goto out; 1708 goto out;
1709 } 1709 }
1710 if(tn == T) 1710 if(tn == T)
1711 goto notenough; 1711 goto notenough;
1712 exportassignok(tn->type, desc); 1712 exportassignok(tn->type, desc);
1713 if(assignop(tn->type, tl->type, &why) == 0) { 1713 if(assignop(tn->type, tl->type, &why) == 0) {
1714 if(call != N) 1714 if(call != N)
1715 yyerror("cannot use %T as type %T in arg ument to %N%s", tn->type, tl->type, call, why); 1715 yyerror("cannot use %T as type %T in arg ument to %N%s", tn->type, tl->type, call, why);
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 s = n->left->val.u.sval; 2462 s = n->left->val.u.sval;
2463 l = nil; 2463 l = nil;
2464 p = s->s; 2464 p = s->s;
2465 ep = s->s + s->len; 2465 ep = s->s + s->len;
2466 i = 0; 2466 i = 0;
2467 if(n->type->type->etype == TUINT8) { 2467 if(n->type->type->etype == TUINT8) {
2468 // raw []byte 2468 // raw []byte
2469 while(p < ep) 2469 while(p < ep)
2470 l = list(l, nod(OKEY, nodintconst(i++), nodintconst((uch ar)*p++))); 2470 l = list(l, nod(OKEY, nodintconst(i++), nodintconst((uch ar)*p++)));
2471 } else { 2471 } else {
2472 » » // utf-8 []int 2472 » » // utf-8 []rune
2473 while(p < ep) { 2473 while(p < ep) {
2474 p += chartorune(&r, p); 2474 p += chartorune(&r, p);
2475 l = list(l, nod(OKEY, nodintconst(i++), nodintconst(r))) ; 2475 l = list(l, nod(OKEY, nodintconst(i++), nodintconst(r))) ;
2476 } 2476 }
2477 } 2477 }
2478 nn = nod(OCOMPLIT, N, typenod(n->type)); 2478 nn = nod(OCOMPLIT, N, typenod(n->type));
2479 nn->list = l; 2479 nn->list = l;
2480 typecheck(&nn, Erv); 2480 typecheck(&nn, Erv);
2481 *np = nn; 2481 *np = nn;
2482 } 2482 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 ret: 2791 ret:
2792 if(typecheckdefstack->n != n) 2792 if(typecheckdefstack->n != n)
2793 fatal("typecheckdefstack mismatch"); 2793 fatal("typecheckdefstack mismatch");
2794 l = typecheckdefstack; 2794 l = typecheckdefstack;
2795 typecheckdefstack = l->next; 2795 typecheckdefstack = l->next;
2796 2796
2797 lineno = lno; 2797 lineno = lno;
2798 n->walkdef = 1; 2798 n->walkdef = 1;
2799 return n; 2799 return n;
2800 } 2800 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b