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

Side by Side Diff: frog/gen.dart

Issue 8590017: Fix "is Object" to always be true in Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: take2 after syncing 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') | frog/type.dart » ('j') | frog/value.dart » ('J')
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 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 var ex = _scope.declare(catch_.exception); 1317 var ex = _scope.declare(catch_.exception);
1318 _scope.rethrow = ex; 1318 _scope.rethrow = ex;
1319 writer.nextBlock('} catch (${ex.code}) {'); 1319 writer.nextBlock('} catch (${ex.code}) {');
1320 if (catch_.trace != null) { 1320 if (catch_.trace != null) {
1321 var trace = _scope.declare(catch_.trace); 1321 var trace = _scope.declare(catch_.trace);
1322 writer.writeln('var ${trace.code} = \$stackTraceOf(${ex.code});'); 1322 writer.writeln('var ${trace.code} = \$stackTraceOf(${ex.code});');
1323 world.gen.corejs.useStackTraceOf = true; 1323 world.gen.corejs.useStackTraceOf = true;
1324 } 1324 }
1325 _genToDartException(ex.code, node); 1325 _genToDartException(ex.code, node);
1326 1326
1327 if (!ex.type.isVar) { 1327 if (!ex.type.isVarOrObject) {
1328 var test = ex.instanceOf(this, ex.type, catch_.exception.span, 1328 var test = ex.instanceOf(this, ex.type, catch_.exception.span,
1329 isTrue:false, forceCheck:true); 1329 isTrue:false, forceCheck:true);
1330 writer.writeln('if (${test.code}) throw ${ex.code};'); 1330 writer.writeln('if (${test.code}) throw ${ex.code};');
1331 } 1331 }
1332 visitStatementsInBlock(node.catches[0].body); 1332 visitStatementsInBlock(node.catches[0].body);
1333 _popBlock(); 1333 _popBlock();
1334 } else if (node.catches.length > 0) { 1334 } else if (node.catches.length > 0) {
1335 // Handle more than one catch 1335 // Handle more than one catch
1336 _pushBlock(); 1336 _pushBlock();
1337 var ex = _scope.create('\$ex', world.varType, null); 1337 var ex = _scope.create('\$ex', world.varType, null);
1338 _scope.rethrow = ex; 1338 _scope.rethrow = ex;
1339 writer.nextBlock('} catch (${ex.code}) {'); 1339 writer.nextBlock('} catch (${ex.code}) {');
1340 var trace = null; 1340 var trace = null;
1341 if (node.catches.some((c) => c.trace != null)) { 1341 if (node.catches.some((c) => c.trace != null)) {
1342 trace = _scope.create('\$trace', world.varType, null); 1342 trace = _scope.create('\$trace', world.varType, null);
1343 writer.writeln('var ${trace.code} = \$stackTraceOf(${ex.code});'); 1343 writer.writeln('var ${trace.code} = \$stackTraceOf(${ex.code});');
1344 world.gen.corejs.useStackTraceOf = true; 1344 world.gen.corejs.useStackTraceOf = true;
1345 } 1345 }
1346 _genToDartException(ex.code, node); 1346 _genToDartException(ex.code, node);
1347 1347
1348 // We need a rethrow unless we encounter a "var" catch 1348 // We need a rethrow unless we encounter a "var" or "Object" catch
1349 bool needsRethrow = true; 1349 bool needsRethrow = true;
1350 1350
1351 for (int i = 0; i < node.catches.length; i++) { 1351 for (int i = 0; i < node.catches.length; i++) {
1352 var catch_ = node.catches[i]; 1352 var catch_ = node.catches[i];
1353 1353
1354 _pushBlock(); 1354 _pushBlock();
1355 var tmp = _scope.declare(catch_.exception); 1355 var tmp = _scope.declare(catch_.exception);
1356 if (!tmp.type.isVar) { 1356 if (!tmp.type.isVarOrObject) {
1357 var test = ex.instanceOf(this, tmp.type, catch_.exception.span, 1357 var test = ex.instanceOf(this, tmp.type, catch_.exception.span,
1358 isTrue:true, forceCheck:true); 1358 isTrue:true, forceCheck:true);
1359 if (i == 0) { 1359 if (i == 0) {
1360 writer.enterBlock('if (${test.code}) {'); 1360 writer.enterBlock('if (${test.code}) {');
1361 } else { 1361 } else {
1362 writer.nextBlock('} else if (${test.code}) {'); 1362 writer.nextBlock('} else if (${test.code}) {');
1363 } 1363 }
1364 } else if (i > 0) { 1364 } else if (i > 0) {
1365 writer.nextBlock('} else {'); 1365 writer.nextBlock('} else {');
1366 } 1366 }
1367 1367
1368 writer.writeln('var ${tmp.code} = ${ex.code};'); 1368 writer.writeln('var ${tmp.code} = ${ex.code};');
1369 if (catch_.trace != null) { 1369 if (catch_.trace != null) {
1370 // TODO(jmesserly): ensure this is the right type 1370 // TODO(jmesserly): ensure this is the right type
1371 var tmptrace = _scope.declare(catch_.trace); 1371 var tmptrace = _scope.declare(catch_.trace);
1372 writer.writeln('var ${tmptrace.code} = ${trace.code};'); 1372 writer.writeln('var ${tmptrace.code} = ${trace.code};');
1373 } 1373 }
1374 1374
1375 visitStatementsInBlock(catch_.body); 1375 visitStatementsInBlock(catch_.body);
1376 _popBlock(); 1376 _popBlock();
1377 1377
1378 if (tmp.type.isVar) { 1378 if (tmp.type.isVarOrObject) {
1379 // We matched this for sure; no need to keep going 1379 // We matched this for sure; no need to keep going
1380 if (i + 1 < node.catches.length) { 1380 if (i + 1 < node.catches.length) {
1381 world.warning('Unreachable catch clause', node.catches[i + 1]); 1381 world.warning('Unreachable catch clause', node.catches[i + 1]);
1382 } 1382 }
1383 if (i > 0) { 1383 if (i > 0) {
1384 // Close the else block 1384 // Close the else block
1385 writer.exitBlock('}'); 1385 writer.exitBlock('}');
1386 } 1386 }
1387 needsRethrow = false; 1387 needsRethrow = false;
1388 break; 1388 break;
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); 2246 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false));
2247 } 2247 }
2248 for (int i = bareCount; i < length; i++) { 2248 for (int i = bareCount; i < length; i++) {
2249 var name = getName(i); 2249 var name = getName(i);
2250 if (name == null) name = '\$$i'; 2250 if (name == null) name = '\$$i';
2251 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); 2251 result.add(new Value(world.varType, name, null, /*needsTemp:*/false));
2252 } 2252 }
2253 return new Arguments(nodes, result); 2253 return new Arguments(nodes, result);
2254 } 2254 }
2255 } 2255 }
OLDNEW
« no previous file with comments | « frog/frogsh ('k') | frog/type.dart » ('j') | frog/value.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698