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 import 'dart:collection' show IterableMixin; | 5 import 'dart:collection' show IterableMixin; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../elements/elements.dart' show MetadataAnnotation; | 8 import '../elements/elements.dart' show MetadataAnnotation; |
9 import '../resolution/secret_tree_element.dart' | 9 import '../resolution/secret_tree_element.dart' |
10 show NullTreeElementMixin, StoredTreeElementMixin; | 10 show NullTreeElementMixin, StoredTreeElementMixin; |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 | 1069 |
1070 /// Is `true` if this modifier is either `async` or `async*`. | 1070 /// Is `true` if this modifier is either `async` or `async*`. |
1071 bool get isAsynchronous => asyncToken.value == 'async'; | 1071 bool get isAsynchronous => asyncToken.value == 'async'; |
1072 | 1072 |
1073 /// Is `true` if this modifier is either `sync*` or `async*`. | 1073 /// Is `true` if this modifier is either `sync*` or `async*`. |
1074 bool get isYielding => starToken != null; | 1074 bool get isYielding => starToken != null; |
1075 } | 1075 } |
1076 | 1076 |
1077 class FunctionExpression extends Expression with StoredTreeElementMixin { | 1077 class FunctionExpression extends Expression with StoredTreeElementMixin { |
1078 final Node name; | 1078 final Node name; |
1079 final NodeList typeVariables; | |
1080 | 1079 |
1081 /** | 1080 /** |
1082 * List of VariableDefinitions or NodeList. | 1081 * List of VariableDefinitions or NodeList. |
1083 * | 1082 * |
1084 * A NodeList can only occur at the end and holds named parameters. | 1083 * A NodeList can only occur at the end and holds named parameters. |
1085 */ | 1084 */ |
1086 final NodeList parameters; | 1085 final NodeList parameters; |
1087 | 1086 |
1088 final Statement body; | 1087 final Statement body; |
1089 final TypeAnnotation returnType; | 1088 final TypeAnnotation returnType; |
1090 final Modifiers modifiers; | 1089 final Modifiers modifiers; |
1091 final NodeList initializers; | 1090 final NodeList initializers; |
1092 | 1091 |
1093 final Token getOrSet; | 1092 final Token getOrSet; |
1094 final AsyncModifier asyncModifier; | 1093 final AsyncModifier asyncModifier; |
1095 | 1094 |
1096 FunctionExpression( | 1095 FunctionExpression(this.name, this.parameters, this.body, this.returnType, |
1097 this.name, | 1096 this.modifiers, this.initializers, this.getOrSet, this.asyncModifier) { |
1098 this.typeVariables, | |
1099 this.parameters, | |
1100 this.body, | |
1101 this.returnType, | |
1102 this.modifiers, | |
1103 this.initializers, | |
1104 this.getOrSet, | |
1105 this.asyncModifier) { | |
1106 assert(modifiers != null); | 1097 assert(modifiers != null); |
1107 } | 1098 } |
1108 | 1099 |
1109 FunctionExpression asFunctionExpression() => this; | 1100 FunctionExpression asFunctionExpression() => this; |
1110 | 1101 |
1111 accept(Visitor visitor) => visitor.visitFunctionExpression(this); | 1102 accept(Visitor visitor) => visitor.visitFunctionExpression(this); |
1112 | 1103 |
1113 accept1(Visitor1 visitor, arg) => visitor.visitFunctionExpression(this, arg); | 1104 accept1(Visitor1 visitor, arg) => visitor.visitFunctionExpression(this, arg); |
1114 | 1105 |
1115 bool get isRedirectingFactory { | 1106 bool get isRedirectingFactory { |
1116 return body != null && body.asRedirectingFactoryBody() != null; | 1107 return body != null && body.asRedirectingFactoryBody() != null; |
1117 } | 1108 } |
1118 | 1109 |
1119 visitChildren(Visitor visitor) { | 1110 visitChildren(Visitor visitor) { |
1120 if (modifiers != null) modifiers.accept(visitor); | 1111 if (modifiers != null) modifiers.accept(visitor); |
1121 if (returnType != null) returnType.accept(visitor); | 1112 if (returnType != null) returnType.accept(visitor); |
1122 if (name != null) name.accept(visitor); | 1113 if (name != null) name.accept(visitor); |
1123 if (typeVariables != null) typeVariables.accept(visitor); | |
1124 if (parameters != null) parameters.accept(visitor); | 1114 if (parameters != null) parameters.accept(visitor); |
1125 if (initializers != null) initializers.accept(visitor); | 1115 if (initializers != null) initializers.accept(visitor); |
1126 if (asyncModifier != null) asyncModifier.accept(visitor); | 1116 if (asyncModifier != null) asyncModifier.accept(visitor); |
1127 if (body != null) body.accept(visitor); | 1117 if (body != null) body.accept(visitor); |
1128 } | 1118 } |
1129 | 1119 |
1130 visitChildren1(Visitor1 visitor, arg) { | 1120 visitChildren1(Visitor1 visitor, arg) { |
1131 if (modifiers != null) modifiers.accept1(visitor, arg); | 1121 if (modifiers != null) modifiers.accept1(visitor, arg); |
1132 if (returnType != null) returnType.accept1(visitor, arg); | 1122 if (returnType != null) returnType.accept1(visitor, arg); |
1133 if (name != null) name.accept1(visitor, arg); | 1123 if (name != null) name.accept1(visitor, arg); |
1134 if (typeVariables != null) typeVariables.accept1(visitor, arg); | |
1135 if (parameters != null) parameters.accept1(visitor, arg); | 1124 if (parameters != null) parameters.accept1(visitor, arg); |
1136 if (initializers != null) initializers.accept1(visitor, arg); | 1125 if (initializers != null) initializers.accept1(visitor, arg); |
1137 if (asyncModifier != null) asyncModifier.accept1(visitor, arg); | 1126 if (asyncModifier != null) asyncModifier.accept1(visitor, arg); |
1138 if (body != null) body.accept1(visitor, arg); | 1127 if (body != null) body.accept1(visitor, arg); |
1139 } | 1128 } |
1140 | 1129 |
1141 bool get hasBody => body.asEmptyStatement() == null; | 1130 bool get hasBody => body.asEmptyStatement() == null; |
1142 | 1131 |
1143 bool get hasEmptyBody { | 1132 bool get hasEmptyBody { |
1144 Block block = body.asBlock(); | 1133 Block block = body.asBlock(); |
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 accept1(Visitor1 visitor, arg) {} | 3095 accept1(Visitor1 visitor, arg) {} |
3107 | 3096 |
3108 visitChildren(Visitor visitor) {} | 3097 visitChildren(Visitor visitor) {} |
3109 | 3098 |
3110 visitChildren1(Visitor1 visitor, arg) {} | 3099 visitChildren1(Visitor1 visitor, arg) {} |
3111 | 3100 |
3112 bool get isErroneous => true; | 3101 bool get isErroneous => true; |
3113 | 3102 |
3114 // FunctionExpression. | 3103 // FunctionExpression. |
3115 get asyncModifier => null; | 3104 get asyncModifier => null; |
3116 get typeVariables => null; | |
3117 get parameters => null; | 3105 get parameters => null; |
3118 get body => null; | 3106 get body => null; |
3119 get returnType => null; | 3107 get returnType => null; |
3120 get modifiers => Modifiers.EMPTY; | 3108 get modifiers => Modifiers.EMPTY; |
3121 get initializers => null; | 3109 get initializers => null; |
3122 get getOrSet => null; | 3110 get getOrSet => null; |
3123 get isRedirectingFactory => false; | 3111 get isRedirectingFactory => false; |
3124 bool get hasBody => false; | 3112 bool get hasBody => false; |
3125 bool get hasEmptyBody => false; | 3113 bool get hasEmptyBody => false; |
3126 | 3114 |
3127 // VariableDefinitions. | 3115 // VariableDefinitions. |
3128 get metadata => null; | 3116 get metadata => null; |
3129 get type => null; | 3117 get type => null; |
3130 | 3118 |
3131 // Typedef. | 3119 // Typedef. |
3132 get typeParameters => null; | 3120 get typeParameters => null; |
3133 get formals => null; | 3121 get formals => null; |
3134 get typedefKeyword => null; | 3122 get typedefKeyword => null; |
3135 } | 3123 } |
OLD | NEW |