| 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 resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
| 9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
| 10 | 10 |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 }); | 1452 }); |
| 1453 Selector selector = registry.getSelector(call); | 1453 Selector selector = registry.getSelector(call); |
| 1454 bool isSuperCall = Initializers.isSuperConstructorCall(call); | 1454 bool isSuperCall = Initializers.isSuperConstructorCall(call); |
| 1455 | 1455 |
| 1456 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, | 1456 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, |
| 1457 isSuperCall, | 1457 isSuperCall, |
| 1458 call); | 1458 call); |
| 1459 Selector constructorSelector = | 1459 Selector constructorSelector = |
| 1460 visitor.getRedirectingThisOrSuperConstructorSelector(call); | 1460 visitor.getRedirectingThisOrSuperConstructorSelector(call); |
| 1461 FunctionElement calledConstructor = | 1461 FunctionElement calledConstructor = |
| 1462 lookupTarget.lookupConstructor(constructorSelector); | 1462 lookupTarget.lookupConstructor(constructorSelector.name); |
| 1463 | 1463 |
| 1464 final bool isImplicitSuperCall = false; | 1464 final bool isImplicitSuperCall = false; |
| 1465 final String className = lookupTarget.name; | 1465 final String className = lookupTarget.name; |
| 1466 verifyThatConstructorMatchesCall(constructor, | 1466 verifyThatConstructorMatchesCall(constructor, |
| 1467 calledConstructor, | 1467 calledConstructor, |
| 1468 selector, | 1468 selector, |
| 1469 isImplicitSuperCall, | 1469 isImplicitSuperCall, |
| 1470 call, | 1470 call, |
| 1471 className, | 1471 className, |
| 1472 constructorSelector); | 1472 constructorSelector); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1490 classElement.library, | 1490 classElement.library, |
| 1491 0); | 1491 0); |
| 1492 | 1492 |
| 1493 final bool isSuperCall = true; | 1493 final bool isSuperCall = true; |
| 1494 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, | 1494 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, |
| 1495 isSuperCall, | 1495 isSuperCall, |
| 1496 functionNode); | 1496 functionNode); |
| 1497 Selector constructorSelector = new Selector.callDefaultConstructor( | 1497 Selector constructorSelector = new Selector.callDefaultConstructor( |
| 1498 visitor.enclosingElement.library); | 1498 visitor.enclosingElement.library); |
| 1499 Element calledConstructor = lookupTarget.lookupConstructor( | 1499 Element calledConstructor = lookupTarget.lookupConstructor( |
| 1500 constructorSelector); | 1500 constructorSelector.name); |
| 1501 | 1501 |
| 1502 final String className = lookupTarget.name; | 1502 final String className = lookupTarget.name; |
| 1503 final bool isImplicitSuperCall = true; | 1503 final bool isImplicitSuperCall = true; |
| 1504 verifyThatConstructorMatchesCall(constructor, | 1504 verifyThatConstructorMatchesCall(constructor, |
| 1505 calledConstructor, | 1505 calledConstructor, |
| 1506 callToMatch, | 1506 callToMatch, |
| 1507 isImplicitSuperCall, | 1507 isImplicitSuperCall, |
| 1508 functionNode, | 1508 functionNode, |
| 1509 className, | 1509 className, |
| 1510 constructorSelector); | 1510 constructorSelector); |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2307 | 2307 |
| 2308 // A synthetic constructor does not have a node. | 2308 // A synthetic constructor does not have a node. |
| 2309 if (node == null) return null; | 2309 if (node == null) return null; |
| 2310 if (node.initializers == null) return null; | 2310 if (node.initializers == null) return null; |
| 2311 Link<Node> initializers = node.initializers.nodes; | 2311 Link<Node> initializers = node.initializers.nodes; |
| 2312 if (!initializers.isEmpty && | 2312 if (!initializers.isEmpty && |
| 2313 Initializers.isConstructorRedirect(initializers.head)) { | 2313 Initializers.isConstructorRedirect(initializers.head)) { |
| 2314 Selector selector = | 2314 Selector selector = |
| 2315 getRedirectingThisOrSuperConstructorSelector(initializers.head); | 2315 getRedirectingThisOrSuperConstructorSelector(initializers.head); |
| 2316 final ClassElement classElement = constructor.enclosingClass; | 2316 final ClassElement classElement = constructor.enclosingClass; |
| 2317 return classElement.lookupConstructor(selector); | 2317 return classElement.lookupConstructor(selector.name); |
| 2318 } | 2318 } |
| 2319 return null; | 2319 return null; |
| 2320 } | 2320 } |
| 2321 | 2321 |
| 2322 void setupFunction(FunctionExpression node, FunctionElement function) { | 2322 void setupFunction(FunctionExpression node, FunctionElement function) { |
| 2323 Element enclosingElement = function.enclosingElement; | 2323 Element enclosingElement = function.enclosingElement; |
| 2324 if (node.modifiers.isStatic && | 2324 if (node.modifiers.isStatic && |
| 2325 enclosingElement.kind != ElementKind.CLASS) { | 2325 enclosingElement.kind != ElementKind.CLASS) { |
| 2326 compiler.reportError(node, MessageKind.ILLEGAL_STATIC); | 2326 compiler.reportError(node, MessageKind.ILLEGAL_STATIC); |
| 2327 } | 2327 } |
| (...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4779 resolver.enclosingElement.library) | 4779 resolver.enclosingElement.library) |
| 4780 : new Selector.callConstructor( | 4780 : new Selector.callConstructor( |
| 4781 constructorName, | 4781 constructorName, |
| 4782 resolver.enclosingElement.library); | 4782 resolver.enclosingElement.library); |
| 4783 } | 4783 } |
| 4784 | 4784 |
| 4785 FunctionElement resolveConstructor(ClassElement cls, | 4785 FunctionElement resolveConstructor(ClassElement cls, |
| 4786 Node diagnosticNode, | 4786 Node diagnosticNode, |
| 4787 String constructorName) { | 4787 String constructorName) { |
| 4788 cls.ensureResolved(compiler); | 4788 cls.ensureResolved(compiler); |
| 4789 Selector selector = createConstructorSelector(constructorName); | 4789 Element result = cls.lookupConstructor(constructorName); |
| 4790 Element result = cls.lookupConstructor(selector); | |
| 4791 if (result == null) { | 4790 if (result == null) { |
| 4792 String fullConstructorName = Elements.constructorNameForDiagnostics( | 4791 String fullConstructorName = Elements.constructorNameForDiagnostics( |
| 4793 cls.name, | 4792 cls.name, |
| 4794 constructorName); | 4793 constructorName); |
| 4795 return failOrReturnErroneousElement( | 4794 return failOrReturnErroneousElement( |
| 4796 cls, | 4795 cls, |
| 4797 diagnosticNode, | 4796 diagnosticNode, |
| 4798 fullConstructorName, | 4797 fullConstructorName, |
| 4799 MessageKind.CANNOT_FIND_CONSTRUCTOR, | 4798 MessageKind.CANNOT_FIND_CONSTRUCTOR, |
| 4800 {'constructorName': fullConstructorName}); | 4799 {'constructorName': fullConstructorName}); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4982 } | 4981 } |
| 4983 | 4982 |
| 4984 /// The result for the resolution of the `assert` method. | 4983 /// The result for the resolution of the `assert` method. |
| 4985 class AssertResult implements ResolutionResult { | 4984 class AssertResult implements ResolutionResult { |
| 4986 const AssertResult(); | 4985 const AssertResult(); |
| 4987 | 4986 |
| 4988 Element get element => null; | 4987 Element get element => null; |
| 4989 | 4988 |
| 4990 String toString() => 'AssertResult()'; | 4989 String toString() => 'AssertResult()'; |
| 4991 } | 4990 } |
| OLD | NEW |