Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 812523002: Change signature of lookupConstructor to only require a name. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: return null for unresolved default constructors Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 }); 1458 });
1459 Selector selector = registry.getSelector(call); 1459 Selector selector = registry.getSelector(call);
1460 bool isSuperCall = Initializers.isSuperConstructorCall(call); 1460 bool isSuperCall = Initializers.isSuperConstructorCall(call);
1461 1461
1462 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, 1462 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor,
1463 isSuperCall, 1463 isSuperCall,
1464 call); 1464 call);
1465 Selector constructorSelector = 1465 Selector constructorSelector =
1466 visitor.getRedirectingThisOrSuperConstructorSelector(call); 1466 visitor.getRedirectingThisOrSuperConstructorSelector(call);
1467 FunctionElement calledConstructor = 1467 FunctionElement calledConstructor =
1468 lookupTarget.lookupConstructor(constructorSelector); 1468 lookupTarget.lookupConstructor(constructorSelector.name);
1469 1469
1470 final bool isImplicitSuperCall = false; 1470 final bool isImplicitSuperCall = false;
1471 final String className = lookupTarget.name; 1471 final String className = lookupTarget.name;
1472 verifyThatConstructorMatchesCall(constructor, 1472 verifyThatConstructorMatchesCall(constructor,
1473 calledConstructor, 1473 calledConstructor,
1474 selector, 1474 selector,
1475 isImplicitSuperCall, 1475 isImplicitSuperCall,
1476 call, 1476 call,
1477 className, 1477 className,
1478 constructorSelector); 1478 constructorSelector);
(...skipping 17 matching lines...) Expand all
1496 classElement.library, 1496 classElement.library,
1497 0); 1497 0);
1498 1498
1499 final bool isSuperCall = true; 1499 final bool isSuperCall = true;
1500 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, 1500 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor,
1501 isSuperCall, 1501 isSuperCall,
1502 functionNode); 1502 functionNode);
1503 Selector constructorSelector = new Selector.callDefaultConstructor( 1503 Selector constructorSelector = new Selector.callDefaultConstructor(
1504 visitor.enclosingElement.library); 1504 visitor.enclosingElement.library);
1505 Element calledConstructor = lookupTarget.lookupConstructor( 1505 Element calledConstructor = lookupTarget.lookupConstructor(
1506 constructorSelector); 1506 constructorSelector.name);
1507 1507
1508 final String className = lookupTarget.name; 1508 final String className = lookupTarget.name;
1509 final bool isImplicitSuperCall = true; 1509 final bool isImplicitSuperCall = true;
1510 verifyThatConstructorMatchesCall(constructor, 1510 verifyThatConstructorMatchesCall(constructor,
1511 calledConstructor, 1511 calledConstructor,
1512 callToMatch, 1512 callToMatch,
1513 isImplicitSuperCall, 1513 isImplicitSuperCall,
1514 functionNode, 1514 functionNode,
1515 className, 1515 className,
1516 constructorSelector); 1516 constructorSelector);
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 2326
2327 // A synthetic constructor does not have a node. 2327 // A synthetic constructor does not have a node.
2328 if (node == null) return null; 2328 if (node == null) return null;
2329 if (node.initializers == null) return null; 2329 if (node.initializers == null) return null;
2330 Link<Node> initializers = node.initializers.nodes; 2330 Link<Node> initializers = node.initializers.nodes;
2331 if (!initializers.isEmpty && 2331 if (!initializers.isEmpty &&
2332 Initializers.isConstructorRedirect(initializers.head)) { 2332 Initializers.isConstructorRedirect(initializers.head)) {
2333 Selector selector = 2333 Selector selector =
2334 getRedirectingThisOrSuperConstructorSelector(initializers.head); 2334 getRedirectingThisOrSuperConstructorSelector(initializers.head);
2335 final ClassElement classElement = constructor.enclosingClass; 2335 final ClassElement classElement = constructor.enclosingClass;
2336 return classElement.lookupConstructor(selector); 2336 return classElement.lookupConstructor(selector.name);
2337 } 2337 }
2338 return null; 2338 return null;
2339 } 2339 }
2340 2340
2341 void setupFunction(FunctionExpression node, FunctionElement function) { 2341 void setupFunction(FunctionExpression node, FunctionElement function) {
2342 Element enclosingElement = function.enclosingElement; 2342 Element enclosingElement = function.enclosingElement;
2343 if (node.modifiers.isStatic && 2343 if (node.modifiers.isStatic &&
2344 enclosingElement.kind != ElementKind.CLASS) { 2344 enclosingElement.kind != ElementKind.CLASS) {
2345 compiler.reportError(node, MessageKind.ILLEGAL_STATIC); 2345 compiler.reportError(node, MessageKind.ILLEGAL_STATIC);
2346 } 2346 }
(...skipping 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4822 resolver.enclosingElement.library) 4822 resolver.enclosingElement.library)
4823 : new Selector.callConstructor( 4823 : new Selector.callConstructor(
4824 constructorName, 4824 constructorName,
4825 resolver.enclosingElement.library); 4825 resolver.enclosingElement.library);
4826 } 4826 }
4827 4827
4828 FunctionElement resolveConstructor(ClassElement cls, 4828 FunctionElement resolveConstructor(ClassElement cls,
4829 Node diagnosticNode, 4829 Node diagnosticNode,
4830 String constructorName) { 4830 String constructorName) {
4831 cls.ensureResolved(compiler); 4831 cls.ensureResolved(compiler);
4832 Selector selector = createConstructorSelector(constructorName); 4832 Element result = cls.lookupConstructor(constructorName);
4833 Element result = cls.lookupConstructor(selector);
4834 if (result == null) { 4833 if (result == null) {
4835 String fullConstructorName = Elements.constructorNameForDiagnostics( 4834 String fullConstructorName = Elements.constructorNameForDiagnostics(
4836 cls.name, 4835 cls.name,
4837 constructorName); 4836 constructorName);
4838 return failOrReturnErroneousElement( 4837 return failOrReturnErroneousElement(
4839 cls, 4838 cls,
4840 diagnosticNode, 4839 diagnosticNode,
4841 fullConstructorName, 4840 fullConstructorName,
4842 MessageKind.CANNOT_FIND_CONSTRUCTOR, 4841 MessageKind.CANNOT_FIND_CONSTRUCTOR,
4843 {'constructorName': fullConstructorName}); 4842 {'constructorName': fullConstructorName});
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
5043 } 5042 }
5044 5043
5045 /// The result for the resolution of the `assert` method. 5044 /// The result for the resolution of the `assert` method.
5046 class AssertResult implements ResolutionResult { 5045 class AssertResult implements ResolutionResult {
5047 const AssertResult(); 5046 const AssertResult();
5048 5047
5049 Element get element => null; 5048 Element get element => null;
5050 5049
5051 String toString() => 'AssertResult()'; 5050 String toString() => 'AssertResult()';
5052 } 5051 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698