| 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 library closureToClassMapper; | 5 library closureToClassMapper; |
| 6 | 6 |
| 7 import "elements/elements.dart"; | 7 import "elements/elements.dart"; |
| 8 import "dart2jslib.dart"; | 8 import "dart2jslib.dart"; |
| 9 import "dart_types.dart"; | 9 import "dart_types.dart"; |
| 10 import "js_backend/js_backend.dart" show JavaScriptBackend; | 10 import "js_backend/js_backend.dart" show JavaScriptBackend; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DartType get type { | 136 DartType get type { |
| 137 if (local is LocalElement) { | 137 if (local is LocalElement) { |
| 138 LocalElement element = local; | 138 LocalElement element = local; |
| 139 return element.type; | 139 return element.type; |
| 140 } | 140 } |
| 141 return const DynamicType(); | 141 return const DynamicType(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 String toString() => "ClosureFieldElement($name)"; | 144 String toString() => "ClosureFieldElement($name)"; |
| 145 | 145 |
| 146 accept(ElementVisitor visitor) => visitor.visitClosureFieldElement(this); | 146 accept(ElementVisitor visitor, arg) { |
| 147 return visitor.visitClosureFieldElement(this, arg); |
| 148 } |
| 147 | 149 |
| 148 Element get analyzableElement => closureClass.methodElement.analyzableElement; | 150 Element get analyzableElement => closureClass.methodElement.analyzableElement; |
| 149 | 151 |
| 150 @override | 152 @override |
| 151 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; | 153 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; |
| 152 } | 154 } |
| 153 | 155 |
| 154 // TODO(ahe): These classes continuously cause problems. We need to find | 156 // TODO(ahe): These classes continuously cause problems. We need to find |
| 155 // a more general solution. | 157 // a more general solution. |
| 156 class ClosureClassElement extends ClassElementX { | 158 class ClosureClassElement extends ClassElementX { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 209 |
| 208 Node parseNode(DiagnosticListener listener) => node; | 210 Node parseNode(DiagnosticListener listener) => node; |
| 209 | 211 |
| 210 // A [ClosureClassElement] is nested inside a function or initializer in terms | 212 // A [ClosureClassElement] is nested inside a function or initializer in terms |
| 211 // of [enclosingElement], but still has to be treated as a top-level | 213 // of [enclosingElement], but still has to be treated as a top-level |
| 212 // element. | 214 // element. |
| 213 bool get isTopLevel => true; | 215 bool get isTopLevel => true; |
| 214 | 216 |
| 215 get enclosingElement => methodElement; | 217 get enclosingElement => methodElement; |
| 216 | 218 |
| 217 accept(ElementVisitor visitor) => visitor.visitClosureClassElement(this); | 219 accept(ElementVisitor visitor, arg) { |
| 220 return visitor.visitClosureClassElement(this, arg); |
| 221 } |
| 218 } | 222 } |
| 219 | 223 |
| 220 /// A local variable that contains the box object holding the [BoxFieldElement] | 224 /// A local variable that contains the box object holding the [BoxFieldElement] |
| 221 /// fields. | 225 /// fields. |
| 222 class BoxLocal extends Local { | 226 class BoxLocal extends Local { |
| 223 final String name; | 227 final String name; |
| 224 final ExecutableElement executableContext; | 228 final ExecutableElement executableContext; |
| 225 | 229 |
| 226 BoxLocal(this.name, this.executableContext); | 230 BoxLocal(this.name, this.executableContext); |
| 227 } | 231 } |
| 228 | 232 |
| 229 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to | 233 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to |
| 230 // find a more general solution. | 234 // find a more general solution. |
| 231 class BoxFieldElement extends ElementX | 235 class BoxFieldElement extends ElementX |
| 232 implements TypedElement, CapturedVariable, FieldElement { | 236 implements TypedElement, CapturedVariable, FieldElement { |
| 233 final BoxLocal box; | 237 final BoxLocal box; |
| 234 | 238 |
| 235 BoxFieldElement(String name, this.variableElement, BoxLocal box) | 239 BoxFieldElement(String name, this.variableElement, BoxLocal box) |
| 236 : this.box = box, | 240 : this.box = box, |
| 237 super(name, ElementKind.FIELD, box.executableContext); | 241 super(name, ElementKind.FIELD, box.executableContext); |
| 238 | 242 |
| 239 DartType computeType(Compiler compiler) => type; | 243 DartType computeType(Compiler compiler) => type; |
| 240 | 244 |
| 241 DartType get type => variableElement.type; | 245 DartType get type => variableElement.type; |
| 242 | 246 |
| 243 final VariableElement variableElement; | 247 final VariableElement variableElement; |
| 244 | 248 |
| 245 accept(ElementVisitor visitor) => visitor.visitBoxFieldElement(this); | 249 accept(ElementVisitor visitor, arg) { |
| 250 return visitor.visitBoxFieldElement(this, arg); |
| 251 } |
| 246 | 252 |
| 247 @override | 253 @override |
| 248 bool get hasNode => false; | 254 bool get hasNode => false; |
| 249 | 255 |
| 250 @override | 256 @override |
| 251 bool get hasResolvedAst => false; | 257 bool get hasResolvedAst => false; |
| 252 | 258 |
| 253 @override | 259 @override |
| 254 Expression get initializer { | 260 Expression get initializer { |
| 255 throw new UnsupportedError("BoxFieldElement.initializer"); | 261 throw new UnsupportedError("BoxFieldElement.initializer"); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 | 1093 |
| 1088 String get name => typeVariable.name; | 1094 String get name => typeVariable.name; |
| 1089 | 1095 |
| 1090 int get hashCode => typeVariable.hashCode; | 1096 int get hashCode => typeVariable.hashCode; |
| 1091 | 1097 |
| 1092 bool operator ==(other) { | 1098 bool operator ==(other) { |
| 1093 if (other is! TypeVariableLocal) return false; | 1099 if (other is! TypeVariableLocal) return false; |
| 1094 return typeVariable == other.typeVariable; | 1100 return typeVariable == other.typeVariable; |
| 1095 } | 1101 } |
| 1096 } | 1102 } |
| OLD | NEW |