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

Side by Side Diff: gen.dart

Issue 8399010: Fixed compiler so that it passes Switch1NegativeTest.dart. (Closed) Base URL: http://dart.googlecode.com/svn/experimental/frog/
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
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 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 var test = visitValue(node.test); 1333 var test = visitValue(node.test);
1334 writer.enterBlock('switch (${test.code}) {'); 1334 writer.enterBlock('switch (${test.code}) {');
1335 for (var case_ in node.cases) { 1335 for (var case_ in node.cases) {
1336 if (case_.label != null) { 1336 if (case_.label != null) {
1337 world.error('unimplemented: labeled case statement', case_.span); 1337 world.error('unimplemented: labeled case statement', case_.span);
1338 } 1338 }
1339 _pushBlock(); 1339 _pushBlock();
1340 for (int i=0; i < case_.cases.length; i++) { 1340 for (int i=0; i < case_.cases.length; i++) {
1341 var expr = case_.cases[i]; 1341 var expr = case_.cases[i];
1342 if (expr == null) { 1342 if (expr == null) {
1343 // Default can only be the last case.
1344 if (i < case_.cases.length - 1) {
1345 world.error('default clause must be the last case', case_.span);
1346 }
1343 writer.writeln('default:'); 1347 writer.writeln('default:');
1344 } else { 1348 } else {
1345 var value = visitValue(expr); 1349 var value = visitValue(expr);
1346 writer.writeln('case ${value.code}:'); 1350 writer.writeln('case ${value.code}:');
1347 } 1351 }
1348 } 1352 }
1349 writer.enterBlock(''); 1353 writer.enterBlock('');
1350 for (var stmt in case_.statements) { 1354 for (var stmt in case_.statements) {
1351 stmt.visit(this); 1355 stmt.visit(this);
jimhug 2011/10/27 17:45:11 This needs to do some sort of minimal checking for
Emily Fortuna 2011/10/27 17:59:04 Done in the next CL.
1352 } 1356 }
1357 if (case_ != node.cases[node.cases.length - 1]) {
1358 var span = case_.statements[case_.statements.length - 1].span;
1359 //TODO(efortuna): This error message isn't 100% correct because
1360 // constructors are not being built correctly. Check back when I've
1361 // fixed constructors.
1362 writer.writeln('\$throw(new FallThroughError("${span.file.filename}",' +
1363 ' ${span.file.getLine(span.start)}))');
1364 }
1353 writer.exitBlock(''); 1365 writer.exitBlock('');
1354 _popBlock(); 1366 _popBlock();
1355 } 1367 }
1356 writer.exitBlock('}'); 1368 writer.exitBlock('}');
1357 } 1369 }
1358 1370
1359 void visitBlockStatement(BlockStatement node) { 1371 void visitBlockStatement(BlockStatement node) {
1360 _pushBlock(); 1372 _pushBlock();
1361 writer.enterBlock('{'); 1373 writer.enterBlock('{');
1362 for (var stmt in node.body) { 1374 for (var stmt in node.body) {
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 2147
2136 static removeTrailingNulls(List<Value> argsCode) { 2148 static removeTrailingNulls(List<Value> argsCode) {
2137 // We simplify calls with null defaults by relying on JS and our 2149 // We simplify calls with null defaults by relying on JS and our
2138 // choice to make undefined === null for Dart generated code. This helps 2150 // choice to make undefined === null for Dart generated code. This helps
2139 // and ensures correct defaults values for native calls. 2151 // and ensures correct defaults values for native calls.
2140 while (argsCode.length > 0 && argsCode.last() == 'null') { 2152 while (argsCode.length > 0 && argsCode.last() == 'null') {
2141 argsCode.removeLast(); 2153 argsCode.removeLast();
2142 } 2154 }
2143 } 2155 }
2144 } 2156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698