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

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

Issue 1341963003: qualify core types: Object, Error, Symbol (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
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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 984
985 static bool foundIn(Node node) { 985 static bool foundIn(Node node) {
986 _thisFinder.found = false; 986 _thisFinder.found = false;
987 node.accept(_thisFinder); 987 node.accept(_thisFinder);
988 return _thisFinder.found; 988 return _thisFinder.found;
989 } 989 }
990 } 990 }
991 991
992 final _thisFinder = new _ThisFinder(); 992 final _thisFinder = new _ThisFinder();
993 class _ThisFinder extends BaseVisitor { 993 class _ThisFinder extends BaseVisitor {
994 int nested = 0;
994 bool found = false; 995 bool found = false;
995 visitThis(This node) { 996 visitThis(This node) {
996 found = true; 997 if (nested <= 1) found = true;
998 }
999 visitFunctionExpression(FunctionExpression node) {
ochafik 2015/09/15 18:05:17 Does FunctionExpression include arrow functions? (
1000 for (var param in node.params) {
1001 param.accept(this);
1002 }
1003 ++nested;
1004 node.body.accept(this);
1005 --nested;
997 } 1006 }
998 visitNode(Node node) { 1007 visitNode(Node node) {
999 if (!found) super.visitNode(node); 1008 if (!found) super.visitNode(node);
1000 } 1009 }
1001 } 1010 }
1002 1011
1003 1012
1004 // `super` is more restricted in the ES6 spec, but for simplicity we accept 1013 // `super` is more restricted in the ES6 spec, but for simplicity we accept
1005 // it anywhere that `this` is accepted. 1014 // it anywhere that `this` is accepted.
1006 class Super extends Expression { 1015 class Super extends Expression {
(...skipping 16 matching lines...) Expand all
1023 function.accept(visitor); 1032 function.accept(visitor);
1024 } 1033 }
1025 NamedFunction _clone() => new NamedFunction(name, function); 1034 NamedFunction _clone() => new NamedFunction(name, function);
1026 1035
1027 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE; 1036 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE;
1028 } 1037 }
1029 1038
1030 abstract class FunctionExpression extends Expression { 1039 abstract class FunctionExpression extends Expression {
1031 List<Parameter> get params; 1040 List<Parameter> get params;
1032 get body; // Expression or block 1041 get body; // Expression or block
1042
1043 void visitChildren(NodeVisitor visitor) {
1044 for (Parameter param in params) param.accept(visitor);
1045 body.accept(visitor);
1046 }
1033 } 1047 }
1034 1048
1035 class Fun extends FunctionExpression { 1049 class Fun extends FunctionExpression {
1036 final List<Parameter> params; 1050 final List<Parameter> params;
1037 final Block body; 1051 final Block body;
1038 /** Whether this is a JS generator (`function*`) that may contain `yield`. */ 1052 /** Whether this is a JS generator (`function*`) that may contain `yield`. */
1039 final bool isGenerator; 1053 final bool isGenerator;
1040 1054
1041 final AsyncModifier asyncModifier; 1055 final AsyncModifier asyncModifier;
1042 1056
1043 Fun(this.params, this.body, {this.isGenerator: false, 1057 Fun(this.params, this.body, {this.isGenerator: false,
1044 this.asyncModifier: const AsyncModifier.sync()}); 1058 this.asyncModifier: const AsyncModifier.sync()});
1045 1059
1046 accept(NodeVisitor visitor) => visitor.visitFun(this); 1060 accept(NodeVisitor visitor) => visitor.visitFun(this);
1047 1061
1048 void visitChildren(NodeVisitor visitor) {
1049 for (Parameter param in params) param.accept(visitor);
1050 body.accept(visitor);
1051 }
1052
1053 Fun _clone() => new Fun(params, body, 1062 Fun _clone() => new Fun(params, body,
1054 isGenerator: isGenerator, asyncModifier: asyncModifier); 1063 isGenerator: isGenerator, asyncModifier: asyncModifier);
1055 1064
1056 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE; 1065 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE;
1057 } 1066 }
1058 1067
1059 class ArrowFun extends FunctionExpression { 1068 class ArrowFun extends FunctionExpression {
1060 final List<Parameter> params; 1069 final List<Parameter> params;
1061 final body; // Expression or Block 1070 final body; // Expression or Block
1062 1071
1063 bool _closesOverThis; // lazy initialized 1072 bool _closesOverThis; // lazy initialized
1064 1073
1065 ArrowFun(this.params, this.body); 1074 ArrowFun(this.params, this.body);
1066 1075
1067 accept(NodeVisitor visitor) => visitor.visitArrowFun(this); 1076 accept(NodeVisitor visitor) => visitor.visitArrowFun(this);
1068 1077
1069 void visitChildren(NodeVisitor visitor) {
1070 for (Parameter param in params) param.accept(visitor);
1071 body.accept(visitor);
1072 }
1073 /// True if this function actually closes of `this`. We use this in some 1078 /// True if this function actually closes of `this`. We use this in some
1074 /// situations to generate different code. 1079 /// situations to generate different code.
1075 bool get closesOverThis { 1080 bool get closesOverThis {
1076 if (_closesOverThis == null) _closesOverThis = This.foundIn(this); 1081 if (_closesOverThis == null) _closesOverThis = This.foundIn(this);
1077 return _closesOverThis; 1082 return _closesOverThis;
1078 } 1083 }
1079 1084
1080 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE; 1085 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE;
1081 1086
1082 ArrowFun _clone() => new ArrowFun(params, body); 1087 ArrowFun _clone() => new ArrowFun(params, body);
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 final Expression expression; 1572 final Expression expression;
1568 1573
1569 CommentExpression(this.comment, this.expression); 1574 CommentExpression(this.comment, this.expression);
1570 1575
1571 int get precedenceLevel => PRIMARY; 1576 int get precedenceLevel => PRIMARY;
1572 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); 1577 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this);
1573 CommentExpression _clone() => new CommentExpression(comment, expression); 1578 CommentExpression _clone() => new CommentExpression(comment, expression);
1574 1579
1575 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); 1580 void visitChildren(NodeVisitor visitor) => expression.accept(visitor);
1576 } 1581 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698