| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 inferrer_visitor; | 5 library inferrer_visitor; |
| 6 | 6 |
| 7 import 'dart:collection' show IterableMixin; | 7 import 'dart:collection' show IterableMixin; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 if (_thisType != null) return _thisType; | 951 if (_thisType != null) return _thisType; |
| 952 ClassElement cls = outermostElement.enclosingClass; | 952 ClassElement cls = outermostElement.enclosingClass; |
| 953 ClosedWorld closedWorld = compiler.closedWorld; | 953 ClosedWorld closedWorld = compiler.closedWorld; |
| 954 if (closedWorld.isUsedAsMixin(cls)) { | 954 if (closedWorld.isUsedAsMixin(cls)) { |
| 955 return _thisType = types.nonNullSubtype(cls); | 955 return _thisType = types.nonNullSubtype(cls); |
| 956 } else { | 956 } else { |
| 957 return _thisType = types.nonNullSubclass(cls); | 957 return _thisType = types.nonNullSubclass(cls); |
| 958 } | 958 } |
| 959 } | 959 } |
| 960 | 960 |
| 961 T _superType; | |
| 962 T get superType { | |
| 963 if (_superType != null) return _superType; | |
| 964 return _superType = | |
| 965 types.nonNullExact(outermostElement.enclosingClass.superclass); | |
| 966 } | |
| 967 | |
| 968 @override | 961 @override |
| 969 T visitThisGet(Identifier node, _) { | 962 T visitThisGet(Identifier node, _) { |
| 970 return thisType; | 963 return thisType; |
| 971 } | 964 } |
| 972 | 965 |
| 973 T visitIdentifier(Identifier node) { | 966 T visitIdentifier(Identifier node) { |
| 974 if (node.isThis()) { | 967 if (node.isThis()) { |
| 975 return thisType; | 968 return thisType; |
| 976 } else if (node.isSuper()) { | 969 } else if (node.isSuper()) { |
| 977 return superType; | 970 return internalError(node, 'Unexpected expression $node.'); |
| 978 } else { | 971 } else { |
| 979 Element element = elements[node]; | 972 Element element = elements[node]; |
| 980 if (Elements.isLocal(element)) { | 973 if (Elements.isLocal(element)) { |
| 981 LocalElement local = element; | 974 LocalElement local = element; |
| 982 return locals.use(local); | 975 return locals.use(local); |
| 983 } | 976 } |
| 984 return null; | 977 return null; |
| 985 } | 978 } |
| 986 } | 979 } |
| 987 | 980 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 return type; | 1477 return type; |
| 1485 } | 1478 } |
| 1486 | 1479 |
| 1487 T visitCascade(Cascade node) { | 1480 T visitCascade(Cascade node) { |
| 1488 // Ignore the result of the cascade send and return the type of the cascade | 1481 // Ignore the result of the cascade send and return the type of the cascade |
| 1489 // receiver. | 1482 // receiver. |
| 1490 visit(node.expression); | 1483 visit(node.expression); |
| 1491 return cascadeReceiverStack.removeLast(); | 1484 return cascadeReceiverStack.removeLast(); |
| 1492 } | 1485 } |
| 1493 } | 1486 } |
| OLD | NEW |