Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
| 6 * This library is capable of producing linked summaries from unlinked | 6 * This library is capable of producing linked summaries from unlinked |
| 7 * ones (or prelinked ones). It functions by building a miniature | 7 * ones (or prelinked ones). It functions by building a miniature |
| 8 * element model to represent the contents of the summaries, and then | 8 * element model to represent the contents of the summaries, and then |
| 9 * scanning the element model to gather linked information and adding | 9 * scanning the element model to gather linked information and adding |
| 10 * it to the summary data structures. | 10 * it to the summary data structures. |
| (...skipping 3226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3237 int numPositional = unlinkedConst.ints[intPtr++]; | 3237 int numPositional = unlinkedConst.ints[intPtr++]; |
| 3238 // TODO(paulberry): don't just pop the args; use their types | 3238 // TODO(paulberry): don't just pop the args; use their types |
| 3239 // to infer the type of type arguments. | 3239 // to infer the type of type arguments. |
| 3240 stack.length -= numNamed + numPositional; | 3240 stack.length -= numNamed + numPositional; |
| 3241 strPtr += numNamed; | 3241 strPtr += numNamed; |
| 3242 refPtr++; | 3242 refPtr++; |
| 3243 // TODO(paulberry): implement. | 3243 // TODO(paulberry): implement. |
| 3244 stack.add(DynamicTypeImpl.instance); | 3244 stack.add(DynamicTypeImpl.instance); |
| 3245 break; | 3245 break; |
| 3246 case UnlinkedConstOperation.invokeMethod: | 3246 case UnlinkedConstOperation.invokeMethod: |
| 3247 strPtr++; | |
| 3248 int numNamed = unlinkedConst.ints[intPtr++]; | 3247 int numNamed = unlinkedConst.ints[intPtr++]; |
| 3249 int numPositional = unlinkedConst.ints[intPtr++]; | 3248 int numPositional = unlinkedConst.ints[intPtr++]; |
| 3250 // TODO(paulberry): don't just pop the args; use their types | 3249 Map<String, DartType> namedArgTypes = <String, DartType>{}; |
| 3251 // to infer the type of type arguments. | 3250 List<DartType> namedArgTypeList = popList(numNamed); |
| 3252 stack.length -= numNamed + numPositional; | 3251 for (int i = 0; i < numNamed; i++) { |
| 3253 strPtr += numNamed; | 3252 String name = unlinkedConst.strings[strPtr++]; |
| 3254 stack.removeLast(); | 3253 DartType type = namedArgTypeList[i]; |
| 3255 // TODO(paulberry): implement. | 3254 namedArgTypes[name] = type; |
| 3256 stack.add(DynamicTypeImpl.instance); | 3255 } |
| 3256 List<DartType> positionalArgTypes = popList(numPositional); | |
| 3257 String methodName = unlinkedConst.strings[strPtr++]; | |
| 3258 DartType target = stack.removeLast(); | |
| 3259 stack.add(() { | |
| 3260 if (target is InterfaceType) { | |
| 3261 MethodElement method = | |
| 3262 target.lookUpMethod(methodName, libraryElement); | |
| 3263 DartType rawMethodType = method?.type; | |
| 3264 TypeSystem ts = linker.typeSystem; | |
| 3265 if (rawMethodType is FunctionType && | |
| 3266 rawMethodType.typeFormals.isNotEmpty && | |
|
Paul Berry
2016/04/09 12:04:29
This means we won't handle non-generic cases. Sug
scheglov
2016/04/10 01:29:21
Thank you, fixed.
| |
| 3267 ts is StrongTypeSystemImpl) { | |
| 3268 List<DartType> paramTypes = <DartType>[]; | |
| 3269 List<DartType> argTypes = <DartType>[]; | |
| 3270 for (int i = 0, length = numPositional; i < length; i++) { | |
| 3271 ParameterElement parameter = rawMethodType.parameters[i]; | |
| 3272 if (parameter != null) { | |
| 3273 paramTypes.add(parameter.type); | |
| 3274 argTypes.add(positionalArgTypes[i]); | |
| 3275 } | |
| 3276 } | |
| 3277 Map<String, DartType> namedParameterTypes = rawMethodType.name dParameterTypes; | |
| 3278 namedArgTypes.forEach((String name, DartType argType) { | |
| 3279 DartType parameterType = namedParameterTypes[name]; | |
| 3280 if (parameterType != null) { | |
| 3281 paramTypes.add(parameterType); | |
| 3282 argTypes.add(argType); | |
| 3283 } | |
| 3284 }); | |
| 3285 FunctionType inferred = ts.inferGenericFunctionCall( | |
| 3286 typeProvider, rawMethodType, paramTypes, argTypes, null); | |
| 3287 return inferred.returnType; | |
| 3288 } | |
| 3289 } | |
| 3290 return DynamicTypeImpl.instance; | |
| 3291 }()); | |
| 3257 break; | 3292 break; |
| 3258 case UnlinkedConstOperation.cascadeSectionBegin: | 3293 case UnlinkedConstOperation.cascadeSectionBegin: |
| 3259 stack.add(stack.last); | 3294 stack.add(stack.last); |
| 3260 break; | 3295 break; |
| 3261 case UnlinkedConstOperation.cascadeSectionEnd: | 3296 case UnlinkedConstOperation.cascadeSectionEnd: |
| 3262 stack.removeLast(); | 3297 stack.removeLast(); |
| 3263 break; | 3298 break; |
| 3264 case UnlinkedConstOperation.typeCast: | 3299 case UnlinkedConstOperation.typeCast: |
| 3265 stack.removeLast(); | 3300 stack.removeLast(); |
| 3266 DartType type = getNextTypeRef(); | 3301 DartType type = getNextTypeRef(); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3680 List<int> implicitFunctionTypeIndices) => | 3715 List<int> implicitFunctionTypeIndices) => |
| 3681 DynamicTypeImpl.instance; | 3716 DynamicTypeImpl.instance; |
| 3682 | 3717 |
| 3683 ReferenceableElementForLink getContainedName(String name) { | 3718 ReferenceableElementForLink getContainedName(String name) { |
| 3684 return new NonstaticMemberElementForLink(_constNode); | 3719 return new NonstaticMemberElementForLink(_constNode); |
| 3685 } | 3720 } |
| 3686 | 3721 |
| 3687 @override | 3722 @override |
| 3688 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3723 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3689 } | 3724 } |
| OLD | NEW |