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

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: format fix 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
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/BenchmarkBase.js » ('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) 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);
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('throw #;', _visit(_catchParameter));
2335 } else { 2335 } else {
2336 return js.call('dart.throw_(#)', _visit(_catchParameter)); 2336 return js.call('throw #', _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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 _visit(node.expression); 2592 _visit(node.expression);
2593 2593
2594 @override 2594 @override
2595 visitBooleanLiteral(BooleanLiteral node) => js.boolean(node.value); 2595 visitBooleanLiteral(BooleanLiteral node) => js.boolean(node.value);
2596 2596
2597 @override 2597 @override
2598 JS.Expression visitExpression(Expression node) => 2598 JS.Expression visitExpression(Expression node) =>
2599 _unimplementedCall('Unimplemented ${node.runtimeType}: $node'); 2599 _unimplementedCall('Unimplemented ${node.runtimeType}: $node');
2600 2600
2601 JS.Expression _unimplementedCall(String comment) { 2601 JS.Expression _unimplementedCall(String comment) {
2602 return js.call('dart.throw_(#)', [js.escapedString(comment)]); 2602 return js.call('dart.throw(#)', [js.escapedString(comment)]);
2603 } 2603 }
2604 2604
2605 @override 2605 @override
2606 visitNode(AstNode node) { 2606 visitNode(AstNode node) {
2607 // TODO(jmesserly): verify this is unreachable. 2607 // TODO(jmesserly): verify this is unreachable.
2608 throw 'Unimplemented ${node.runtimeType}: $node'; 2608 throw 'Unimplemented ${node.runtimeType}: $node';
2609 } 2609 }
2610 2610
2611 _visit(AstNode node) { 2611 _visit(AstNode node) {
2612 if (node == null) return null; 2612 if (node == null) return null;
(...skipping 210 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
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/BenchmarkBase.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698