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

Side by Side Diff: frog/gen.dart

Issue 8587021: fix initialization of null in loops (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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/frogsh ('k') | tests/language/language.status » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Top level generator object for writing code and keeping track of 6 * Top level generator object for writing code and keeping track of
7 * dependencies. 7 * dependencies.
8 * 8 *
9 * Should have two compilation models, but only one implemented so far. 9 * Should have two compilation models, but only one implemented so far.
10 * 10 *
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 world.error('no value specified for final variable', node.span); 1080 world.error('no value specified for final variable', node.span);
1081 } else { 1081 } else {
1082 // TODO(jimhug): Mark inferred types as special for correct errors. 1082 // TODO(jimhug): Mark inferred types as special for correct errors.
1083 if (thisType.isVar) thisType = value.type; 1083 if (thisType.isVar) thisType = value.type;
1084 } 1084 }
1085 } 1085 }
1086 1086
1087 var val = _scope.create(name, thisType, node.names[i].span); 1087 var val = _scope.create(name, thisType, node.names[i].span);
1088 1088
1089 if (value == null) { 1089 if (value == null) {
1090 writer.write('${val.code}'); 1090 if (_scope.reentrant) {
1091 // To preserve block scoping, we need to ensure the variable is
1092 // reinitialized each time the block is entered.
1093 writer.write('${val.code} = null');
1094 } else {
1095 writer.write('${val.code}');
1096 }
1091 } else { 1097 } else {
1092 value = value.convertTo(this, type, node.values[i]); 1098 value = value.convertTo(this, type, node.values[i]);
1093 writer.write('${val.code} = ${value.code}'); 1099 writer.write('${val.code} = ${value.code}');
1094 } 1100 }
1095 } 1101 }
1096 writer.writeln(';'); 1102 writer.writeln(';');
1097 return false; 1103 return false;
1098 1104
1099 } 1105 }
1100 1106
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); 2252 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false));
2247 } 2253 }
2248 for (int i = bareCount; i < length; i++) { 2254 for (int i = bareCount; i < length; i++) {
2249 var name = getName(i); 2255 var name = getName(i);
2250 if (name == null) name = '\$$i'; 2256 if (name == null) name = '\$$i';
2251 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); 2257 result.add(new Value(world.varType, name, null, /*needsTemp:*/false));
2252 } 2258 }
2253 return new Arguments(nodes, result); 2259 return new Arguments(nodes, result);
2254 } 2260 }
2255 } 2261 }
OLDNEW
« no previous file with comments | « frog/frogsh ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698