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.members; | 5 library dart2js.resolution.members; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show | 8 import '../common/names.dart' show |
9 Selectors; | 9 Selectors; |
10 import '../compiler.dart' show | 10 import '../compiler.dart' show |
(...skipping 19 matching lines...) Expand all Loading... |
30 VariableList; | 30 VariableList; |
31 import '../tokens/token.dart' show | 31 import '../tokens/token.dart' show |
32 isUserDefinableOperator; | 32 isUserDefinableOperator; |
33 import '../tree/tree.dart'; | 33 import '../tree/tree.dart'; |
34 import '../util/util.dart' show | 34 import '../util/util.dart' show |
35 Link; | 35 Link; |
36 import '../universe/call_structure.dart' show | 36 import '../universe/call_structure.dart' show |
37 CallStructure; | 37 CallStructure; |
38 import '../universe/selector.dart' show | 38 import '../universe/selector.dart' show |
39 Selector; | 39 Selector; |
40 import '../universe/universe.dart' show | |
41 UniverseSelector; | |
42 import '../universe/use.dart' show | 40 import '../universe/use.dart' show |
| 41 DynamicUse, |
43 StaticUse; | 42 StaticUse; |
44 | 43 |
45 import 'access_semantics.dart'; | 44 import 'access_semantics.dart'; |
46 import 'class_members.dart' show MembersCreator; | 45 import 'class_members.dart' show MembersCreator; |
47 import 'operators.dart'; | 46 import 'operators.dart'; |
48 import 'send_structure.dart'; | 47 import 'send_structure.dart'; |
49 | 48 |
50 import 'constructors.dart' show | 49 import 'constructors.dart' show |
51 ConstructorResolver, | 50 ConstructorResolver, |
52 ConstructorResult; | 51 ConstructorResult; |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 error = reportAndCreateErroneousElement( | 1027 error = reportAndCreateErroneousElement( |
1029 node, name.text, MessageKind.NO_SUCH_SUPER_MEMBER, | 1028 node, name.text, MessageKind.NO_SUCH_SUPER_MEMBER, |
1030 {'className': currentClass.name, 'memberName': name}); | 1029 {'className': currentClass.name, 'memberName': name}); |
1031 } | 1030 } |
1032 if (target == null) { | 1031 if (target == null) { |
1033 // If a setter wasn't resolved, use the [ErroneousElement]. | 1032 // If a setter wasn't resolved, use the [ErroneousElement]. |
1034 target = error; | 1033 target = error; |
1035 } | 1034 } |
1036 // We still need to register the invocation, because we might | 1035 // We still need to register the invocation, because we might |
1037 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. | 1036 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. |
1038 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 1037 registry.registerDynamicUse(new DynamicUse(selector, null)); |
1039 registry.registerSuperNoSuchMethod(); | 1038 registry.registerSuperNoSuchMethod(); |
1040 } | 1039 } |
1041 return computeSuperAccessSemantics(node, target); | 1040 return computeSuperAccessSemantics(node, target); |
1042 } | 1041 } |
1043 | 1042 |
1044 /// Compute the [AccessSemantics] for accessing the name of [selector] on the | 1043 /// Compute the [AccessSemantics] for accessing the name of [selector] on the |
1045 /// super class. | 1044 /// super class. |
1046 /// | 1045 /// |
1047 /// If no matching super member is found and error is reported and | 1046 /// If no matching super member is found and error is reported and |
1048 /// `noSuchMethod` on `super` is registered. Furthermore, if [alternateName] | 1047 /// `noSuchMethod` on `super` is registered. Furthermore, if [alternateName] |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER, | 1095 MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER, |
1097 {'superclassName': setter.enclosingClass.name, | 1096 {'superclassName': setter.enclosingClass.name, |
1098 'name': setterSelector.name}); | 1097 'name': setterSelector.name}); |
1099 setterError = true; | 1098 setterError = true; |
1100 } | 1099 } |
1101 } | 1100 } |
1102 if (getterError) { | 1101 if (getterError) { |
1103 // We still need to register the invocation, because we might | 1102 // We still need to register the invocation, because we might |
1104 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. | 1103 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. |
1105 registry.registerDynamicUse( | 1104 registry.registerDynamicUse( |
1106 new UniverseSelector(getterSelector, null)); | 1105 new DynamicUse(getterSelector, null)); |
1107 } | 1106 } |
1108 if (setterError) { | 1107 if (setterError) { |
1109 // We still need to register the invocation, because we might | 1108 // We still need to register the invocation, because we might |
1110 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. | 1109 // call [:super.noSuchMethod:] which calls [JSInvocationMirror._invokeOn]. |
1111 registry.registerDynamicUse( | 1110 registry.registerDynamicUse( |
1112 new UniverseSelector(setterSelector, null)); | 1111 new DynamicUse(setterSelector, null)); |
1113 } | 1112 } |
1114 if (getterError || setterError) { | 1113 if (getterError || setterError) { |
1115 registry.registerSuperNoSuchMethod(); | 1114 registry.registerSuperNoSuchMethod(); |
1116 } | 1115 } |
1117 return computeCompoundSuperAccessSemantics( | 1116 return computeCompoundSuperAccessSemantics( |
1118 node, getter, setter, isIndex: isIndex); | 1117 node, getter, setter, isIndex: isIndex); |
1119 } | 1118 } |
1120 | 1119 |
1121 /// Resolve [node] as a subexpression that is _not_ the prefix of a member | 1120 /// Resolve [node] as a subexpression that is _not_ the prefix of a member |
1122 /// access. For instance `a` in `a + b`, as opposed to `a` in `a.b`. | 1121 /// access. For instance `a` in `a + b`, as opposed to `a` in `a.b`. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 semantics.element.declaration, | 1216 semantics.element.declaration, |
1218 selector.callStructure)); | 1217 selector.callStructure)); |
1219 } | 1218 } |
1220 // TODO(23998): Remove this when all information goes through | 1219 // TODO(23998): Remove this when all information goes through |
1221 // the [SendStructure]. | 1220 // the [SendStructure]. |
1222 registry.useElement(node, semantics.element); | 1221 registry.useElement(node, semantics.element); |
1223 } | 1222 } |
1224 } else { | 1223 } else { |
1225 ResolutionResult expressionResult = visitExpression(expression); | 1224 ResolutionResult expressionResult = visitExpression(expression); |
1226 semantics = const DynamicAccess.expression(); | 1225 semantics = const DynamicAccess.expression(); |
1227 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 1226 registry.registerDynamicUse(new DynamicUse(selector, null)); |
1228 | 1227 |
1229 if (expressionResult.isConstant) { | 1228 if (expressionResult.isConstant) { |
1230 bool isValidConstant; | 1229 bool isValidConstant; |
1231 ConstantExpression expressionConstant = expressionResult.constant; | 1230 ConstantExpression expressionConstant = expressionResult.constant; |
1232 DartType knownExpressionType = | 1231 DartType knownExpressionType = |
1233 expressionConstant.getKnownType(coreTypes); | 1232 expressionConstant.getKnownType(coreTypes); |
1234 switch (operator.kind) { | 1233 switch (operator.kind) { |
1235 case UnaryOperatorKind.COMPLEMENT: | 1234 case UnaryOperatorKind.COMPLEMENT: |
1236 isValidConstant = | 1235 isValidConstant = |
1237 knownExpressionType == coreTypes.intType; | 1236 knownExpressionType == coreTypes.intType; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 selector.callStructure)); | 1392 selector.callStructure)); |
1394 } | 1393 } |
1395 // TODO(23998): Remove this when all information goes through | 1394 // TODO(23998): Remove this when all information goes through |
1396 // the [SendStructure]. | 1395 // the [SendStructure]. |
1397 registry.useElement(node, semantics.element); | 1396 registry.useElement(node, semantics.element); |
1398 } | 1397 } |
1399 visitExpression(right); | 1398 visitExpression(right); |
1400 } else { | 1399 } else { |
1401 ResolutionResult leftResult = visitExpression(left); | 1400 ResolutionResult leftResult = visitExpression(left); |
1402 ResolutionResult rightResult = visitExpression(right); | 1401 ResolutionResult rightResult = visitExpression(right); |
1403 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 1402 registry.registerDynamicUse(new DynamicUse(selector, null)); |
1404 semantics = const DynamicAccess.expression(); | 1403 semantics = const DynamicAccess.expression(); |
1405 | 1404 |
1406 if (leftResult.isConstant && rightResult.isConstant) { | 1405 if (leftResult.isConstant && rightResult.isConstant) { |
1407 bool isValidConstant; | 1406 bool isValidConstant; |
1408 ConstantExpression leftConstant = leftResult.constant; | 1407 ConstantExpression leftConstant = leftResult.constant; |
1409 ConstantExpression rightConstant = rightResult.constant; | 1408 ConstantExpression rightConstant = rightResult.constant; |
1410 DartType knownLeftType = leftConstant.getKnownType(coreTypes); | 1409 DartType knownLeftType = leftConstant.getKnownType(coreTypes); |
1411 DartType knownRightType = rightConstant.getKnownType(coreTypes); | 1410 DartType knownRightType = rightConstant.getKnownType(coreTypes); |
1412 switch (operator.kind) { | 1411 switch (operator.kind) { |
1413 case BinaryOperatorKind.EQ: | 1412 case BinaryOperatorKind.EQ: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 assert(invariant(node, node.isCall, | 1527 assert(invariant(node, node.isCall, |
1529 message: "Unexpected expression: $node")); | 1528 message: "Unexpected expression: $node")); |
1530 Node expression = node.selector; | 1529 Node expression = node.selector; |
1531 visitExpression(expression); | 1530 visitExpression(expression); |
1532 CallStructure callStructure = | 1531 CallStructure callStructure = |
1533 resolveArguments(node.argumentsNode).callStructure; | 1532 resolveArguments(node.argumentsNode).callStructure; |
1534 Selector selector = callStructure.callSelector; | 1533 Selector selector = callStructure.callSelector; |
1535 // TODO(23998): Remove this when all information goes through the | 1534 // TODO(23998): Remove this when all information goes through the |
1536 // [SendStructure]. | 1535 // [SendStructure]. |
1537 registry.setSelector(node, selector); | 1536 registry.setSelector(node, selector); |
1538 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 1537 registry.registerDynamicUse(new DynamicUse(selector, null)); |
1539 registry.registerSendStructure(node, | 1538 registry.registerSendStructure(node, |
1540 new InvokeStructure(const DynamicAccess.expression(), selector)); | 1539 new InvokeStructure(const DynamicAccess.expression(), selector)); |
1541 return const NoneResult(); | 1540 return const NoneResult(); |
1542 } | 1541 } |
1543 | 1542 |
1544 /// Handle access of a property of [name] on `this`, like `this.name` and | 1543 /// Handle access of a property of [name] on `this`, like `this.name` and |
1545 /// `this.name()`, or `name` and `name()` in instance context. | 1544 /// `this.name()`, or `name` and `name()` in instance context. |
1546 ResolutionResult handleThisPropertyAccess(Send node, Name name) { | 1545 ResolutionResult handleThisPropertyAccess(Send node, Name name) { |
1547 AccessSemantics semantics = new DynamicAccess.thisProperty(name); | 1546 AccessSemantics semantics = new DynamicAccess.thisProperty(name); |
1548 return handleDynamicAccessSemantics(node, name, semantics); | 1547 return handleDynamicAccessSemantics(node, name, semantics); |
(...skipping 13 matching lines...) Expand all Loading... |
1562 if (node.isCall) { | 1561 if (node.isCall) { |
1563 CallStructure callStructure = | 1562 CallStructure callStructure = |
1564 resolveArguments(node.argumentsNode).callStructure; | 1563 resolveArguments(node.argumentsNode).callStructure; |
1565 Selector selector = callStructure.callSelector; | 1564 Selector selector = callStructure.callSelector; |
1566 // TODO(johnniwinther): Handle invalid this access as an | 1565 // TODO(johnniwinther): Handle invalid this access as an |
1567 // [AccessSemantics]. | 1566 // [AccessSemantics]. |
1568 AccessSemantics accessSemantics = checkThisAccess(node); | 1567 AccessSemantics accessSemantics = checkThisAccess(node); |
1569 if (accessSemantics == null) { | 1568 if (accessSemantics == null) { |
1570 accessSemantics = const DynamicAccess.thisAccess(); | 1569 accessSemantics = const DynamicAccess.thisAccess(); |
1571 registry.registerDynamicUse( | 1570 registry.registerDynamicUse( |
1572 new UniverseSelector(selector, null)); | 1571 new DynamicUse(selector, null)); |
1573 } | 1572 } |
1574 registry.registerSendStructure(node, | 1573 registry.registerSendStructure(node, |
1575 new InvokeStructure(accessSemantics, selector)); | 1574 new InvokeStructure(accessSemantics, selector)); |
1576 // TODO(23998): Remove this when all information goes through | 1575 // TODO(23998): Remove this when all information goes through |
1577 // the [SendStructure]. | 1576 // the [SendStructure]. |
1578 registry.setSelector(node, selector); | 1577 registry.setSelector(node, selector); |
1579 return const NoneResult(); | 1578 return const NoneResult(); |
1580 } else { | 1579 } else { |
1581 // TODO(johnniwinther): Handle get of `this` when it is a [Send] node. | 1580 // TODO(johnniwinther): Handle get of `this` when it is a [Send] node. |
1582 reporter.internalError( | 1581 reporter.internalError( |
(...skipping 21 matching lines...) Expand all Loading... |
1604 if (node.isCall) { | 1603 if (node.isCall) { |
1605 bool isIncompatibleInvoke = false; | 1604 bool isIncompatibleInvoke = false; |
1606 switch (semantics.kind) { | 1605 switch (semantics.kind) { |
1607 case AccessKind.SUPER_METHOD: | 1606 case AccessKind.SUPER_METHOD: |
1608 MethodElementX superMethod = semantics.element; | 1607 MethodElementX superMethod = semantics.element; |
1609 superMethod.computeType(resolution); | 1608 superMethod.computeType(resolution); |
1610 if (!callStructure.signatureApplies( | 1609 if (!callStructure.signatureApplies( |
1611 superMethod.functionSignature)) { | 1610 superMethod.functionSignature)) { |
1612 registry.registerThrowNoSuchMethod(); | 1611 registry.registerThrowNoSuchMethod(); |
1613 registry.registerDynamicUse( | 1612 registry.registerDynamicUse( |
1614 new UniverseSelector(selector, null)); | 1613 new DynamicUse(selector, null)); |
1615 registry.registerSuperNoSuchMethod(); | 1614 registry.registerSuperNoSuchMethod(); |
1616 isIncompatibleInvoke = true; | 1615 isIncompatibleInvoke = true; |
1617 } else { | 1616 } else { |
1618 registry.registerStaticUse( | 1617 registry.registerStaticUse( |
1619 new StaticUse.superInvoke(semantics.element, callStructure)); | 1618 new StaticUse.superInvoke(semantics.element, callStructure)); |
1620 } | 1619 } |
1621 break; | 1620 break; |
1622 case AccessKind.SUPER_FIELD: | 1621 case AccessKind.SUPER_FIELD: |
1623 case AccessKind.SUPER_FINAL_FIELD: | 1622 case AccessKind.SUPER_FINAL_FIELD: |
1624 case AccessKind.SUPER_GETTER: | 1623 case AccessKind.SUPER_GETTER: |
1625 registry.registerStaticUse( | 1624 registry.registerStaticUse( |
1626 new StaticUse.superGet(semantics.element)); | 1625 new StaticUse.superGet(semantics.element)); |
1627 selector = callStructure.callSelector; | 1626 selector = callStructure.callSelector; |
1628 registry.registerDynamicUse( | 1627 registry.registerDynamicUse( |
1629 new UniverseSelector(selector, null)); | 1628 new DynamicUse(selector, null)); |
1630 break; | 1629 break; |
1631 case AccessKind.SUPER_SETTER: | 1630 case AccessKind.SUPER_SETTER: |
1632 case AccessKind.UNRESOLVED_SUPER: | 1631 case AccessKind.UNRESOLVED_SUPER: |
1633 // NoSuchMethod registered in [computeSuperSemantics]. | 1632 // NoSuchMethod registered in [computeSuperSemantics]. |
1634 break; | 1633 break; |
1635 case AccessKind.INVALID: | 1634 case AccessKind.INVALID: |
1636 // 'super' is not allowed. | 1635 // 'super' is not allowed. |
1637 break; | 1636 break; |
1638 default: | 1637 default: |
1639 reporter.internalError( | 1638 reporter.internalError( |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 /// Handle dynamic access of [semantics]. | 2331 /// Handle dynamic access of [semantics]. |
2333 ResolutionResult handleDynamicAccessSemantics( | 2332 ResolutionResult handleDynamicAccessSemantics( |
2334 Send node, Name name, AccessSemantics semantics) { | 2333 Send node, Name name, AccessSemantics semantics) { |
2335 SendStructure sendStructure; | 2334 SendStructure sendStructure; |
2336 Selector selector; | 2335 Selector selector; |
2337 if (node.isCall) { | 2336 if (node.isCall) { |
2338 CallStructure callStructure = | 2337 CallStructure callStructure = |
2339 resolveArguments(node.argumentsNode).callStructure; | 2338 resolveArguments(node.argumentsNode).callStructure; |
2340 selector = new Selector.call(name, callStructure); | 2339 selector = new Selector.call(name, callStructure); |
2341 registry.registerDynamicUse( | 2340 registry.registerDynamicUse( |
2342 new UniverseSelector(selector, null)); | 2341 new DynamicUse(selector, null)); |
2343 sendStructure = new InvokeStructure(semantics, selector); | 2342 sendStructure = new InvokeStructure(semantics, selector); |
2344 } else { | 2343 } else { |
2345 assert(invariant(node, node.isPropertyAccess)); | 2344 assert(invariant(node, node.isPropertyAccess)); |
2346 selector = new Selector.getter(name); | 2345 selector = new Selector.getter(name); |
2347 registry.registerDynamicUse( | 2346 registry.registerDynamicUse( |
2348 new UniverseSelector(selector, null)); | 2347 new DynamicUse(selector, null)); |
2349 sendStructure = new GetStructure(semantics); | 2348 sendStructure = new GetStructure(semantics); |
2350 } | 2349 } |
2351 registry.registerSendStructure(node, sendStructure); | 2350 registry.registerSendStructure(node, sendStructure); |
2352 // TODO(23998): Remove this when all information goes through | 2351 // TODO(23998): Remove this when all information goes through |
2353 // the [SendStructure]. | 2352 // the [SendStructure]. |
2354 registry.setSelector(node, selector); | 2353 registry.setSelector(node, selector); |
2355 return const NoneResult(); | 2354 return const NoneResult(); |
2356 } | 2355 } |
2357 | 2356 |
2358 /// Handle dynamic update of [semantics]. | 2357 /// Handle dynamic update of [semantics]. |
2359 ResolutionResult handleDynamicUpdateSemantics( | 2358 ResolutionResult handleDynamicUpdateSemantics( |
2360 SendSet node, Name name, Element element, AccessSemantics semantics) { | 2359 SendSet node, Name name, Element element, AccessSemantics semantics) { |
2361 Selector getterSelector = new Selector.getter(name); | 2360 Selector getterSelector = new Selector.getter(name); |
2362 Selector setterSelector = new Selector.setter(name.setter); | 2361 Selector setterSelector = new Selector.setter(name.setter); |
2363 registry.registerDynamicUse( | 2362 registry.registerDynamicUse( |
2364 new UniverseSelector(setterSelector, null)); | 2363 new DynamicUse(setterSelector, null)); |
2365 if (node.isComplex) { | 2364 if (node.isComplex) { |
2366 registry.registerDynamicUse( | 2365 registry.registerDynamicUse( |
2367 new UniverseSelector(getterSelector, null)); | 2366 new DynamicUse(getterSelector, null)); |
2368 } | 2367 } |
2369 | 2368 |
2370 // TODO(23998): Remove these when elements are only accessed through the | 2369 // TODO(23998): Remove these when elements are only accessed through the |
2371 // send structure. | 2370 // send structure. |
2372 Element getter = element; | 2371 Element getter = element; |
2373 Element setter = element; | 2372 Element setter = element; |
2374 if (element != null && element.isAbstractField) { | 2373 if (element != null && element.isAbstractField) { |
2375 AbstractFieldElement abstractField = element; | 2374 AbstractFieldElement abstractField = element; |
2376 getter = abstractField.getter; | 2375 getter = abstractField.getter; |
2377 setter = abstractField.setter; | 2376 setter = abstractField.setter; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 | 2476 |
2478 /// Handle erroneous access of [element] of the given [semantics]. | 2477 /// Handle erroneous access of [element] of the given [semantics]. |
2479 ResolutionResult handleErroneousAccess( | 2478 ResolutionResult handleErroneousAccess( |
2480 Send node, Name name, AccessSemantics semantics) { | 2479 Send node, Name name, AccessSemantics semantics) { |
2481 SendStructure sendStructure; | 2480 SendStructure sendStructure; |
2482 Selector selector; | 2481 Selector selector; |
2483 if (node.isCall) { | 2482 if (node.isCall) { |
2484 CallStructure callStructure = | 2483 CallStructure callStructure = |
2485 resolveArguments(node.argumentsNode).callStructure; | 2484 resolveArguments(node.argumentsNode).callStructure; |
2486 selector = new Selector.call(name, callStructure); | 2485 selector = new Selector.call(name, callStructure); |
2487 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 2486 registry.registerDynamicUse(new DynamicUse(selector, null)); |
2488 sendStructure = new InvokeStructure(semantics, selector); | 2487 sendStructure = new InvokeStructure(semantics, selector); |
2489 } else { | 2488 } else { |
2490 assert(invariant(node, node.isPropertyAccess)); | 2489 assert(invariant(node, node.isPropertyAccess)); |
2491 selector = new Selector.getter(name); | 2490 selector = new Selector.getter(name); |
2492 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 2491 registry.registerDynamicUse(new DynamicUse(selector, null)); |
2493 sendStructure = new GetStructure(semantics); | 2492 sendStructure = new GetStructure(semantics); |
2494 } | 2493 } |
2495 // TODO(23998): Remove this when all information goes through | 2494 // TODO(23998): Remove this when all information goes through |
2496 // the [SendStructure]. | 2495 // the [SendStructure]. |
2497 registry.setSelector(node, selector); | 2496 registry.setSelector(node, selector); |
2498 registry.useElement(node, semantics.element); | 2497 registry.useElement(node, semantics.element); |
2499 registry.registerSendStructure(node, sendStructure); | 2498 registry.registerSendStructure(node, sendStructure); |
2500 return const NoneResult(); | 2499 return const NoneResult(); |
2501 } | 2500 } |
2502 | 2501 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 resolveArguments(node.argumentsNode).callStructure; | 2559 resolveArguments(node.argumentsNode).callStructure; |
2561 selector = new Selector.call(name, callStructure); | 2560 selector = new Selector.call(name, callStructure); |
2562 bool isIncompatibleInvoke = false; | 2561 bool isIncompatibleInvoke = false; |
2563 switch (semantics.kind) { | 2562 switch (semantics.kind) { |
2564 case AccessKind.LOCAL_FUNCTION: | 2563 case AccessKind.LOCAL_FUNCTION: |
2565 LocalFunctionElementX function = semantics.element; | 2564 LocalFunctionElementX function = semantics.element; |
2566 function.computeType(resolution); | 2565 function.computeType(resolution); |
2567 if (!callStructure.signatureApplies(function.functionSignature)) { | 2566 if (!callStructure.signatureApplies(function.functionSignature)) { |
2568 registry.registerThrowNoSuchMethod(); | 2567 registry.registerThrowNoSuchMethod(); |
2569 registry.registerDynamicUse( | 2568 registry.registerDynamicUse( |
2570 new UniverseSelector(selector, null)); | 2569 new DynamicUse(selector, null)); |
2571 isIncompatibleInvoke = true; | 2570 isIncompatibleInvoke = true; |
2572 } | 2571 } |
2573 break; | 2572 break; |
2574 case AccessKind.PARAMETER: | 2573 case AccessKind.PARAMETER: |
2575 case AccessKind.FINAL_PARAMETER: | 2574 case AccessKind.FINAL_PARAMETER: |
2576 case AccessKind.LOCAL_VARIABLE: | 2575 case AccessKind.LOCAL_VARIABLE: |
2577 case AccessKind.FINAL_LOCAL_VARIABLE: | 2576 case AccessKind.FINAL_LOCAL_VARIABLE: |
2578 selector = callStructure.callSelector; | 2577 selector = callStructure.callSelector; |
2579 registry.registerDynamicUse( | 2578 registry.registerDynamicUse( |
2580 new UniverseSelector(selector, null)); | 2579 new DynamicUse(selector, null)); |
2581 break; | 2580 break; |
2582 default: | 2581 default: |
2583 reporter.internalError(node, | 2582 reporter.internalError(node, |
2584 "Unexpected local access $semantics."); | 2583 "Unexpected local access $semantics."); |
2585 break; | 2584 break; |
2586 } | 2585 } |
2587 registry.registerSendStructure(node, | 2586 registry.registerSendStructure(node, |
2588 isIncompatibleInvoke | 2587 isIncompatibleInvoke |
2589 ? new IncompatibleInvokeStructure(semantics, selector) | 2588 ? new IncompatibleInvokeStructure(semantics, selector) |
2590 : new InvokeStructure(semantics, selector)); | 2589 : new InvokeStructure(semantics, selector)); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2733 | 2732 |
2734 bool isIncompatibleInvoke = false; | 2733 bool isIncompatibleInvoke = false; |
2735 switch (semantics.kind) { | 2734 switch (semantics.kind) { |
2736 case AccessKind.STATIC_METHOD: | 2735 case AccessKind.STATIC_METHOD: |
2737 case AccessKind.TOPLEVEL_METHOD: | 2736 case AccessKind.TOPLEVEL_METHOD: |
2738 MethodElement method = semantics.element; | 2737 MethodElement method = semantics.element; |
2739 method.computeType(resolution); | 2738 method.computeType(resolution); |
2740 if (!callStructure.signatureApplies(method.functionSignature)) { | 2739 if (!callStructure.signatureApplies(method.functionSignature)) { |
2741 registry.registerThrowNoSuchMethod(); | 2740 registry.registerThrowNoSuchMethod(); |
2742 registry.registerDynamicUse( | 2741 registry.registerDynamicUse( |
2743 new UniverseSelector(selector, null)); | 2742 new DynamicUse(selector, null)); |
2744 isIncompatibleInvoke = true; | 2743 isIncompatibleInvoke = true; |
2745 } else { | 2744 } else { |
2746 registry.registerStaticUse( | 2745 registry.registerStaticUse( |
2747 new StaticUse.staticInvoke(semantics.element, callStructure)); | 2746 new StaticUse.staticInvoke(semantics.element, callStructure)); |
2748 handleForeignCall(node, semantics.element, callStructure); | 2747 handleForeignCall(node, semantics.element, callStructure); |
2749 if (method == compiler.identicalFunction && | 2748 if (method == compiler.identicalFunction && |
2750 argumentsResult.isValidAsConstant) { | 2749 argumentsResult.isValidAsConstant) { |
2751 result = new ConstantResult(node, | 2750 result = new ConstantResult(node, |
2752 new IdenticalConstantExpression( | 2751 new IdenticalConstantExpression( |
2753 argumentsResult.argumentResults[0].constant, | 2752 argumentsResult.argumentResults[0].constant, |
2754 argumentsResult.argumentResults[1].constant)); | 2753 argumentsResult.argumentResults[1].constant)); |
2755 } | 2754 } |
2756 } | 2755 } |
2757 break; | 2756 break; |
2758 case AccessKind.STATIC_FIELD: | 2757 case AccessKind.STATIC_FIELD: |
2759 case AccessKind.FINAL_STATIC_FIELD: | 2758 case AccessKind.FINAL_STATIC_FIELD: |
2760 case AccessKind.STATIC_GETTER: | 2759 case AccessKind.STATIC_GETTER: |
2761 case AccessKind.TOPLEVEL_FIELD: | 2760 case AccessKind.TOPLEVEL_FIELD: |
2762 case AccessKind.FINAL_TOPLEVEL_FIELD: | 2761 case AccessKind.FINAL_TOPLEVEL_FIELD: |
2763 case AccessKind.TOPLEVEL_GETTER: | 2762 case AccessKind.TOPLEVEL_GETTER: |
2764 registry.registerStaticUse( | 2763 registry.registerStaticUse( |
2765 new StaticUse.staticGet(semantics.element)); | 2764 new StaticUse.staticGet(semantics.element)); |
2766 selector = callStructure.callSelector; | 2765 selector = callStructure.callSelector; |
2767 registry.registerDynamicUse( | 2766 registry.registerDynamicUse( |
2768 new UniverseSelector(selector, null)); | 2767 new DynamicUse(selector, null)); |
2769 break; | 2768 break; |
2770 case AccessKind.STATIC_SETTER: | 2769 case AccessKind.STATIC_SETTER: |
2771 case AccessKind.TOPLEVEL_SETTER: | 2770 case AccessKind.TOPLEVEL_SETTER: |
2772 case AccessKind.UNRESOLVED: | 2771 case AccessKind.UNRESOLVED: |
2773 registry.registerThrowNoSuchMethod(); | 2772 registry.registerThrowNoSuchMethod(); |
2774 member = reportAndCreateErroneousElement( | 2773 member = reportAndCreateErroneousElement( |
2775 node.selector, name.text, | 2774 node.selector, name.text, |
2776 MessageKind.CANNOT_RESOLVE_GETTER, const {}); | 2775 MessageKind.CANNOT_RESOLVE_GETTER, const {}); |
2777 break; | 2776 break; |
2778 default: | 2777 default: |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3138 Selector operatorSelector = | 3137 Selector operatorSelector = |
3139 new Selector.binaryOperator(operator.selectorName); | 3138 new Selector.binaryOperator(operator.selectorName); |
3140 | 3139 |
3141 // TODO(23998): Remove these when selectors are only accessed | 3140 // TODO(23998): Remove these when selectors are only accessed |
3142 // through the send structure. | 3141 // through the send structure. |
3143 registry.setGetterSelectorInComplexSendSet(node, getterSelector); | 3142 registry.setGetterSelectorInComplexSendSet(node, getterSelector); |
3144 registry.setSelector(node, setterSelector); | 3143 registry.setSelector(node, setterSelector); |
3145 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); | 3144 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); |
3146 | 3145 |
3147 registry.registerDynamicUse( | 3146 registry.registerDynamicUse( |
3148 new UniverseSelector(getterSelector, null)); | 3147 new DynamicUse(getterSelector, null)); |
3149 registry.registerDynamicUse( | 3148 registry.registerDynamicUse( |
3150 new UniverseSelector(setterSelector, null)); | 3149 new DynamicUse(setterSelector, null)); |
3151 registry.registerDynamicUse( | 3150 registry.registerDynamicUse( |
3152 new UniverseSelector(operatorSelector, null)); | 3151 new DynamicUse(operatorSelector, null)); |
3153 | 3152 |
3154 SendStructure sendStructure = node.isPrefix | 3153 SendStructure sendStructure = node.isPrefix |
3155 ? new IndexPrefixStructure(semantics, operator) | 3154 ? new IndexPrefixStructure(semantics, operator) |
3156 : new IndexPostfixStructure(semantics, operator); | 3155 : new IndexPostfixStructure(semantics, operator); |
3157 registry.registerSendStructure(node, sendStructure); | 3156 registry.registerSendStructure(node, sendStructure); |
3158 return const NoneResult(); | 3157 return const NoneResult(); |
3159 } else { | 3158 } else { |
3160 Node rhs = node.arguments.tail.head; | 3159 Node rhs = node.arguments.tail.head; |
3161 visitExpression(rhs); | 3160 visitExpression(rhs); |
3162 | 3161 |
3163 AssignmentOperator operator = AssignmentOperator.parse(operatorText); | 3162 AssignmentOperator operator = AssignmentOperator.parse(operatorText); |
3164 if (operator.kind == AssignmentOperatorKind.ASSIGN) { | 3163 if (operator.kind == AssignmentOperatorKind.ASSIGN) { |
3165 // `a[b] = c`. | 3164 // `a[b] = c`. |
3166 Selector setterSelector = new Selector.indexSet(); | 3165 Selector setterSelector = new Selector.indexSet(); |
3167 | 3166 |
3168 // TODO(23998): Remove this when selectors are only accessed | 3167 // TODO(23998): Remove this when selectors are only accessed |
3169 // through the send structure. | 3168 // through the send structure. |
3170 registry.setSelector(node, setterSelector); | 3169 registry.setSelector(node, setterSelector); |
3171 registry.registerDynamicUse( | 3170 registry.registerDynamicUse( |
3172 new UniverseSelector(setterSelector, null)); | 3171 new DynamicUse(setterSelector, null)); |
3173 | 3172 |
3174 SendStructure sendStructure = new IndexSetStructure(semantics); | 3173 SendStructure sendStructure = new IndexSetStructure(semantics); |
3175 registry.registerSendStructure(node, sendStructure); | 3174 registry.registerSendStructure(node, sendStructure); |
3176 return const NoneResult(); | 3175 return const NoneResult(); |
3177 } else { | 3176 } else { |
3178 // `a[b] += c`. | 3177 // `a[b] += c`. |
3179 Selector getterSelector = new Selector.index(); | 3178 Selector getterSelector = new Selector.index(); |
3180 Selector setterSelector = new Selector.indexSet(); | 3179 Selector setterSelector = new Selector.indexSet(); |
3181 Selector operatorSelector = | 3180 Selector operatorSelector = |
3182 new Selector.binaryOperator(operator.selectorName); | 3181 new Selector.binaryOperator(operator.selectorName); |
3183 | 3182 |
3184 // TODO(23998): Remove these when selectors are only accessed | 3183 // TODO(23998): Remove these when selectors are only accessed |
3185 // through the send structure. | 3184 // through the send structure. |
3186 registry.setGetterSelectorInComplexSendSet(node, getterSelector); | 3185 registry.setGetterSelectorInComplexSendSet(node, getterSelector); |
3187 registry.setSelector(node, setterSelector); | 3186 registry.setSelector(node, setterSelector); |
3188 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); | 3187 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); |
3189 | 3188 |
3190 registry.registerDynamicUse( | 3189 registry.registerDynamicUse( |
3191 new UniverseSelector(getterSelector, null)); | 3190 new DynamicUse(getterSelector, null)); |
3192 registry.registerDynamicUse( | 3191 registry.registerDynamicUse( |
3193 new UniverseSelector(setterSelector, null)); | 3192 new DynamicUse(setterSelector, null)); |
3194 registry.registerDynamicUse( | 3193 registry.registerDynamicUse( |
3195 new UniverseSelector(operatorSelector, null)); | 3194 new DynamicUse(operatorSelector, null)); |
3196 | 3195 |
3197 SendStructure sendStructure = | 3196 SendStructure sendStructure = |
3198 new CompoundIndexSetStructure(semantics, operator); | 3197 new CompoundIndexSetStructure(semantics, operator); |
3199 registry.registerSendStructure(node, sendStructure); | 3198 registry.registerSendStructure(node, sendStructure); |
3200 return const NoneResult(); | 3199 return const NoneResult(); |
3201 } | 3200 } |
3202 } | 3201 } |
3203 } | 3202 } |
3204 | 3203 |
3205 /// Handle super index operations like `super[a] = b`, `super[a] += b`, and | 3204 /// Handle super index operations like `super[a] = b`, `super[a] += b`, and |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3239 new StaticUse.superInvoke( | 3238 new StaticUse.superInvoke( |
3240 semantics.setter, setterSelector.callStructure)); | 3239 semantics.setter, setterSelector.callStructure)); |
3241 } | 3240 } |
3242 | 3241 |
3243 // TODO(23998): Remove these when elements are only accessed | 3242 // TODO(23998): Remove these when elements are only accessed |
3244 // through the send structure. | 3243 // through the send structure. |
3245 registry.useElement(node, semantics.setter); | 3244 registry.useElement(node, semantics.setter); |
3246 registry.useElement(node.selector, semantics.getter); | 3245 registry.useElement(node.selector, semantics.getter); |
3247 } | 3246 } |
3248 registry.registerDynamicUse( | 3247 registry.registerDynamicUse( |
3249 new UniverseSelector(operatorSelector, null)); | 3248 new DynamicUse(operatorSelector, null)); |
3250 | 3249 |
3251 SendStructure sendStructure = node.isPrefix | 3250 SendStructure sendStructure = node.isPrefix |
3252 ? new IndexPrefixStructure(semantics, operator) | 3251 ? new IndexPrefixStructure(semantics, operator) |
3253 : new IndexPostfixStructure(semantics, operator); | 3252 : new IndexPostfixStructure(semantics, operator); |
3254 registry.registerSendStructure(node, sendStructure); | 3253 registry.registerSendStructure(node, sendStructure); |
3255 return const NoneResult(); | 3254 return const NoneResult(); |
3256 } else { | 3255 } else { |
3257 Node rhs = node.arguments.tail.head; | 3256 Node rhs = node.arguments.tail.head; |
3258 visitExpression(rhs); | 3257 visitExpression(rhs); |
3259 | 3258 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3309 registry.useElement(node.selector, semantics.getter); | 3308 registry.useElement(node.selector, semantics.getter); |
3310 } | 3309 } |
3311 | 3310 |
3312 // TODO(23998): Remove these when selectors are only accessed | 3311 // TODO(23998): Remove these when selectors are only accessed |
3313 // through the send structure. | 3312 // through the send structure. |
3314 registry.setGetterSelectorInComplexSendSet(node, getterSelector); | 3313 registry.setGetterSelectorInComplexSendSet(node, getterSelector); |
3315 registry.setSelector(node, setterSelector); | 3314 registry.setSelector(node, setterSelector); |
3316 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); | 3315 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); |
3317 | 3316 |
3318 registry.registerDynamicUse( | 3317 registry.registerDynamicUse( |
3319 new UniverseSelector(operatorSelector, null)); | 3318 new DynamicUse(operatorSelector, null)); |
3320 | 3319 |
3321 SendStructure sendStructure = | 3320 SendStructure sendStructure = |
3322 new CompoundIndexSetStructure(semantics, operator); | 3321 new CompoundIndexSetStructure(semantics, operator); |
3323 registry.registerSendStructure(node, sendStructure); | 3322 registry.registerSendStructure(node, sendStructure); |
3324 return const NoneResult(); | 3323 return const NoneResult(); |
3325 } | 3324 } |
3326 } | 3325 } |
3327 } | 3326 } |
3328 | 3327 |
3329 /// Handle super index operations like `super.a = b`, `super.a += b`, and | 3328 /// Handle super index operations like `super.a = b`, `super.a += b`, and |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3411 node, setterSelector, alternateName: name); | 3410 node, setterSelector, alternateName: name); |
3412 switch (semantics.kind) { | 3411 switch (semantics.kind) { |
3413 case AccessKind.SUPER_FINAL_FIELD: | 3412 case AccessKind.SUPER_FINAL_FIELD: |
3414 reporter.reportWarningMessage( | 3413 reporter.reportWarningMessage( |
3415 node, | 3414 node, |
3416 MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER, | 3415 MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER, |
3417 {'name': name, | 3416 {'name': name, |
3418 'superclassName': semantics.setter.enclosingClass.name}); | 3417 'superclassName': semantics.setter.enclosingClass.name}); |
3419 // TODO(johnniwinther): This shouldn't be needed. | 3418 // TODO(johnniwinther): This shouldn't be needed. |
3420 registry.registerDynamicUse( | 3419 registry.registerDynamicUse( |
3421 new UniverseSelector(setterSelector, null)); | 3420 new DynamicUse(setterSelector, null)); |
3422 registry.registerSuperNoSuchMethod(); | 3421 registry.registerSuperNoSuchMethod(); |
3423 break; | 3422 break; |
3424 case AccessKind.SUPER_METHOD: | 3423 case AccessKind.SUPER_METHOD: |
3425 reporter.reportWarningMessage( | 3424 reporter.reportWarningMessage( |
3426 node, MessageKind.ASSIGNING_METHOD_IN_SUPER, | 3425 node, MessageKind.ASSIGNING_METHOD_IN_SUPER, |
3427 {'name': name, | 3426 {'name': name, |
3428 'superclassName': semantics.setter.enclosingClass.name}); | 3427 'superclassName': semantics.setter.enclosingClass.name}); |
3429 // TODO(johnniwinther): This shouldn't be needed. | 3428 // TODO(johnniwinther): This shouldn't be needed. |
3430 registry.registerDynamicUse( | 3429 registry.registerDynamicUse( |
3431 new UniverseSelector(setterSelector, null)); | 3430 new DynamicUse(setterSelector, null)); |
3432 registry.registerSuperNoSuchMethod(); | 3431 registry.registerSuperNoSuchMethod(); |
3433 break; | 3432 break; |
3434 case AccessKind.SUPER_FIELD: | 3433 case AccessKind.SUPER_FIELD: |
3435 case AccessKind.SUPER_SETTER: | 3434 case AccessKind.SUPER_SETTER: |
3436 registry.registerStaticUse( | 3435 registry.registerStaticUse( |
3437 new StaticUse.superSet(semantics.setter)); | 3436 new StaticUse.superSet(semantics.setter)); |
3438 break; | 3437 break; |
3439 default: | 3438 default: |
3440 break; | 3439 break; |
3441 } | 3440 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3474 registry.setGetterSelectorInComplexSendSet(node, getterSelector); | 3473 registry.setGetterSelectorInComplexSendSet(node, getterSelector); |
3475 registry.setSelector(node, setterSelector); | 3474 registry.setSelector(node, setterSelector); |
3476 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); | 3475 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); |
3477 | 3476 |
3478 // TODO(23998): Remove these when elements are only accessed | 3477 // TODO(23998): Remove these when elements are only accessed |
3479 // through the send structure. | 3478 // through the send structure. |
3480 registry.useElement(node, semantics.setter); | 3479 registry.useElement(node, semantics.setter); |
3481 registry.useElement(node.selector, semantics.getter); | 3480 registry.useElement(node.selector, semantics.getter); |
3482 | 3481 |
3483 registry.registerDynamicUse( | 3482 registry.registerDynamicUse( |
3484 new UniverseSelector(operatorSelector, null)); | 3483 new DynamicUse(operatorSelector, null)); |
3485 | 3484 |
3486 SendStructure sendStructure = node.isPrefix | 3485 SendStructure sendStructure = node.isPrefix |
3487 ? new PrefixStructure(semantics, operator) | 3486 ? new PrefixStructure(semantics, operator) |
3488 : new PostfixStructure(semantics, operator); | 3487 : new PostfixStructure(semantics, operator); |
3489 registry.registerSendStructure(node, sendStructure); | 3488 registry.registerSendStructure(node, sendStructure); |
3490 registry.registerIncDecOperation(); | 3489 registry.registerIncDecOperation(); |
3491 } else { | 3490 } else { |
3492 Node rhs = node.arguments.head; | 3491 Node rhs = node.arguments.head; |
3493 visitExpression(rhs); | 3492 visitExpression(rhs); |
3494 | 3493 |
(...skipping 21 matching lines...) Expand all Loading... |
3516 registry.useElement(node, semantics.setter); | 3515 registry.useElement(node, semantics.setter); |
3517 registry.useElement(node.selector, semantics.getter); | 3516 registry.useElement(node.selector, semantics.getter); |
3518 | 3517 |
3519 // TODO(23998): Remove these when selectors are only accessed | 3518 // TODO(23998): Remove these when selectors are only accessed |
3520 // through the send structure. | 3519 // through the send structure. |
3521 registry.setGetterSelectorInComplexSendSet(node, getterSelector); | 3520 registry.setGetterSelectorInComplexSendSet(node, getterSelector); |
3522 registry.setSelector(node, setterSelector); | 3521 registry.setSelector(node, setterSelector); |
3523 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); | 3522 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); |
3524 | 3523 |
3525 registry.registerDynamicUse( | 3524 registry.registerDynamicUse( |
3526 new UniverseSelector(operatorSelector, null)); | 3525 new DynamicUse(operatorSelector, null)); |
3527 | 3526 |
3528 SendStructure sendStructure; | 3527 SendStructure sendStructure; |
3529 if (operator.kind == AssignmentOperatorKind.IF_NULL) { | 3528 if (operator.kind == AssignmentOperatorKind.IF_NULL) { |
3530 sendStructure = new SetIfNullStructure(semantics); | 3529 sendStructure = new SetIfNullStructure(semantics); |
3531 } else { | 3530 } else { |
3532 sendStructure = new CompoundStructure(semantics, operator); | 3531 sendStructure = new CompoundStructure(semantics, operator); |
3533 } | 3532 } |
3534 registry.registerSendStructure(node, sendStructure); | 3533 registry.registerSendStructure(node, sendStructure); |
3535 } | 3534 } |
3536 } | 3535 } |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4242 node.target, MessageKind.INVALID_CONTINUE); | 4241 node.target, MessageKind.INVALID_CONTINUE); |
4243 } | 4242 } |
4244 label.setContinueTarget(); | 4243 label.setContinueTarget(); |
4245 registry.useLabel(node, label); | 4244 registry.useLabel(node, label); |
4246 } | 4245 } |
4247 registry.registerTargetOf(node, target); | 4246 registry.registerTargetOf(node, target); |
4248 return const NoneResult(); | 4247 return const NoneResult(); |
4249 } | 4248 } |
4250 | 4249 |
4251 registerImplicitInvocation(Selector selector) { | 4250 registerImplicitInvocation(Selector selector) { |
4252 registry.registerDynamicUse(new UniverseSelector(selector, null)); | 4251 registry.registerDynamicUse(new DynamicUse(selector, null)); |
4253 } | 4252 } |
4254 | 4253 |
4255 ResolutionResult visitAsyncForIn(AsyncForIn node) { | 4254 ResolutionResult visitAsyncForIn(AsyncForIn node) { |
4256 registry.registerAsyncForIn(node); | 4255 registry.registerAsyncForIn(node); |
4257 registry.setCurrentSelector(node, Selectors.current); | 4256 registry.setCurrentSelector(node, Selectors.current); |
4258 registry.registerDynamicUse( | 4257 registry.registerDynamicUse( |
4259 new UniverseSelector(Selectors.current, null)); | 4258 new DynamicUse(Selectors.current, null)); |
4260 registry.setMoveNextSelector(node, Selectors.moveNext); | 4259 registry.setMoveNextSelector(node, Selectors.moveNext); |
4261 registry.registerDynamicUse( | 4260 registry.registerDynamicUse( |
4262 new UniverseSelector(Selectors.moveNext, null)); | 4261 new DynamicUse(Selectors.moveNext, null)); |
4263 | 4262 |
4264 visit(node.expression); | 4263 visit(node.expression); |
4265 | 4264 |
4266 Scope blockScope = new BlockScope(scope); | 4265 Scope blockScope = new BlockScope(scope); |
4267 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); | 4266 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); |
4268 visitLoopBodyIn(node, node.body, blockScope); | 4267 visitLoopBodyIn(node, node.body, blockScope); |
4269 return const NoneResult(); | 4268 return const NoneResult(); |
4270 } | 4269 } |
4271 | 4270 |
4272 ResolutionResult visitSyncForIn(SyncForIn node) { | 4271 ResolutionResult visitSyncForIn(SyncForIn node) { |
4273 registry.registerSyncForIn(node); | 4272 registry.registerSyncForIn(node); |
4274 registry.setIteratorSelector(node, Selectors.iterator); | 4273 registry.setIteratorSelector(node, Selectors.iterator); |
4275 registry.registerDynamicUse( | 4274 registry.registerDynamicUse( |
4276 new UniverseSelector(Selectors.iterator, null)); | 4275 new DynamicUse(Selectors.iterator, null)); |
4277 registry.setCurrentSelector(node, Selectors.current); | 4276 registry.setCurrentSelector(node, Selectors.current); |
4278 registry.registerDynamicUse( | 4277 registry.registerDynamicUse( |
4279 new UniverseSelector(Selectors.current, null)); | 4278 new DynamicUse(Selectors.current, null)); |
4280 registry.setMoveNextSelector(node, Selectors.moveNext); | 4279 registry.setMoveNextSelector(node, Selectors.moveNext); |
4281 registry.registerDynamicUse( | 4280 registry.registerDynamicUse( |
4282 new UniverseSelector(Selectors.moveNext, null)); | 4281 new DynamicUse(Selectors.moveNext, null)); |
4283 | 4282 |
4284 visit(node.expression); | 4283 visit(node.expression); |
4285 | 4284 |
4286 Scope blockScope = new BlockScope(scope); | 4285 Scope blockScope = new BlockScope(scope); |
4287 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); | 4286 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); |
4288 visitLoopBodyIn(node, node.body, blockScope); | 4287 visitLoopBodyIn(node, node.body, blockScope); |
4289 return const NoneResult(); | 4288 return const NoneResult(); |
4290 } | 4289 } |
4291 | 4290 |
4292 void visitForInDeclaredIdentifierIn( | 4291 void visitForInDeclaredIdentifierIn( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4336 loopVariable = registry.getDefinition(identifier); | 4335 loopVariable = registry.getDefinition(identifier); |
4337 } | 4336 } |
4338 } else { | 4337 } else { |
4339 reporter.reportErrorMessage( | 4338 reporter.reportErrorMessage( |
4340 declaration, MessageKind.INVALID_FOR_IN); | 4339 declaration, MessageKind.INVALID_FOR_IN); |
4341 } | 4340 } |
4342 if (loopVariableSelector != null) { | 4341 if (loopVariableSelector != null) { |
4343 registry.setSelector(declaration, loopVariableSelector); | 4342 registry.setSelector(declaration, loopVariableSelector); |
4344 if (loopVariable == null || loopVariable.isInstanceMember) { | 4343 if (loopVariable == null || loopVariable.isInstanceMember) { |
4345 registry.registerDynamicUse( | 4344 registry.registerDynamicUse( |
4346 new UniverseSelector(loopVariableSelector, null)); | 4345 new DynamicUse(loopVariableSelector, null)); |
4347 } else if (loopVariable.isStatic || loopVariable.isTopLevel) { | 4346 } else if (loopVariable.isStatic || loopVariable.isTopLevel) { |
4348 registry.registerStaticUse( | 4347 registry.registerStaticUse( |
4349 new StaticUse.staticSet(loopVariable.declaration)); | 4348 new StaticUse.staticSet(loopVariable.declaration)); |
4350 } | 4349 } |
4351 } else { | 4350 } else { |
4352 // The selector may only be null if we reported an error. | 4351 // The selector may only be null if we reported an error. |
4353 assert(invariant(declaration, compiler.compilationFailed)); | 4352 assert(invariant(declaration, compiler.compilationFailed)); |
4354 } | 4353 } |
4355 if (loopVariable != null) { | 4354 if (loopVariable != null) { |
4356 // loopVariable may be null if it could not be resolved. | 4355 // loopVariable may be null if it could not be resolved. |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4759 } | 4758 } |
4760 return const NoneResult(); | 4759 return const NoneResult(); |
4761 } | 4760 } |
4762 } | 4761 } |
4763 | 4762 |
4764 /// Looks up [name] in [scope] and unwraps the result. | 4763 /// Looks up [name] in [scope] and unwraps the result. |
4765 Element lookupInScope(DiagnosticReporter reporter, Node node, | 4764 Element lookupInScope(DiagnosticReporter reporter, Node node, |
4766 Scope scope, String name) { | 4765 Scope scope, String name) { |
4767 return Elements.unwrap(scope.lookup(name), reporter, node); | 4766 return Elements.unwrap(scope.lookup(name), reporter, node); |
4768 } | 4767 } |
OLD | NEW |