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

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

Issue 1305413006: fix readability regressions from previous block-scope CL (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | lib/src/compiler.dart » ('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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 var ret = new JS.Return(_visit(node.expression)); 1760 var ret = new JS.Return(_visit(node.expression));
1761 return new JS.Block(initArgs != null ? [initArgs, ret] : [ret]); 1761 return new JS.Block(initArgs != null ? [initArgs, ret] : [ret]);
1762 } 1762 }
1763 1763
1764 @override 1764 @override
1765 JS.Block visitEmptyFunctionBody(EmptyFunctionBody node) => new JS.Block([]); 1765 JS.Block visitEmptyFunctionBody(EmptyFunctionBody node) => new JS.Block([]);
1766 1766
1767 @override 1767 @override
1768 JS.Block visitBlockFunctionBody(BlockFunctionBody node) { 1768 JS.Block visitBlockFunctionBody(BlockFunctionBody node) {
1769 var initArgs = _emitArgumentInitializers(node.parent); 1769 var initArgs = _emitArgumentInitializers(node.parent);
1770 var block = visitBlock(node.block); 1770 var stmts = _visitList(node.block.statements) as List<JS.Statement>;
1771 if (initArgs != null) return new JS.Block([initArgs, block]); 1771 if (initArgs != null) stmts.insert(0, initArgs);
1772 return block; 1772 return new JS.Block(stmts);
1773 } 1773 }
1774 1774
1775 @override 1775 @override
1776 JS.Block visitBlock(Block node) => 1776 JS.Block visitBlock(Block node) =>
1777 new JS.Block(_visitList(node.statements) as List<JS.Statement>, 1777 new JS.Block(_visitList(node.statements) as List<JS.Statement>,
1778 isScope: true); 1778 isScope: true);
1779 1779
1780 @override 1780 @override
1781 visitMethodInvocation(MethodInvocation node) { 1781 visitMethodInvocation(MethodInvocation node) {
1782 if (node.operator != null && node.operator.lexeme == '?.') { 1782 if (node.operator != null && node.operator.lexeme == '?.') {
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2925 'let # = #;', [_visit(name), _visit(_catchParameter)])); 2925 'let # = #;', [_visit(name), _visit(_catchParameter)]));
2926 _catchParameter = name; 2926 _catchParameter = name;
2927 } 2927 }
2928 if (node.stackTraceParameter != null) { 2928 if (node.stackTraceParameter != null) {
2929 var stackVar = node.stackTraceParameter.name; 2929 var stackVar = node.stackTraceParameter.name;
2930 body.add(js.statement( 2930 body.add(js.statement(
2931 'let # = dart.stackTrace(#);', [stackVar, _visit(name)])); 2931 'let # = dart.stackTrace(#);', [stackVar, _visit(name)]));
2932 } 2932 }
2933 } 2933 }
2934 2934
2935 body.add(_visit(node.body)); 2935 body.add(
2936 new JS.Block(_visitList(node.body.statements) as List<JS.Statement>));
Leaf 2015/09/09 21:29:45 Will JS be ok with this hoisting if either the exc
Jennifer Messerly 2015/09/09 21:48:39 JS wouldn't care, unless we end up desugaring (_ca
Jennifer Messerly 2015/09/09 22:02:57 confirmed that it's spec'd that way.
2936 _catchParameter = savedCatch; 2937 _catchParameter = savedCatch;
2937 return _statement(body); 2938 return _statement(body);
2938 } 2939 }
2939 2940
2940 @override 2941 @override
2941 JS.Case visitSwitchCase(SwitchCase node) { 2942 JS.Case visitSwitchCase(SwitchCase node) {
2942 var expr = _visit(node.expression); 2943 var expr = _visit(node.expression);
2943 var body = _visitList(node.statements) as List<JS.Statement>; 2944 var body = _visitList(node.statements) as List<JS.Statement>;
2944 if (node.labels.isNotEmpty) { 2945 if (node.labels.isNotEmpty) {
2945 body.insert(0, js.comment('Unimplemented case labels: ${node.labels}')); 2946 body.insert(0, js.comment('Unimplemented case labels: ${node.labels}'));
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 3309
3309 /// A special kind of element created by the compiler, signifying a temporary 3310 /// A special kind of element created by the compiler, signifying a temporary
3310 /// variable. These objects use instance equality, and should be shared 3311 /// variable. These objects use instance equality, and should be shared
3311 /// everywhere in the tree where they are treated as the same variable. 3312 /// everywhere in the tree where they are treated as the same variable.
3312 class TemporaryVariableElement extends LocalVariableElementImpl { 3313 class TemporaryVariableElement extends LocalVariableElementImpl {
3313 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 3314 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
3314 3315
3315 int get hashCode => identityHashCode(this); 3316 int get hashCode => identityHashCode(this);
3316 bool operator ==(Object other) => identical(this, other); 3317 bool operator ==(Object other) => identical(this, other);
3317 } 3318 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698