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

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

Issue 112570044: code review 112570044: cmd/gc, runtime: treat slices and strings like pointers... (Closed)
Left Patch Set: Created 10 years, 8 months ago
Right Patch Set: diff -r 6d5c17d94e9ddcd8ca450ac62f84cf9ddb436b65 https://code.google.com/p/go/ Created 10 years, 7 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/gc/typecheck.c ('k') | src/pkg/reflect/all_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(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 #include <u.h> 5 #include <u.h>
6 #include <libc.h> 6 #include <libc.h>
7 #include "go.h" 7 #include "go.h"
8 #include "../ld/textflag.h" 8 #include "../ld/textflag.h"
9 9
10 static Node* walkprint(Node*, NodeList**, int); 10 static Node* walkprint(Node*, NodeList**, int);
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 if(isconst(lb, CTINT)) { 2868 if(isconst(lb, CTINT)) {
2869 lbv = mpgetfix(lb->val.u.xval); 2869 lbv = mpgetfix(lb->val.u.xval);
2870 if(lbv < 0 || lbv > bv) { 2870 if(lbv < 0 || lbv > bv) {
2871 yyerror("slice index out of bounds"); 2871 yyerror("slice index out of bounds");
2872 lbv = -1; 2872 lbv = -1;
2873 } 2873 }
2874 if(lbv == 0) 2874 if(lbv == 0)
2875 lb = N; 2875 lb = N;
2876 } 2876 }
2877 2877
2878 » // dynamic checks convert all bounds to unsigned to save us the bound < 0 comparison 2878 » // Checking src[lb:hb:cb] or src[lb:hb].
2879 » // generate 2879 » // if chk0 || chk1 || chk2 { panicslice() }
2880 » // if hb > bound || lb > hb { panicslice() }
2881 chk = N; 2880 chk = N;
2882 » chk0 = N; 2881 » chk0 = N; // cap(src) < cb
2883 » chk1 = N; 2882 » chk1 = N; // cb < hb for src[lb:hb:cb]; cap(src) < hb for src[lb:hb]
2884 » chk2 = N; 2883 » chk2 = N; // hb < lb
2885 2884
2885 » // All comparisons are unsigned to avoid testing < 0.
2886 bt = types[simtype[TUINT]]; 2886 bt = types[simtype[TUINT]];
2887 if(cb != N && cb->type->width > 4) 2887 if(cb != N && cb->type->width > 4)
2888 bt = types[TUINT64]; 2888 bt = types[TUINT64];
2889 if(hb != N && hb->type->width > 4) 2889 if(hb != N && hb->type->width > 4)
2890 bt = types[TUINT64]; 2890 bt = types[TUINT64];
2891 if(lb != N && lb->type->width > 4) 2891 if(lb != N && lb->type->width > 4)
2892 bt = types[TUINT64]; 2892 bt = types[TUINT64];
2893 2893
2894 bound = cheapexpr(conv(bound, bt), init); 2894 bound = cheapexpr(conv(bound, bt), init);
2895 2895
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
3744 !candiscardlist(n->ninit) || 3744 !candiscardlist(n->ninit) ||
3745 !candiscardlist(n->nbody) || 3745 !candiscardlist(n->nbody) ||
3746 !candiscardlist(n->nelse) || 3746 !candiscardlist(n->nelse) ||
3747 !candiscardlist(n->list) || 3747 !candiscardlist(n->list) ||
3748 !candiscardlist(n->rlist)) { 3748 !candiscardlist(n->rlist)) {
3749 return 0; 3749 return 0;
3750 } 3750 }
3751 ········ 3751 ········
3752 return 1; 3752 return 1;
3753 } 3753 }
LEFTRIGHT

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