| 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 library kernel.transformations.mixin_full_resolution; | 4 library kernel.transformations.mixin_full_resolution; |
| 5 | 5 |
| 6 import '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import '../class_hierarchy.dart'; | 7 import '../class_hierarchy.dart'; |
| 8 import '../clone.dart'; | 8 import '../clone.dart'; |
| 9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
| 10 import '../type_algebra.dart'; | 10 import '../type_algebra.dart'; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return new DirectMethodInvocation( | 264 return new DirectMethodInvocation( |
| 265 new ThisExpression(), noSuchMethod, new Arguments([invocationPrime])) | 265 new ThisExpression(), noSuchMethod, new Arguments([invocationPrime])) |
| 266 ..fileOffset = node.fileOffset; | 266 ..fileOffset = node.fileOffset; |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 /// Creates an "new _InvocationMirror(...)" invocation. | 270 /// Creates an "new _InvocationMirror(...)" invocation. |
| 271 ConstructorInvocation _createInvocation(String methodName, | 271 ConstructorInvocation _createInvocation(String methodName, |
| 272 Arguments callArguments, bool isSuperInvocation, Expression receiver) { | 272 Arguments callArguments, bool isSuperInvocation, Expression receiver) { |
| 273 if (_invocationMirrorConstructor == null) { | 273 if (_invocationMirrorConstructor == null) { |
| 274 Class clazz = coreTypes.getCoreClass('dart:core', '_InvocationMirror'); | 274 Class clazz = coreTypes.getClass('dart:core', '_InvocationMirror'); |
| 275 _invocationMirrorConstructor = clazz.constructors[0]; | 275 _invocationMirrorConstructor = clazz.constructors[0]; |
| 276 } | 276 } |
| 277 | 277 |
| 278 // The _InvocationMirror constructor takes the following arguments: | 278 // The _InvocationMirror constructor takes the following arguments: |
| 279 // * Method name (a string). | 279 // * Method name (a string). |
| 280 // * An arguments descriptor - a list consisting of: | 280 // * An arguments descriptor - a list consisting of: |
| 281 // - number of arguments (including receiver). | 281 // - number of arguments (including receiver). |
| 282 // - number of positional arguments (including receiver). | 282 // - number of positional arguments (including receiver). |
| 283 // - pairs (2 entries in the list) of | 283 // - pairs (2 entries in the list) of |
| 284 // * named arguments name. | 284 // * named arguments name. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 308 new Arguments([ | 308 new Arguments([ |
| 309 new StringLiteral(methodName), | 309 new StringLiteral(methodName), |
| 310 _fixedLengthList(argumentsDescriptor), | 310 _fixedLengthList(argumentsDescriptor), |
| 311 _fixedLengthList(arguments), | 311 _fixedLengthList(arguments), |
| 312 new BoolLiteral(isSuperInvocation) | 312 new BoolLiteral(isSuperInvocation) |
| 313 ])); | 313 ])); |
| 314 } | 314 } |
| 315 | 315 |
| 316 /// Create a fixed length list containing given expressions. | 316 /// Create a fixed length list containing given expressions. |
| 317 Expression _fixedLengthList(List<Expression> list) { | 317 Expression _fixedLengthList(List<Expression> list) { |
| 318 if (_listFrom == null) { | 318 _listFrom ??= coreTypes.getMember('dart:core', 'List', 'from'); |
| 319 Class clazz = coreTypes.getCoreClass('dart:core', 'List'); | |
| 320 _listFrom = clazz.procedures.firstWhere((c) => c.name.name == "from"); | |
| 321 } | |
| 322 return new StaticInvocation( | 319 return new StaticInvocation( |
| 323 _listFrom, | 320 _listFrom, |
| 324 new Arguments([new ListLiteral(list)], | 321 new Arguments([new ListLiteral(list)], |
| 325 named: [new NamedExpression("growable", new BoolLiteral(false))], | 322 named: [new NamedExpression("growable", new BoolLiteral(false))], |
| 326 types: [const DynamicType()])); | 323 types: [const DynamicType()])); |
| 327 } | 324 } |
| 328 | 325 |
| 329 /// Check that a call to the targetFunction is legal given the arguments. | 326 /// Check that a call to the targetFunction is legal given the arguments. |
| 330 /// | 327 /// |
| 331 /// I.e. check that the number of positional parameters and the names of the | 328 /// I.e. check that the number of positional parameters and the names of the |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return null; | 368 return null; |
| 372 } | 369 } |
| 373 } | 370 } |
| 374 | 371 |
| 375 throw new Exception( | 372 throw new Exception( |
| 376 'Could not find a generative constructor named "${constructor.name}" ' | 373 'Could not find a generative constructor named "${constructor.name}" ' |
| 377 'in lookup class "${lookupClass.name}"!'); | 374 'in lookup class "${lookupClass.name}"!'); |
| 378 } | 375 } |
| 379 } | 376 } |
| 380 } | 377 } |
| OLD | NEW |