| 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 'common/names.dart' show Identifiers; | 7 import 'common/names.dart' show Identifiers; |
| 8 import 'common/resolution.dart' show ParsingContext, Resolution; | 8 import 'common/resolution.dart' show ParsingContext, Resolution; |
| 9 import 'common/tasks.dart' show CompilerTask; | 9 import 'common/tasks.dart' show CompilerTask; |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| 11 import 'compiler.dart' show Compiler; | 11 import 'compiler.dart' show Compiler; |
| 12 import 'constants/expressions.dart'; | 12 import 'constants/expressions.dart'; |
| 13 import 'elements/resolution_types.dart'; | 13 import 'elements/resolution_types.dart'; |
| 14 import 'elements/elements.dart'; | 14 import 'elements/elements.dart'; |
| 15 import 'elements/entities.dart'; |
| 15 import 'elements/modelx.dart' | 16 import 'elements/modelx.dart' |
| 16 show BaseFunctionElementX, ClassElementX, ElementX; | 17 show BaseFunctionElementX, ClassElementX, ElementX; |
| 17 import 'elements/visitor.dart' show ElementVisitor; | 18 import 'elements/visitor.dart' show ElementVisitor; |
| 18 import 'js_backend/js_backend.dart' show JavaScriptBackend; | 19 import 'js_backend/js_backend.dart' show JavaScriptBackend; |
| 19 import 'resolution/tree_elements.dart' show TreeElements; | 20 import 'resolution/tree_elements.dart' show TreeElements; |
| 20 import 'tokens/token.dart' show Token; | 21 import 'tokens/token.dart' show Token; |
| 21 import 'tree/tree.dart'; | 22 import 'tree/tree.dart'; |
| 22 import 'util/util.dart'; | 23 import 'util/util.dart'; |
| 23 import 'world.dart' show ClosedWorldRefiner; | 24 import 'world.dart' show ClosedWorldRefiner; |
| 24 | 25 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 /// fields. | 280 /// fields. |
| 280 class BoxLocal extends Local { | 281 class BoxLocal extends Local { |
| 281 final String name; | 282 final String name; |
| 282 final ExecutableElement executableContext; | 283 final ExecutableElement executableContext; |
| 283 | 284 |
| 284 final int hashCode = _nextHashCode = (_nextHashCode + 10007).toUnsigned(30); | 285 final int hashCode = _nextHashCode = (_nextHashCode + 10007).toUnsigned(30); |
| 285 static int _nextHashCode = 0; | 286 static int _nextHashCode = 0; |
| 286 | 287 |
| 287 BoxLocal(this.name, this.executableContext); | 288 BoxLocal(this.name, this.executableContext); |
| 288 | 289 |
| 290 @override |
| 291 MemberElement get memberContext => executableContext.memberContext; |
| 292 |
| 289 String toString() => 'BoxLocal($name)'; | 293 String toString() => 'BoxLocal($name)'; |
| 290 } | 294 } |
| 291 | 295 |
| 292 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to | 296 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to |
| 293 // find a more general solution. | 297 // find a more general solution. |
| 294 class BoxFieldElement extends ElementX | 298 class BoxFieldElement extends ElementX |
| 295 implements | 299 implements |
| 296 TypedElement, | 300 TypedElement, |
| 297 CapturedVariable, | 301 CapturedVariable, |
| 298 FieldElement, | 302 FieldElement, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 ConstantExpression get constant => null; | 356 ConstantExpression get constant => null; |
| 353 } | 357 } |
| 354 | 358 |
| 355 /// A local variable used encode the direct (uncaptured) references to [this]. | 359 /// A local variable used encode the direct (uncaptured) references to [this]. |
| 356 class ThisLocal extends Local { | 360 class ThisLocal extends Local { |
| 357 final ExecutableElement executableContext; | 361 final ExecutableElement executableContext; |
| 358 final hashCode = ElementX.newHashCode(); | 362 final hashCode = ElementX.newHashCode(); |
| 359 | 363 |
| 360 ThisLocal(this.executableContext); | 364 ThisLocal(this.executableContext); |
| 361 | 365 |
| 366 @override |
| 367 MemberElement get memberContext => executableContext.memberContext; |
| 368 |
| 362 String get name => 'this'; | 369 String get name => 'this'; |
| 363 | 370 |
| 364 ClassElement get enclosingClass => executableContext.enclosingClass; | 371 ClassElement get enclosingClass => executableContext.enclosingClass; |
| 365 } | 372 } |
| 366 | 373 |
| 367 /// Call method of a closure class. | 374 /// Call method of a closure class. |
| 368 class SynthesizedCallMethodElementX extends BaseFunctionElementX | 375 class SynthesizedCallMethodElementX extends BaseFunctionElementX |
| 369 implements MethodElement { | 376 implements MethodElement { |
| 370 final LocalFunctionElement expression; | 377 final LocalFunctionElement expression; |
| 371 final FunctionExpression node; | 378 final FunctionExpression node; |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 } | 1202 } |
| 1196 } | 1203 } |
| 1197 | 1204 |
| 1198 /// A type variable as a local variable. | 1205 /// A type variable as a local variable. |
| 1199 class TypeVariableLocal implements Local { | 1206 class TypeVariableLocal implements Local { |
| 1200 final ResolutionTypeVariableType typeVariable; | 1207 final ResolutionTypeVariableType typeVariable; |
| 1201 final ExecutableElement executableContext; | 1208 final ExecutableElement executableContext; |
| 1202 | 1209 |
| 1203 TypeVariableLocal(this.typeVariable, this.executableContext); | 1210 TypeVariableLocal(this.typeVariable, this.executableContext); |
| 1204 | 1211 |
| 1212 @override |
| 1213 MemberElement get memberContext => executableContext.memberContext; |
| 1214 |
| 1205 String get name => typeVariable.name; | 1215 String get name => typeVariable.name; |
| 1206 | 1216 |
| 1207 int get hashCode => typeVariable.hashCode; | 1217 int get hashCode => typeVariable.hashCode; |
| 1208 | 1218 |
| 1209 bool operator ==(other) { | 1219 bool operator ==(other) { |
| 1210 if (other is! TypeVariableLocal) return false; | 1220 if (other is! TypeVariableLocal) return false; |
| 1211 return typeVariable == other.typeVariable; | 1221 return typeVariable == other.typeVariable; |
| 1212 } | 1222 } |
| 1213 } | 1223 } |
| 1214 | 1224 |
| 1215 /// | 1225 /// |
| 1216 /// Move the below classes to a JS model eventually. | 1226 /// Move the below classes to a JS model eventually. |
| 1217 /// | 1227 /// |
| 1218 abstract class JSEntity implements Entity { | 1228 abstract class JSEntity implements Entity { |
| 1219 Entity get declaredEntity; | 1229 Entity get declaredEntity; |
| 1220 } | 1230 } |
| 1221 | 1231 |
| 1222 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1232 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1223 Entity get rootOfScope; | 1233 Entity get rootOfScope; |
| 1224 } | 1234 } |
| OLD | NEW |