Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: frog/member.dart

Issue 9129023: adds array bounds checking (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/lib/corelib_impl.dart ('k') | frog/minfrog » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** A formal parameter to a [Method]. */ 5 /** A formal parameter to a [Method]. */
6 class Parameter { 6 class Parameter {
7 FormalNode definition; 7 FormalNode definition;
8 Member method; 8 Member method;
9 9
10 String name; 10 String name;
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 return new Value(inferredResult, code, node.span); 1131 return new Value(inferredResult, code, node.span);
1132 } 1132 }
1133 } else if (target.type.isString) { 1133 } else if (target.type.isString) {
1134 if (name == ':index' && args.values[0].type.isNum) { 1134 if (name == ':index' && args.values[0].type.isNum) {
1135 return new Value(declaringType, '${target.code}[${argsCode[0]}]', 1135 return new Value(declaringType, '${target.code}[${argsCode[0]}]',
1136 node.span); 1136 node.span);
1137 } else if (name == ':add' && args.values[0].type.isNum) { 1137 } else if (name == ':add' && args.values[0].type.isNum) {
1138 return new Value(declaringType, '${target.code} + ${argsCode[0]}', 1138 return new Value(declaringType, '${target.code} + ${argsCode[0]}',
1139 node.span); 1139 node.span);
1140 } 1140 }
1141 } else if (declaringType.isNative) { 1141 } else if (declaringType.isNative && options.disableBoundsChecks) {
1142 if (args.length > 0 && args.values[0].type.isNum) { 1142 if (args.length > 0 && args.values[0].type.isNum) {
1143 // TODO(jimhug): make more accurate/reliable
1144 if (name == ':index') { 1143 if (name == ':index') {
1145 return 1144 return new Value(returnType,
1146 new Value(returnType, '${target.code}[${argsCode[0]}]', node.span) ; 1145 '${target.code}[${argsCode[0]}]', node.span);
1147 } else if (name == ':setindex') { 1146 } else if (name == ':setindex') {
1148 return new Value(returnType, 1147 return new Value(returnType,
1149 '${target.code}[${argsCode[0]}] = ${argsCode[1]}', node.span); 1148 '${target.code}[${argsCode[0]}] = ${argsCode[1]}', node.span);
1150 } 1149 }
1151 } 1150 }
1152 } 1151 }
1153 1152
1154 // TODO(jimhug): Optimize null on lhs as well. 1153 // TODO(jimhug): Optimize null on lhs as well.
1155 if (name == ':eq' || name == ':ne') { 1154 if (name == ':eq' || name == ':ne') {
1156 final op = name == ':eq' ? '==' : '!='; 1155 final op = name == ':eq' ? '==' : '!=';
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 } 1355 }
1357 1356
1358 void forEach(void f(Member member)) { 1357 void forEach(void f(Member member)) {
1359 factories.forEach((_, Map constructors) { 1358 factories.forEach((_, Map constructors) {
1360 constructors.forEach((_, Member member) { 1359 constructors.forEach((_, Member member) {
1361 f(member); 1360 f(member);
1362 }); 1361 });
1363 }); 1362 });
1364 } 1363 }
1365 } 1364 }
OLDNEW
« no previous file with comments | « frog/lib/corelib_impl.dart ('k') | frog/minfrog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698