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

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

Issue 1182913003: Split TypedSelector into Selector and TypeMask. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 5 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
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 /** 7 /**
8 * Core implementation of resolution. 8 * Core implementation of resolution.
9 * 9 *
10 * Do not subclass or instantiate this class outside this library 10 * Do not subclass or instantiate this class outside this library
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 target = currentClass.lookupSuperByName(selector.memberName); 567 target = currentClass.lookupSuperByName(selector.memberName);
568 // [target] may be null which means invoking noSuchMethod on 568 // [target] may be null which means invoking noSuchMethod on
569 // super. 569 // super.
570 if (target == null) { 570 if (target == null) {
571 target = reportAndCreateErroneousElement( 571 target = reportAndCreateErroneousElement(
572 node, name, MessageKind.NO_SUCH_SUPER_MEMBER, 572 node, name, MessageKind.NO_SUCH_SUPER_MEMBER,
573 {'className': currentClass.name, 'memberName': name}); 573 {'className': currentClass.name, 'memberName': name});
574 // We still need to register the invocation, because we might 574 // We still need to register the invocation, because we might
575 // call [:super.noSuchMethod:] which calls 575 // call [:super.noSuchMethod:] which calls
576 // [JSInvocationMirror._invokeOn]. 576 // [JSInvocationMirror._invokeOn].
577 registry.registerDynamicInvocation(selector); 577 registry.registerDynamicInvocation(
578 new UniverseSelector(selector, null));
578 registry.registerSuperNoSuchMethod(); 579 registry.registerSuperNoSuchMethod();
579 } 580 }
580 } else if (Elements.isUnresolved(resolvedReceiver.element)) { 581 } else if (Elements.isUnresolved(resolvedReceiver.element)) {
581 return const NoneResult(); 582 return const NoneResult();
582 } else if (resolvedReceiver.element.isClass) { 583 } else if (resolvedReceiver.element.isClass) {
583 ClassElement receiverClass = resolvedReceiver.element; 584 ClassElement receiverClass = resolvedReceiver.element;
584 receiverClass.ensureResolved(compiler); 585 receiverClass.ensureResolved(compiler);
585 if (node.isOperator) { 586 if (node.isOperator) {
586 // When the resolved receiver is a class, we can have two cases: 587 // When the resolved receiver is a class, we can have two cases:
587 // 1) a static send: C.foo, or 588 // 1) a static send: C.foo, or
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 {'className': currentClass.name, 'memberName': name}); 943 {'className': currentClass.name, 'memberName': name});
943 if (alternateName != null) { 944 if (alternateName != null) {
944 target = currentClass.lookupSuperByName(alternateName); 945 target = currentClass.lookupSuperByName(alternateName);
945 } 946 }
946 if (target == null) { 947 if (target == null) {
947 // If a setter wasn't resolved, use the [ErroneousElement]. 948 // If a setter wasn't resolved, use the [ErroneousElement].
948 target = error; 949 target = error;
949 } 950 }
950 // We still need to register the invocation, because we might 951 // We still need to register the invocation, because we might
951 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. 952 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn].
952 registry.registerDynamicInvocation(selector); 953 registry.registerDynamicInvocation(new UniverseSelector(selector, null));
953 registry.registerSuperNoSuchMethod(); 954 registry.registerSuperNoSuchMethod();
954 } 955 }
955 return computeSuperAccessSemantics(node, target); 956 return computeSuperAccessSemantics(node, target);
956 } 957 }
957 958
958 /// Resolve [node] as a subexpression that is _not_ the prefix of a member 959 /// Resolve [node] as a subexpression that is _not_ the prefix of a member
959 /// access. For instance `a` in `a + b`, as opposed to `a` in `a.b`. 960 /// access. For instance `a` in `a + b`, as opposed to `a` in `a.b`.
960 ResolutionResult visitExpression(Node node) { 961 ResolutionResult visitExpression(Node node) {
961 bool oldSendIsMemberAccess = sendIsMemberAccess; 962 bool oldSendIsMemberAccess = sendIsMemberAccess;
962 sendIsMemberAccess = false; 963 sendIsMemberAccess = false;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 if (semantics.kind == AccessKind.SUPER_METHOD) { 1071 if (semantics.kind == AccessKind.SUPER_METHOD) {
1071 registry.registerStaticUse(semantics.element.declaration); 1072 registry.registerStaticUse(semantics.element.declaration);
1072 } 1073 }
1073 // TODO(johnniwinther): Remove this when all information goes through 1074 // TODO(johnniwinther): Remove this when all information goes through
1074 // the [SendStructure]. 1075 // the [SendStructure].
1075 registry.useElement(node, semantics.element); 1076 registry.useElement(node, semantics.element);
1076 } 1077 }
1077 } else { 1078 } else {
1078 ResolutionResult expressionResult = visitExpression(expression); 1079 ResolutionResult expressionResult = visitExpression(expression);
1079 semantics = new DynamicAccess.dynamicProperty(expression); 1080 semantics = new DynamicAccess.dynamicProperty(expression);
1080 registry.registerDynamicInvocation(selector); 1081 registry.registerDynamicInvocation(new UniverseSelector(selector, null));
1081 1082
1082 if (expressionResult.isConstant) { 1083 if (expressionResult.isConstant) {
1083 bool isValidConstant; 1084 bool isValidConstant;
1084 ConstantExpression expressionConstant = expressionResult.constant; 1085 ConstantExpression expressionConstant = expressionResult.constant;
1085 DartType knownExpressionType = 1086 DartType knownExpressionType =
1086 expressionConstant.getKnownType(coreTypes); 1087 expressionConstant.getKnownType(coreTypes);
1087 switch (operator.kind) { 1088 switch (operator.kind) {
1088 case UnaryOperatorKind.COMPLEMENT: 1089 case UnaryOperatorKind.COMPLEMENT:
1089 isValidConstant = 1090 isValidConstant =
1090 knownExpressionType == coreTypes.intType; 1091 knownExpressionType == coreTypes.intType;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 registry.registerStaticUse(semantics.element.declaration); 1246 registry.registerStaticUse(semantics.element.declaration);
1246 } 1247 }
1247 // TODO(johnniwinther): Remove this when all information goes through 1248 // TODO(johnniwinther): Remove this when all information goes through
1248 // the [SendStructure]. 1249 // the [SendStructure].
1249 registry.useElement(node, semantics.element); 1250 registry.useElement(node, semantics.element);
1250 } 1251 }
1251 visitExpression(right); 1252 visitExpression(right);
1252 } else { 1253 } else {
1253 ResolutionResult leftResult = visitExpression(left); 1254 ResolutionResult leftResult = visitExpression(left);
1254 ResolutionResult rightResult = visitExpression(right); 1255 ResolutionResult rightResult = visitExpression(right);
1255 registry.registerDynamicInvocation(selector); 1256 registry.registerDynamicInvocation(new UniverseSelector(selector, null));
1256 semantics = new DynamicAccess.dynamicProperty(left); 1257 semantics = new DynamicAccess.dynamicProperty(left);
1257 1258
1258 if (leftResult.isConstant && rightResult.isConstant) { 1259 if (leftResult.isConstant && rightResult.isConstant) {
1259 bool isValidConstant; 1260 bool isValidConstant;
1260 ConstantExpression leftConstant = leftResult.constant; 1261 ConstantExpression leftConstant = leftResult.constant;
1261 ConstantExpression rightConstant = leftResult.constant; 1262 ConstantExpression rightConstant = leftResult.constant;
1262 DartType knownLeftType = leftConstant.getKnownType(coreTypes); 1263 DartType knownLeftType = leftConstant.getKnownType(coreTypes);
1263 DartType knownRightType = rightConstant.getKnownType(coreTypes); 1264 DartType knownRightType = rightConstant.getKnownType(coreTypes);
1264 switch (operator.kind) { 1265 switch (operator.kind) {
1265 case BinaryOperatorKind.EQ: 1266 case BinaryOperatorKind.EQ:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 ResolutionResult handleExpressionInvoke(Send node) { 1378 ResolutionResult handleExpressionInvoke(Send node) {
1378 assert(invariant(node, node.isCall, 1379 assert(invariant(node, node.isCall,
1379 message: "Unexpected expression: $node")); 1380 message: "Unexpected expression: $node"));
1380 Node expression = node.selector; 1381 Node expression = node.selector;
1381 visitExpression(expression); 1382 visitExpression(expression);
1382 CallStructure callStructure = resolveArguments(node.argumentsNode); 1383 CallStructure callStructure = resolveArguments(node.argumentsNode);
1383 Selector selector = callStructure.callSelector; 1384 Selector selector = callStructure.callSelector;
1384 // TODO(johnniwinther): Remove this when all information goes through the 1385 // TODO(johnniwinther): Remove this when all information goes through the
1385 // [SendStructure]. 1386 // [SendStructure].
1386 registry.setSelector(node, selector); 1387 registry.setSelector(node, selector);
1387 registry.registerDynamicInvocation(selector); 1388 registry.registerDynamicInvocation(new UniverseSelector(selector, null));
1388 registry.registerSendStructure(node, 1389 registry.registerSendStructure(node,
1389 new InvokeStructure(new AccessSemantics.expression(), selector)); 1390 new InvokeStructure(new AccessSemantics.expression(), selector));
1390 return const NoneResult(); 1391 return const NoneResult();
1391 } 1392 }
1392 1393
1393 /// Handle a, possibly invalid, assertion, like `assert(cond)` or `assert()`. 1394 /// Handle a, possibly invalid, assertion, like `assert(cond)` or `assert()`.
1394 ResolutionResult handleAssert(Send node) { 1395 ResolutionResult handleAssert(Send node) {
1395 assert(invariant(node, node.isCall, 1396 assert(invariant(node, node.isCall,
1396 message: "Unexpected assert: $node")); 1397 message: "Unexpected assert: $node"));
1397 // If this send is of the form "assert(expr);", then 1398 // If this send is of the form "assert(expr);", then
(...skipping 29 matching lines...) Expand all
1427 /// Handle access on `this`, like `this()` and `this` when it is parsed as a 1428 /// Handle access on `this`, like `this()` and `this` when it is parsed as a
1428 /// [Send] node. 1429 /// [Send] node.
1429 ResolutionResult handleThisAccess(Send node) { 1430 ResolutionResult handleThisAccess(Send node) {
1430 AccessSemantics accessSemantics = new AccessSemantics.thisAccess(); 1431 AccessSemantics accessSemantics = new AccessSemantics.thisAccess();
1431 if (node.isCall) { 1432 if (node.isCall) {
1432 CallStructure callStructure = resolveArguments(node.argumentsNode); 1433 CallStructure callStructure = resolveArguments(node.argumentsNode);
1433 Selector selector = callStructure.callSelector; 1434 Selector selector = callStructure.callSelector;
1434 // TODO(johnniwinther): Handle invalid this access as an 1435 // TODO(johnniwinther): Handle invalid this access as an
1435 // [AccessSemantics]. 1436 // [AccessSemantics].
1436 if (checkThisAccess(node)) { 1437 if (checkThisAccess(node)) {
1437 registry.registerDynamicInvocation(selector); 1438 registry.registerDynamicInvocation(
1439 new UniverseSelector(selector, null));
1438 registry.registerSendStructure(node, 1440 registry.registerSendStructure(node,
1439 new InvokeStructure(accessSemantics, selector)); 1441 new InvokeStructure(accessSemantics, selector));
1440 } 1442 }
1441 // TODO(johnniwinther): Remove this when all information goes through 1443 // TODO(johnniwinther): Remove this when all information goes through
1442 // the [SendStructure]. 1444 // the [SendStructure].
1443 registry.setSelector(node, selector); 1445 registry.setSelector(node, selector);
1444 } else { 1446 } else {
1445 // TODO(johnniwinther): Handle get of `this` when it is a [Send] node. 1447 // TODO(johnniwinther): Handle get of `this` when it is a [Send] node.
1446 internalError(node, "Unexpected node '$node'."); 1448 internalError(node, "Unexpected node '$node'.");
1447 } 1449 }
(...skipping 15 matching lines...) Expand all
1463 AccessSemantics semantics = computeSuperAccessSemanticsForSelector( 1465 AccessSemantics semantics = computeSuperAccessSemanticsForSelector(
1464 node, selector, alternateName: name.setter); 1466 node, selector, alternateName: name.setter);
1465 if (node.isCall) { 1467 if (node.isCall) {
1466 bool isIncompatibleInvoke = false; 1468 bool isIncompatibleInvoke = false;
1467 switch (semantics.kind) { 1469 switch (semantics.kind) {
1468 case AccessKind.SUPER_METHOD: 1470 case AccessKind.SUPER_METHOD:
1469 MethodElementX superMethod = semantics.element; 1471 MethodElementX superMethod = semantics.element;
1470 superMethod.computeSignature(compiler); 1472 superMethod.computeSignature(compiler);
1471 if (!callStructure.signatureApplies(superMethod)) { 1473 if (!callStructure.signatureApplies(superMethod)) {
1472 registry.registerThrowNoSuchMethod(); 1474 registry.registerThrowNoSuchMethod();
1473 registry.registerDynamicInvocation(selector); 1475 registry.registerDynamicInvocation(
1476 new UniverseSelector(selector, null));
1474 registry.registerSuperNoSuchMethod(); 1477 registry.registerSuperNoSuchMethod();
1475 isIncompatibleInvoke = true; 1478 isIncompatibleInvoke = true;
1476 } else { 1479 } else {
1477 registry.registerStaticInvocation(semantics.element); 1480 registry.registerStaticInvocation(semantics.element);
1478 } 1481 }
1479 break; 1482 break;
1480 case AccessKind.SUPER_FIELD: 1483 case AccessKind.SUPER_FIELD:
1481 case AccessKind.SUPER_FINAL_FIELD: 1484 case AccessKind.SUPER_FINAL_FIELD:
1482 case AccessKind.SUPER_GETTER: 1485 case AccessKind.SUPER_GETTER:
1483 registry.registerStaticUse(semantics.element); 1486 registry.registerStaticUse(semantics.element);
1484 selector = callStructure.callSelector; 1487 selector = callStructure.callSelector;
1485 registry.registerDynamicInvocation(selector); 1488 registry.registerDynamicInvocation(
1489 new UniverseSelector(selector, null));
1486 break; 1490 break;
1487 case AccessKind.SUPER_SETTER: 1491 case AccessKind.SUPER_SETTER:
1488 case AccessKind.UNRESOLVED_SUPER: 1492 case AccessKind.UNRESOLVED_SUPER:
1489 // NoSuchMethod registered in [computeSuperSemantics]. 1493 // NoSuchMethod registered in [computeSuperSemantics].
1490 break; 1494 break;
1491 default: 1495 default:
1492 internalError(node, "Unexpected super property access $semantics."); 1496 internalError(node, "Unexpected super property access $semantics.");
1493 break; 1497 break;
1494 } 1498 }
1495 registry.registerSendStructure(node, 1499 registry.registerSendStructure(node,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 } 1705 }
1702 1706
1703 /// Handle dynamic access of [semantics]. 1707 /// Handle dynamic access of [semantics].
1704 ResolutionResult handleDynamicAccessSemantics( 1708 ResolutionResult handleDynamicAccessSemantics(
1705 Send node, Name name, AccessSemantics semantics) { 1709 Send node, Name name, AccessSemantics semantics) {
1706 SendStructure sendStructure; 1710 SendStructure sendStructure;
1707 Selector selector; 1711 Selector selector;
1708 if (node.isCall) { 1712 if (node.isCall) {
1709 CallStructure callStructure = resolveArguments(node.argumentsNode); 1713 CallStructure callStructure = resolveArguments(node.argumentsNode);
1710 selector = new Selector(SelectorKind.CALL, name, callStructure); 1714 selector = new Selector(SelectorKind.CALL, name, callStructure);
1711 registry.registerDynamicInvocation(selector); 1715 registry.registerDynamicInvocation(
1716 new UniverseSelector(selector, null));
1712 sendStructure = new InvokeStructure(semantics, selector); 1717 sendStructure = new InvokeStructure(semantics, selector);
1713 } else { 1718 } else {
1714 assert(invariant(node, node.isPropertyAccess)); 1719 assert(invariant(node, node.isPropertyAccess));
1715 selector = new Selector( 1720 selector = new Selector(
1716 SelectorKind.GETTER, name, CallStructure.NO_ARGS); 1721 SelectorKind.GETTER, name, CallStructure.NO_ARGS);
1717 registry.registerDynamicGetter(selector); 1722 registry.registerDynamicGetter(
1723 new UniverseSelector(selector, null));
1718 sendStructure = new GetStructure(semantics, selector); 1724 sendStructure = new GetStructure(semantics, selector);
1719 } 1725 }
1720 registry.registerSendStructure(node, sendStructure); 1726 registry.registerSendStructure(node, sendStructure);
1721 // TODO(johnniwinther): Remove this when all information goes through 1727 // TODO(johnniwinther): Remove this when all information goes through
1722 // the [SendStructure]. 1728 // the [SendStructure].
1723 registry.setSelector(node, selector); 1729 registry.setSelector(node, selector);
1724 return const NoneResult(); 1730 return const NoneResult();
1725 } 1731 }
1726 1732
1727 /// Handle dynamic property access, like `a.b` or `a.b()` where `a` is not a 1733 /// Handle dynamic property access, like `a.b` or `a.b()` where `a` is not a
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 } 1797 }
1792 1798
1793 /// Handle erroneous access of [element] of the given [accessSemantics]. 1799 /// Handle erroneous access of [element] of the given [accessSemantics].
1794 ResolutionResult handleErroneousAccess( 1800 ResolutionResult handleErroneousAccess(
1795 Send node, Name name, Element element, AccessSemantics accessSemantics) { 1801 Send node, Name name, Element element, AccessSemantics accessSemantics) {
1796 SendStructure sendStructure; 1802 SendStructure sendStructure;
1797 Selector selector; 1803 Selector selector;
1798 if (node.isCall) { 1804 if (node.isCall) {
1799 CallStructure callStructure = resolveArguments(node.argumentsNode); 1805 CallStructure callStructure = resolveArguments(node.argumentsNode);
1800 selector = new Selector(SelectorKind.CALL, name, callStructure); 1806 selector = new Selector(SelectorKind.CALL, name, callStructure);
1801 registry.registerDynamicInvocation(selector); 1807 registry.registerDynamicInvocation(
1808 new UniverseSelector(selector, null));
1802 sendStructure = new InvokeStructure(accessSemantics, selector); 1809 sendStructure = new InvokeStructure(accessSemantics, selector);
1803 } else { 1810 } else {
1804 assert(invariant(node, node.isPropertyAccess)); 1811 assert(invariant(node, node.isPropertyAccess));
1805 selector = new Selector( 1812 selector = new Selector(
1806 SelectorKind.GETTER, name, CallStructure.NO_ARGS); 1813 SelectorKind.GETTER, name, CallStructure.NO_ARGS);
1807 registry.registerDynamicGetter(selector); 1814 registry.registerDynamicGetter(
1815 new UniverseSelector(selector, null));
1808 sendStructure = new GetStructure(accessSemantics, selector); 1816 sendStructure = new GetStructure(accessSemantics, selector);
1809 } 1817 }
1810 // TODO(johnniwinther): Remove this when all information goes through 1818 // TODO(johnniwinther): Remove this when all information goes through
1811 // the [SendStructure]. 1819 // the [SendStructure].
1812 registry.setSelector(node, selector); 1820 registry.setSelector(node, selector);
1813 registry.useElement(node, element); 1821 registry.useElement(node, element);
1814 registry.registerSendStructure(node, sendStructure); 1822 registry.registerSendStructure(node, sendStructure);
1815 return const NoneResult(); 1823 return const NoneResult();
1816 } 1824 }
1817 1825
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 selector = new Selector(SelectorKind.GETTER, name, callStructure); 1873 selector = new Selector(SelectorKind.GETTER, name, callStructure);
1866 } 1874 }
1867 if (node.isCall) { 1875 if (node.isCall) {
1868 bool isIncompatibleInvoke = false; 1876 bool isIncompatibleInvoke = false;
1869 switch (semantics.kind) { 1877 switch (semantics.kind) {
1870 case AccessKind.LOCAL_FUNCTION: 1878 case AccessKind.LOCAL_FUNCTION:
1871 LocalFunctionElementX function = semantics.element; 1879 LocalFunctionElementX function = semantics.element;
1872 function.computeSignature(compiler); 1880 function.computeSignature(compiler);
1873 if (!callStructure.signatureApplies(function)) { 1881 if (!callStructure.signatureApplies(function)) {
1874 registry.registerThrowNoSuchMethod(); 1882 registry.registerThrowNoSuchMethod();
1875 registry.registerDynamicInvocation(selector); 1883 registry.registerDynamicInvocation(
1884 new UniverseSelector(selector, null));
1876 isIncompatibleInvoke = true; 1885 isIncompatibleInvoke = true;
1877 } 1886 }
1878 break; 1887 break;
1879 case AccessKind.PARAMETER: 1888 case AccessKind.PARAMETER:
1880 case AccessKind.FINAL_PARAMETER: 1889 case AccessKind.FINAL_PARAMETER:
1881 case AccessKind.LOCAL_VARIABLE: 1890 case AccessKind.LOCAL_VARIABLE:
1882 case AccessKind.FINAL_LOCAL_VARIABLE: 1891 case AccessKind.FINAL_LOCAL_VARIABLE:
1883 selector = callStructure.callSelector; 1892 selector = callStructure.callSelector;
1884 registry.registerDynamicInvocation(selector); 1893 registry.registerDynamicInvocation(
1894 new UniverseSelector(selector, null));
1885 break; 1895 break;
1886 default: 1896 default:
1887 internalError(node, 1897 internalError(node,
1888 "Unexpected local access $semantics."); 1898 "Unexpected local access $semantics.");
1889 break; 1899 break;
1890 } 1900 }
1891 registry.registerSendStructure(node, 1901 registry.registerSendStructure(node,
1892 isIncompatibleInvoke 1902 isIncompatibleInvoke
1893 ? new IncompatibleInvokeStructure(semantics, selector) 1903 ? new IncompatibleInvokeStructure(semantics, selector)
1894 : new InvokeStructure(semantics, selector)); 1904 : new InvokeStructure(semantics, selector));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 computeStaticOrTopLevelAccessSemantics(node, member); 1949 computeStaticOrTopLevelAccessSemantics(node, member);
1940 if (node.isCall) { 1950 if (node.isCall) {
1941 bool isIncompatibleInvoke = false; 1951 bool isIncompatibleInvoke = false;
1942 switch (semantics.kind) { 1952 switch (semantics.kind) {
1943 case AccessKind.STATIC_METHOD: 1953 case AccessKind.STATIC_METHOD:
1944 case AccessKind.TOPLEVEL_METHOD: 1954 case AccessKind.TOPLEVEL_METHOD:
1945 MethodElementX method = semantics.element; 1955 MethodElementX method = semantics.element;
1946 method.computeSignature(compiler); 1956 method.computeSignature(compiler);
1947 if (!callStructure.signatureApplies(method)) { 1957 if (!callStructure.signatureApplies(method)) {
1948 registry.registerThrowNoSuchMethod(); 1958 registry.registerThrowNoSuchMethod();
1949 registry.registerDynamicInvocation(selector); 1959 registry.registerDynamicInvocation(
1960 new UniverseSelector(selector, null));
1950 isIncompatibleInvoke = true; 1961 isIncompatibleInvoke = true;
1951 } else { 1962 } else {
1952 registry.registerStaticUse(semantics.element); 1963 registry.registerStaticUse(semantics.element);
1953 handleForeignCall(node, semantics.element, selector); 1964 handleForeignCall(node, semantics.element, selector);
1954 } 1965 }
1955 break; 1966 break;
1956 case AccessKind.STATIC_FIELD: 1967 case AccessKind.STATIC_FIELD:
1957 case AccessKind.FINAL_STATIC_FIELD: 1968 case AccessKind.FINAL_STATIC_FIELD:
1958 case AccessKind.STATIC_GETTER: 1969 case AccessKind.STATIC_GETTER:
1959 case AccessKind.TOPLEVEL_FIELD: 1970 case AccessKind.TOPLEVEL_FIELD:
1960 case AccessKind.FINAL_TOPLEVEL_FIELD: 1971 case AccessKind.FINAL_TOPLEVEL_FIELD:
1961 case AccessKind.TOPLEVEL_GETTER: 1972 case AccessKind.TOPLEVEL_GETTER:
1962 registry.registerStaticUse(semantics.element); 1973 registry.registerStaticUse(semantics.element);
1963 selector = callStructure.callSelector; 1974 selector = callStructure.callSelector;
1964 registry.registerDynamicInvocation(selector); 1975 registry.registerDynamicInvocation(
1976 new UniverseSelector(selector, null));
1965 break; 1977 break;
1966 case AccessKind.STATIC_SETTER: 1978 case AccessKind.STATIC_SETTER:
1967 case AccessKind.TOPLEVEL_SETTER: 1979 case AccessKind.TOPLEVEL_SETTER:
1968 case AccessKind.UNRESOLVED: 1980 case AccessKind.UNRESOLVED:
1969 registry.registerThrowNoSuchMethod(); 1981 registry.registerThrowNoSuchMethod();
1970 member = reportAndCreateErroneousElement( 1982 member = reportAndCreateErroneousElement(
1971 node.selector, name.text, 1983 node.selector, name.text,
1972 MessageKind.CANNOT_RESOLVE_GETTER, const {}); 1984 MessageKind.CANNOT_RESOLVE_GETTER, const {});
1973 break; 1985 break;
1974 default: 1986 default:
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2189
2178 if (node.isCall) { 2190 if (node.isCall) {
2179 if (Elements.isUnresolved(target) || 2191 if (Elements.isUnresolved(target) ||
2180 target.isGetter || 2192 target.isGetter ||
2181 target.isField || 2193 target.isField ||
2182 Elements.isClosureSend(node, target)) { 2194 Elements.isClosureSend(node, target)) {
2183 // If we don't know what we're calling or if we are calling a getter, 2195 // If we don't know what we're calling or if we are calling a getter,
2184 // we need to register that fact that we may be calling a closure 2196 // we need to register that fact that we may be calling a closure
2185 // with the same arguments. 2197 // with the same arguments.
2186 Selector call = new Selector.callClosureFrom(selector); 2198 Selector call = new Selector.callClosureFrom(selector);
2187 registry.registerDynamicInvocation(call); 2199 registry.registerDynamicInvocation(
2200 new UniverseSelector(selector, null));
2188 } else if (target.impliesType) { 2201 } else if (target.impliesType) {
2189 // We call 'call()' on a Type instance returned from the reference to a 2202 // We call 'call()' on a Type instance returned from the reference to a
2190 // class or typedef literal. We do not need to register this call as a 2203 // class or typedef literal. We do not need to register this call as a
2191 // dynamic invocation, because we statically know what the target is. 2204 // dynamic invocation, because we statically know what the target is.
2192 } else { 2205 } else {
2193 if (target is FunctionElement) { 2206 if (target is FunctionElement) {
2194 FunctionElement function = target; 2207 FunctionElement function = target;
2195 function.computeType(compiler); 2208 function.computeType(compiler);
2196 } 2209 }
2197 if (!selector.applies(target, compiler.world)) { 2210 if (!selector.applies(target, compiler.world)) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 {'className': currentClass.name, 'memberName': selector.name}); 2365 {'className': currentClass.name, 'memberName': selector.name});
2353 registry.registerSuperNoSuchMethod(); 2366 registry.registerSuperNoSuchMethod();
2354 } 2367 }
2355 } 2368 }
2356 registry.useElement(node.selector, getter); 2369 registry.useElement(node.selector, getter);
2357 2370
2358 // Make sure we include the + and - operators if we are using 2371 // Make sure we include the + and - operators if we are using
2359 // the ++ and -- ones. Also, if op= form is used, include op itself. 2372 // the ++ and -- ones. Also, if op= form is used, include op itself.
2360 void registerBinaryOperator(String name) { 2373 void registerBinaryOperator(String name) {
2361 Selector binop = new Selector.binaryOperator(name); 2374 Selector binop = new Selector.binaryOperator(name);
2362 registry.registerDynamicInvocation(binop); 2375 registry.registerDynamicInvocation(
2376 new UniverseSelector(binop, null));
2363 registry.setOperatorSelectorInComplexSendSet(node, binop); 2377 registry.setOperatorSelectorInComplexSendSet(node, binop);
2364 } 2378 }
2365 if (identical(source, '++')) { 2379 if (identical(source, '++')) {
2366 registerBinaryOperator('+'); 2380 registerBinaryOperator('+');
2367 registry.registerInstantiatedClass(compiler.intClass); 2381 registry.registerInstantiatedClass(compiler.intClass);
2368 } else if (identical(source, '--')) { 2382 } else if (identical(source, '--')) {
2369 registerBinaryOperator('-'); 2383 registerBinaryOperator('-');
2370 registry.registerInstantiatedClass(compiler.intClass); 2384 registry.registerInstantiatedClass(compiler.intClass);
2371 } else if (source.endsWith('=')) { 2385 } else if (source.endsWith('=')) {
2372 registerBinaryOperator(Elements.mapToUserOperator(operatorName)); 2386 registerBinaryOperator(Elements.mapToUserOperator(operatorName));
2373 } 2387 }
2374 } 2388 }
2375 2389
2376 registerSend(selector, setter); 2390 registerSend(selector, setter);
2377 return new ResolutionResult.forElement(registry.useElement(node, setter)); 2391 return new ResolutionResult.forElement(registry.useElement(node, setter));
2378 } 2392 }
2379 2393
2380 void registerSend(Selector selector, Element target) { 2394 void registerSend(Selector selector, Element target) {
2381 if (target == null || target.isInstanceMember) { 2395 if (target == null || target.isInstanceMember) {
2382 if (selector.isGetter) { 2396 if (selector.isGetter) {
2383 registry.registerDynamicGetter(selector); 2397 registry.registerDynamicGetter(
2398 new UniverseSelector(selector, null));
2384 } else if (selector.isSetter) { 2399 } else if (selector.isSetter) {
2385 registry.registerDynamicSetter(selector); 2400 registry.registerDynamicSetter(
2401 new UniverseSelector(selector, null));
2386 } else { 2402 } else {
2387 registry.registerDynamicInvocation(selector); 2403 registry.registerDynamicInvocation(
2404 new UniverseSelector(selector, null));
2388 } 2405 }
2389 } else if (Elements.isStaticOrTopLevel(target)) { 2406 } else if (Elements.isStaticOrTopLevel(target)) {
2390 // Avoid registration of type variables since they are not analyzable but 2407 // Avoid registration of type variables since they are not analyzable but
2391 // instead resolved through their enclosing type declaration. 2408 // instead resolved through their enclosing type declaration.
2392 if (!target.isTypeVariable) { 2409 if (!target.isTypeVariable) {
2393 // [target] might be the implementation element and only declaration 2410 // [target] might be the implementation element and only declaration
2394 // elements may be registered. 2411 // elements may be registered.
2395 registry.registerStaticUse(target.declaration); 2412 registry.registerStaticUse(target.declaration);
2396 } 2413 }
2397 } 2414 }
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 } 3021 }
3005 label.setContinueTarget(); 3022 label.setContinueTarget();
3006 registry.useLabel(node, label); 3023 registry.useLabel(node, label);
3007 } 3024 }
3008 registry.registerTargetOf(node, target); 3025 registry.registerTargetOf(node, target);
3009 return const NoneResult(); 3026 return const NoneResult();
3010 } 3027 }
3011 3028
3012 registerImplicitInvocation(String name, int arity) { 3029 registerImplicitInvocation(String name, int arity) {
3013 Selector selector = new Selector.call(name, null, arity); 3030 Selector selector = new Selector.call(name, null, arity);
3014 registry.registerDynamicInvocation(selector); 3031 registry.registerDynamicInvocation(new UniverseSelector(selector, null));
3015 } 3032 }
3016 3033
3017 ResolutionResult visitAsyncForIn(AsyncForIn node) { 3034 ResolutionResult visitAsyncForIn(AsyncForIn node) {
3018 registry.registerAsyncForIn(node); 3035 registry.registerAsyncForIn(node);
3019 registry.setCurrentSelector(node, compiler.currentSelector); 3036 registry.setCurrentSelector(node, compiler.currentSelector);
3020 registry.registerDynamicGetter(compiler.currentSelector); 3037 registry.registerDynamicGetter(
3038 new UniverseSelector(compiler.currentSelector, null));
3021 registry.setMoveNextSelector(node, compiler.moveNextSelector); 3039 registry.setMoveNextSelector(node, compiler.moveNextSelector);
3022 registry.registerDynamicInvocation(compiler.moveNextSelector); 3040 registry.registerDynamicInvocation(
3041 new UniverseSelector(compiler.moveNextSelector, null));
3023 3042
3024 visit(node.expression); 3043 visit(node.expression);
3025 3044
3026 Scope blockScope = new BlockScope(scope); 3045 Scope blockScope = new BlockScope(scope);
3027 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); 3046 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope);
3028 visitLoopBodyIn(node, node.body, blockScope); 3047 visitLoopBodyIn(node, node.body, blockScope);
3029 return const NoneResult(); 3048 return const NoneResult();
3030 } 3049 }
3031 3050
3032 ResolutionResult visitSyncForIn(SyncForIn node) { 3051 ResolutionResult visitSyncForIn(SyncForIn node) {
3033 registry.registerSyncForIn(node); 3052 registry.registerSyncForIn(node);
3034 registry.setIteratorSelector(node, compiler.iteratorSelector); 3053 registry.setIteratorSelector(node, compiler.iteratorSelector);
3035 registry.registerDynamicGetter(compiler.iteratorSelector); 3054 registry.registerDynamicGetter(
3055 new UniverseSelector(compiler.iteratorSelector, null));
3036 registry.setCurrentSelector(node, compiler.currentSelector); 3056 registry.setCurrentSelector(node, compiler.currentSelector);
3037 registry.registerDynamicGetter(compiler.currentSelector); 3057 registry.registerDynamicGetter(
3058 new UniverseSelector(compiler.currentSelector, null));
3038 registry.setMoveNextSelector(node, compiler.moveNextSelector); 3059 registry.setMoveNextSelector(node, compiler.moveNextSelector);
3039 registry.registerDynamicInvocation(compiler.moveNextSelector); 3060 registry.registerDynamicInvocation(
3061 new UniverseSelector(compiler.moveNextSelector, null));
3040 3062
3041 visit(node.expression); 3063 visit(node.expression);
3042 3064
3043 Scope blockScope = new BlockScope(scope); 3065 Scope blockScope = new BlockScope(scope);
3044 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); 3066 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope);
3045 visitLoopBodyIn(node, node.body, blockScope); 3067 visitLoopBodyIn(node, node.body, blockScope);
3046 return const NoneResult(); 3068 return const NoneResult();
3047 } 3069 }
3048 3070
3049 void visitForInDeclaredIdentifierIn( 3071 void visitForInDeclaredIdentifierIn(
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
3461 } 3483 }
3462 return const NoneResult(); 3484 return const NoneResult();
3463 } 3485 }
3464 } 3486 }
3465 3487
3466 /// Looks up [name] in [scope] and unwraps the result. 3488 /// Looks up [name] in [scope] and unwraps the result.
3467 Element lookupInScope(Compiler compiler, Node node, 3489 Element lookupInScope(Compiler compiler, Node node,
3468 Scope scope, String name) { 3490 Scope scope, String name) {
3469 return Elements.unwrap(scope.lookup(name), compiler, node); 3491 return Elements.unwrap(scope.lookup(name), compiler, node);
3470 } 3492 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698