| 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 simple_types_inferrer; | 5 library simple_types_inferrer; |
| 6 | 6 |
| 7 import '../closure.dart' show ClosureClassMap, ClosureScope; | 7 import '../closure.dart' show ClosureClassMap, ClosureScope; |
| 8 import '../dart_types.dart' | 8 import '../dart_types.dart' |
| 9 show DartType, InterfaceType, FunctionType, TypeKind; | 9 show DartType, InterfaceType, FunctionType, TypeKind; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 } | 972 } |
| 973 ArgumentsTypes arguments = analyzeArguments(node.arguments); | 973 ArgumentsTypes arguments = analyzeArguments(node.arguments); |
| 974 if (visitingInitializers) { | 974 if (visitingInitializers) { |
| 975 if (ast.Initializers.isConstructorRedirect(node)) { | 975 if (ast.Initializers.isConstructorRedirect(node)) { |
| 976 isConstructorRedirect = true; | 976 isConstructorRedirect = true; |
| 977 } else if (ast.Initializers.isSuperConstructorCall(node)) { | 977 } else if (ast.Initializers.isSuperConstructorCall(node)) { |
| 978 seenSuperConstructorCall = true; | 978 seenSuperConstructorCall = true; |
| 979 analyzeSuperConstructorCall(element, arguments); | 979 analyzeSuperConstructorCall(element, arguments); |
| 980 } | 980 } |
| 981 } | 981 } |
| 982 // If we are looking at a new expression on a forwarding factory, |
| 983 // we have to forward the call to the effective target of the |
| 984 // factory. |
| 985 if (element.isFactoryConstructor) { |
| 986 ConstructorElement constructor = element; |
| 987 if (constructor.isRedirectingFactory) { |
| 988 element = constructor.effectiveTarget.implementation; |
| 989 } |
| 990 } |
| 982 if (element.isForeign(compiler.backend)) { | 991 if (element.isForeign(compiler.backend)) { |
| 983 return handleForeignSend(node); | 992 return handleForeignSend(node); |
| 984 } | 993 } |
| 985 Selector selector = elements.getSelector(node); | 994 Selector selector = elements.getSelector(node); |
| 986 // In erroneous code the number of arguments in the selector might not | 995 // In erroneous code the number of arguments in the selector might not |
| 987 // match the function element. | 996 // match the function element. |
| 988 // TODO(polux): return nonNullEmpty and check it doesn't break anything | 997 // TODO(polux): return nonNullEmpty and check it doesn't break anything |
| 989 if (!selector.applies(element, compiler.world)) return types.dynamicType; | 998 if (!selector.applies(element, compiler.world)) return types.dynamicType; |
| 990 | 999 |
| 991 T returnType = handleStaticSend(node, selector, element, arguments); | 1000 T returnType = handleStaticSend(node, selector, element, arguments); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 return inferrer.registerCalledClosure( | 1117 return inferrer.registerCalledClosure( |
| 1109 node, selector, closure, outermostElement, arguments, | 1118 node, selector, closure, outermostElement, arguments, |
| 1110 sideEffects, inLoop); | 1119 sideEffects, inLoop); |
| 1111 } | 1120 } |
| 1112 } | 1121 } |
| 1113 | 1122 |
| 1114 T handleStaticSend(ast.Node node, | 1123 T handleStaticSend(ast.Node node, |
| 1115 Selector selector, | 1124 Selector selector, |
| 1116 Element element, | 1125 Element element, |
| 1117 ArgumentsTypes arguments) { | 1126 ArgumentsTypes arguments) { |
| 1127 assert(!element.isFactoryConstructor || |
| 1128 !(element as ConstructorElement).isRedirectingFactory); |
| 1118 // Erroneous elements may be unresolved, for example missing getters. | 1129 // Erroneous elements may be unresolved, for example missing getters. |
| 1119 if (Elements.isUnresolved(element)) return types.dynamicType; | 1130 if (Elements.isUnresolved(element)) return types.dynamicType; |
| 1120 // TODO(herhut): should we follow redirecting constructors here? We would | 1131 // TODO(herhut): should we follow redirecting constructors here? We would |
| 1121 // need to pay attention of the constructor is pointing to an erroneous | 1132 // need to pay attention of the constructor is pointing to an erroneous |
| 1122 // element. | 1133 // element. |
| 1123 return inferrer.registerCalledElement( | 1134 return inferrer.registerCalledElement( |
| 1124 node, selector, outermostElement, element, arguments, | 1135 node, selector, outermostElement, element, arguments, |
| 1125 sideEffects, inLoop); | 1136 sideEffects, inLoop); |
| 1126 } | 1137 } |
| 1127 | 1138 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 } | 1299 } |
| 1289 | 1300 |
| 1290 handlePlainAssignment(identifier, element, selector, | 1301 handlePlainAssignment(identifier, element, selector, |
| 1291 receiverType, currentType, | 1302 receiverType, currentType, |
| 1292 node.expression); | 1303 node.expression); |
| 1293 return handleLoop(node, () { | 1304 return handleLoop(node, () { |
| 1294 visit(node.body); | 1305 visit(node.body); |
| 1295 }); | 1306 }); |
| 1296 } | 1307 } |
| 1297 } | 1308 } |
| OLD | NEW |