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