| OLD | NEW |
| 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> implements TypeRefVisitor<T> { | 7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> { |
| 8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
| 9 | 9 |
| 10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 class Super extends Expression { | 1139 class Super extends Expression { |
| 1140 accept(NodeVisitor visitor) => visitor.visitSuper(this); | 1140 accept(NodeVisitor visitor) => visitor.visitSuper(this); |
| 1141 Super _clone() => new Super(); | 1141 Super _clone() => new Super(); |
| 1142 int get precedenceLevel => PRIMARY; | 1142 int get precedenceLevel => PRIMARY; |
| 1143 void visitChildren(NodeVisitor visitor) {} | 1143 void visitChildren(NodeVisitor visitor) {} |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 class NamedFunction extends Expression { | 1146 class NamedFunction extends Expression { |
| 1147 final Identifier name; | 1147 final Identifier name; |
| 1148 final Fun function; | 1148 final Fun function; |
| 1149 // A heuristic to force extra parens around this function. V8 and other |
| 1150 // engines use this IIFE (immediately invoked function expression) heuristic |
| 1151 // to eagerly parse a function. |
| 1152 final bool immediatelyInvoked; |
| 1149 | 1153 |
| 1150 NamedFunction(this.name, this.function); | 1154 NamedFunction(this.name, this.function, [this.immediatelyInvoked = false]); |
| 1151 | 1155 |
| 1152 accept(NodeVisitor visitor) => visitor.visitNamedFunction(this); | 1156 accept(NodeVisitor visitor) => visitor.visitNamedFunction(this); |
| 1153 | 1157 |
| 1154 void visitChildren(NodeVisitor visitor) { | 1158 void visitChildren(NodeVisitor visitor) { |
| 1155 name.accept(visitor); | 1159 name.accept(visitor); |
| 1156 function.accept(visitor); | 1160 function.accept(visitor); |
| 1157 } | 1161 } |
| 1158 NamedFunction _clone() => new NamedFunction(name, function); | 1162 NamedFunction _clone() => new NamedFunction(name, function, immediatelyInvoked
); |
| 1159 | 1163 |
| 1160 int get precedenceLevel => PRIMARY_LOW_PRECEDENCE; | 1164 int get precedenceLevel => immediatelyInvoked ? EXPRESSION : PRIMARY_LOW_PRECE
DENCE; |
| 1161 } | 1165 } |
| 1162 | 1166 |
| 1163 abstract class FunctionExpression extends Expression { | 1167 abstract class FunctionExpression extends Expression { |
| 1164 List<Parameter> get params; | 1168 List<Parameter> get params; |
| 1165 | 1169 |
| 1166 get body; // Expression or block | 1170 get body; // Expression or block |
| 1167 /// Type parameters passed to this generic function, if any. `null` otherwise. | 1171 /// Type parameters passed to this generic function, if any. `null` otherwise. |
| 1168 // TODO(ochafik): Support type bounds. | 1172 // TODO(ochafik): Support type bounds. |
| 1169 List<Identifier> get typeParams; | 1173 List<Identifier> get typeParams; |
| 1170 /// Return type of this function, if any. `null` otherwise. | 1174 /// Return type of this function, if any. `null` otherwise. |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 | 1870 |
| 1867 final List<ModuleItem> body; | 1871 final List<ModuleItem> body; |
| 1868 Module(this.body, {this.name}); | 1872 Module(this.body, {this.name}); |
| 1869 | 1873 |
| 1870 accept(NodeVisitor visitor) => visitor.visitModule(this); | 1874 accept(NodeVisitor visitor) => visitor.visitModule(this); |
| 1871 void visitChildren(NodeVisitor visitor) { | 1875 void visitChildren(NodeVisitor visitor) { |
| 1872 for (ModuleItem item in body) item.accept(visitor); | 1876 for (ModuleItem item in body) item.accept(visitor); |
| 1873 } | 1877 } |
| 1874 Module _clone() => new Module(body); | 1878 Module _clone() => new Module(body); |
| 1875 } | 1879 } |
| OLD | NEW |