| 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 dart2js.resolution; | 5 library dart2js.resolution; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 308 } |
| 309 if (element.isSynthesized) { | 309 if (element.isSynthesized) { |
| 310 if (element.isGenerativeConstructor) { | 310 if (element.isGenerativeConstructor) { |
| 311 ResolutionRegistry registry = | 311 ResolutionRegistry registry = |
| 312 new ResolutionRegistry(this.target, _ensureTreeElements(element)); | 312 new ResolutionRegistry(this.target, _ensureTreeElements(element)); |
| 313 ConstructorElement constructor = element.asFunctionElement(); | 313 ConstructorElement constructor = element.asFunctionElement(); |
| 314 ConstructorElement target = constructor.definingConstructor; | 314 ConstructorElement target = constructor.definingConstructor; |
| 315 // Ensure the signature of the synthesized element is | 315 // Ensure the signature of the synthesized element is |
| 316 // resolved. This is the only place where the resolver is | 316 // resolved. This is the only place where the resolver is |
| 317 // seeing this element. | 317 // seeing this element. |
| 318 FunctionType type = element.computeType(resolution); | 318 element.computeType(resolution); |
| 319 if (!target.isMalformed) { | 319 if (!target.isMalformed) { |
| 320 registry.registerStaticUse(new StaticUse.superConstructorInvoke( | 320 registry.registerStaticUse(new StaticUse.superConstructorInvoke( |
| 321 // TODO(johnniwinther): Provide the right call structure for | 321 target, CallStructure.NO_ARGS)); |
| 322 // forwarding constructors. | |
| 323 target, | |
| 324 CallStructure.NO_ARGS)); | |
| 325 } | 322 } |
| 326 // TODO(johnniwinther): Remove this substitution when synthesized | |
| 327 // constructors handle type variables correctly. | |
| 328 type = type.substByContext( | |
| 329 constructor.enclosingClass.asInstanceOf(target.enclosingClass)); | |
| 330 type.parameterTypes.forEach(registry.registerCheckedModeCheck); | |
| 331 type.optionalParameterTypes | |
| 332 .forEach(registry.registerCheckedModeCheck); | |
| 333 type.namedParameterTypes.forEach(registry.registerCheckedModeCheck); | |
| 334 return registry.impactBuilder; | 323 return registry.impactBuilder; |
| 335 } else { | 324 } else { |
| 336 assert(element.isDeferredLoaderGetter || element.isMalformed); | 325 assert(element.isDeferredLoaderGetter || element.isMalformed); |
| 337 _ensureTreeElements(element); | 326 _ensureTreeElements(element); |
| 338 return const ResolutionImpact(); | 327 return const ResolutionImpact(); |
| 339 } | 328 } |
| 340 } else { | 329 } else { |
| 341 element.parseNode(resolution.parsingContext); | 330 element.parseNode(resolution.parsingContext); |
| 342 element.computeType(resolution); | 331 element.computeType(resolution); |
| 343 FunctionElementX implementation = element; | 332 FunctionElementX implementation = element; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // `Foo<Unresolved>`. | 375 // `Foo<Unresolved>`. |
| 387 element.variables.type.toString() == type.toString(), | 376 element.variables.type.toString() == type.toString(), |
| 388 message: "Unexpected type computed for $element. " | 377 message: "Unexpected type computed for $element. " |
| 389 "Was ${element.variables.type}, computed $type.")); | 378 "Was ${element.variables.type}, computed $type.")); |
| 390 element.variables.type = type; | 379 element.variables.type = type; |
| 391 } else if (element.variables.type == null) { | 380 } else if (element.variables.type == null) { |
| 392 // Only assign the dynamic type if the element has no known type. This | 381 // Only assign the dynamic type if the element has no known type. This |
| 393 // happens for enum fields where the type is known but is not in the | 382 // happens for enum fields where the type is known but is not in the |
| 394 // synthesized AST. | 383 // synthesized AST. |
| 395 element.variables.type = const DynamicType(); | 384 element.variables.type = const DynamicType(); |
| 396 } else { | |
| 397 registry.registerCheckedModeCheck(element.variables.type); | |
| 398 } | 385 } |
| 399 | 386 |
| 400 Expression initializer = element.initializer; | 387 Expression initializer = element.initializer; |
| 401 Modifiers modifiers = element.modifiers; | 388 Modifiers modifiers = element.modifiers; |
| 402 if (initializer != null) { | 389 if (initializer != null) { |
| 403 // TODO(johnniwinther): Avoid analyzing initializers if | 390 // TODO(johnniwinther): Avoid analyzing initializers if |
| 404 // [Compiler.analyzeSignaturesOnly] is set. | 391 // [Compiler.analyzeSignaturesOnly] is set. |
| 405 ResolutionResult result = visitor.visit(initializer); | 392 ResolutionResult result = visitor.visit(initializer); |
| 406 if (result.isConstant) { | 393 if (result.isConstant) { |
| 407 element.constant = result.constant; | 394 element.constant = result.constant; |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 TreeElements get treeElements { | 1124 TreeElements get treeElements { |
| 1138 assert(invariant(this, _treeElements != null, | 1125 assert(invariant(this, _treeElements != null, |
| 1139 message: "TreeElements have not been computed for $this.")); | 1126 message: "TreeElements have not been computed for $this.")); |
| 1140 return _treeElements; | 1127 return _treeElements; |
| 1141 } | 1128 } |
| 1142 | 1129 |
| 1143 void reuseElement() { | 1130 void reuseElement() { |
| 1144 _treeElements = null; | 1131 _treeElements = null; |
| 1145 } | 1132 } |
| 1146 } | 1133 } |
| OLD | NEW |