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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1233553005: Fixes #254 - Better stacktrace support (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.js_codegen; 5 library dev_compiler.src.codegen.js_codegen;
6 6
7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
(...skipping 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 notNull(node.condition), 2315 notNull(node.condition),
2316 _visit(node.thenExpression), 2316 _visit(node.thenExpression),
2317 _visit(node.elseExpression) 2317 _visit(node.elseExpression)
2318 ]); 2318 ]);
2319 } 2319 }
2320 2320
2321 @override 2321 @override
2322 visitThrowExpression(ThrowExpression node) { 2322 visitThrowExpression(ThrowExpression node) {
2323 var expr = _visit(node.expression); 2323 var expr = _visit(node.expression);
2324 if (node.parent is ExpressionStatement) { 2324 if (node.parent is ExpressionStatement) {
2325 return js.statement('throw #;', expr); 2325 return js.statement('dart.throw_(#);', expr);
Jennifer Messerly 2015/07/13 16:39:17 commented on the bug, but I have some concerns ove
vsm 2015/07/14 13:54:48 Done in the case of Error - Exception is only an i
2326 } else { 2326 } else {
2327 return js.call('dart.throw_(#)', expr); 2327 return js.call('dart.throw_(#)', expr);
2328 } 2328 }
2329 } 2329 }
2330 2330
2331 @override 2331 @override
2332 visitRethrowExpression(RethrowExpression node) { 2332 visitRethrowExpression(RethrowExpression node) {
2333 if (node.parent is ExpressionStatement) { 2333 if (node.parent is ExpressionStatement) {
2334 return js.statement('throw #;', _visit(_catchParameter)); 2334 return js.statement('dart.rethrow(#);', _visit(_catchParameter));
2335 } else { 2335 } else {
2336 return js.call('dart.throw_(#)', _visit(_catchParameter)); 2336 return js.call('dart.rethrow(#)', _visit(_catchParameter));
2337 } 2337 }
2338 } 2338 }
2339 2339
2340 @override 2340 @override
2341 JS.If visitIfStatement(IfStatement node) { 2341 JS.If visitIfStatement(IfStatement node) {
2342 return new JS.If(notNull(node.condition), _visit(node.thenStatement), 2342 return new JS.If(notNull(node.condition), _visit(node.thenStatement),
2343 _visit(node.elseStatement)); 2343 _visit(node.elseStatement));
2344 } 2344 }
2345 2345
2346 @override 2346 @override
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 // This could incorrectly shadow a user's name. 2396 // This could incorrectly shadow a user's name.
2397 var savedCatch = _catchParameter; 2397 var savedCatch = _catchParameter;
2398 2398
2399 if (clauses.length == 1 && clauses.single.exceptionParameter != null) { 2399 if (clauses.length == 1 && clauses.single.exceptionParameter != null) {
2400 // Special case for a single catch. 2400 // Special case for a single catch.
2401 _catchParameter = clauses.single.exceptionParameter; 2401 _catchParameter = clauses.single.exceptionParameter;
2402 } else { 2402 } else {
2403 _catchParameter = _createTemporary('e', types.dynamicType); 2403 _catchParameter = _createTemporary('e', types.dynamicType);
2404 } 2404 }
2405 2405
2406 JS.Statement catchBody = js.statement('throw #;', _visit(_catchParameter)); 2406 JS.Statement catchBody = js.statement('dart.rethrow(#);', _visit(_catchParam eter));
2407 for (var clause in clauses.reversed) { 2407 for (var clause in clauses.reversed) {
2408 catchBody = _catchClauseGuard(clause, catchBody); 2408 catchBody = _catchClauseGuard(clause, catchBody);
2409 } 2409 }
2410 2410
2411 var catchVarDecl = _visit(_catchParameter); 2411 var catchVarDecl = _visit(_catchParameter);
2412 _catchParameter = savedCatch; 2412 _catchParameter = savedCatch;
2413 return new JS.Catch(catchVarDecl, new JS.Block([catchBody])); 2413 return new JS.Catch(catchVarDecl, new JS.Block([catchBody]));
2414 } 2414 }
2415 2415
2416 JS.Statement _catchClauseGuard(CatchClause clause, JS.Statement otherwise) { 2416 JS.Statement _catchClauseGuard(CatchClause clause, JS.Statement otherwise) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 2823
2824 class _JsThisFinder extends JS.BaseVisitor { 2824 class _JsThisFinder extends JS.BaseVisitor {
2825 bool found = false; 2825 bool found = false;
2826 visitThis(JS.This node) { 2826 visitThis(JS.This node) {
2827 found = true; 2827 found = true;
2828 } 2828 }
2829 visitNode(JS.Node node) { 2829 visitNode(JS.Node node) {
2830 if (!found) super.visitNode(node); 2830 if (!found) super.visitNode(node);
2831 } 2831 }
2832 } 2832 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698