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

Side by Side Diff: lib/src/js/nodes.dart

Issue 1169473003: fixes #43, remove => workaround (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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/harmony_feature_check.js ('k') | lib/src/js/printer.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_ast; 5 part of js_ast;
6 6
7 abstract class NodeVisitor<T> { 7 abstract class NodeVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 951
952 Fun _clone() => new Fun(params, body, asyncModifier: asyncModifier); 952 Fun _clone() => new Fun(params, body, asyncModifier: asyncModifier);
953 953
954 int get precedenceLevel => CALL; 954 int get precedenceLevel => CALL;
955 } 955 }
956 956
957 class ArrowFun extends FunctionExpression { 957 class ArrowFun extends FunctionExpression {
958 final List<Identifier> params; 958 final List<Identifier> params;
959 final body; // Expression or Block 959 final body; // Expression or Block
960 960
961 bool _bindThisWorkaround; // lazy initialized
962
963 ArrowFun(this.params, this.body); 961 ArrowFun(this.params, this.body);
964 962
965 accept(NodeVisitor visitor) => visitor.visitArrowFun(this); 963 accept(NodeVisitor visitor) => visitor.visitArrowFun(this);
966 964
967 void visitChildren(NodeVisitor visitor) { 965 void visitChildren(NodeVisitor visitor) {
968 for (Identifier param in params) param.accept(visitor); 966 for (Identifier param in params) param.accept(visitor);
969 body.accept(visitor); 967 body.accept(visitor);
970 } 968 }
971 969
972 ArrowFun _clone() => new ArrowFun(params, body); 970 ArrowFun _clone() => new ArrowFun(params, body);
973 971
974 /// This is a workaround for V8 arrow function bindings being not yet
975 /// implemented. See <https://code.google.com/p/v8/issues/detail?id=2700>
976 bool get bindThisWorkaround {
977 if (_bindThisWorkaround != null) return _bindThisWorkaround;
978 var visitor = new _ThisFinder();
979 body.accept(visitor);
980 return _bindThisWorkaround = visitor.found;
981 }
982
983 /// Ensure parens always get generated if necessary. 972 /// Ensure parens always get generated if necessary.
984 // TODO(jmesserly): I'm not sure the printer is handling this correctly for 973 // TODO(jmesserly): I'm not sure the printer is handling this correctly for
985 // function() { ... } either. 974 // function() { ... } either.
986 int get precedenceLevel => bindThisWorkaround ? CALL : ASSIGNMENT; 975 int get precedenceLevel => ASSIGNMENT;
987 }
988
989 class _ThisFinder extends BaseVisitor {
990 bool found = false;
991 visitThis(This node) {
992 found = true;
993 }
994 visitNode(Node node) {
995 if (!found) super.visitNode(node);
996 }
997 } 976 }
998 977
999 class AsyncModifier { 978 class AsyncModifier {
1000 final bool isAsync; 979 final bool isAsync;
1001 final bool isYielding; 980 final bool isYielding;
1002 final String description; 981 final String description;
1003 982
1004 const AsyncModifier.sync() 983 const AsyncModifier.sync()
1005 : isAsync = false, 984 : isAsync = false,
1006 isYielding = false, 985 isYielding = false,
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 final Expression expression; 1428 final Expression expression;
1450 1429
1451 CommentExpression(this.comment, this.expression); 1430 CommentExpression(this.comment, this.expression);
1452 1431
1453 int get precedenceLevel => PRIMARY; 1432 int get precedenceLevel => PRIMARY;
1454 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); 1433 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this);
1455 CommentExpression _clone() => new CommentExpression(comment, expression); 1434 CommentExpression _clone() => new CommentExpression(comment, expression);
1456 1435
1457 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); 1436 void visitChildren(NodeVisitor visitor) => expression.accept(visitor);
1458 } 1437 }
OLDNEW
« no previous file with comments | « lib/runtime/harmony_feature_check.js ('k') | lib/src/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698