OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 cps_ir.optimization.inline; | 5 library cps_ir.optimization.inline; |
6 | 6 |
7 import 'package:js_ast/js_ast.dart' as js; | 7 import 'package:js_ast/js_ast.dart' as js; |
8 | 8 |
9 import '../dart_types.dart' show DartType, GenericType; | 9 import '../dart_types.dart' show DartType, GenericType; |
10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 node.selector.callStructure.getOrderedNamedArguments(); | 370 node.selector.callStructure.getOrderedNamedArguments(); |
371 List<String> outgoingNames = <String>[]; | 371 List<String> outgoingNames = <String>[]; |
372 int nameIndex = 0; | 372 int nameIndex = 0; |
373 signature.orderedOptionalParameters.forEach((ParameterElement formal) { | 373 signature.orderedOptionalParameters.forEach((ParameterElement formal) { |
374 if (nameIndex < incomingNames.length && | 374 if (nameIndex < incomingNames.length && |
375 formal.name == incomingNames[nameIndex]) { | 375 formal.name == incomingNames[nameIndex]) { |
376 arguments.add(parameters[parameterIndex++]); | 376 arguments.add(parameters[parameterIndex++]); |
377 ++nameIndex; | 377 ++nameIndex; |
378 } else { | 378 } else { |
379 Constant defaultValue = cps.makeConstant( | 379 Constant defaultValue = cps.makeConstant( |
380 backend.constants.getConstantValueForVariable(formal)); | 380 backend.constants.getConstantValue(formal.constant)); |
381 defaultValue.type = typeSystem.getParameterType(formal); | 381 defaultValue.type = typeSystem.getParameterType(formal); |
382 arguments.add(defaultValue); | 382 arguments.add(defaultValue); |
383 } | 383 } |
384 outgoingNames.add(formal.name); | 384 outgoingNames.add(formal.name); |
385 }); | 385 }); |
386 newCallStructure = | 386 newCallStructure = |
387 new CallStructure(signature.parameterCount, outgoingNames); | 387 new CallStructure(signature.parameterCount, outgoingNames); |
388 } else { | 388 } else { |
389 signature.forEachOptionalParameter((ParameterElement formal) { | 389 signature.forEachOptionalParameter((ParameterElement formal) { |
390 if (parameterIndex < parameters.length) { | 390 if (parameterIndex < parameters.length) { |
391 arguments.add(parameters[parameterIndex++]); | 391 arguments.add(parameters[parameterIndex++]); |
392 } else { | 392 } else { |
393 Constant defaultValue = cps.makeConstant( | 393 Constant defaultValue = cps.makeConstant( |
394 backend.constants.getConstantValueForVariable(formal)); | 394 backend.constants.getConstantValue(formal.constant)); |
395 defaultValue.type = typeSystem.getParameterType(formal); | 395 defaultValue.type = typeSystem.getParameterType(formal); |
396 arguments.add(defaultValue); | 396 arguments.add(defaultValue); |
397 } | 397 } |
398 }); | 398 }); |
399 newCallStructure = new CallStructure(signature.parameterCount); | 399 newCallStructure = new CallStructure(signature.parameterCount); |
400 } | 400 } |
401 | 401 |
402 Selector newSelector = new Selector( | 402 Selector newSelector = new Selector( |
403 node.selector.kind, node.selector.memberName, newCallStructure); | 403 node.selector.kind, node.selector.memberName, newCallStructure); |
404 Primitive result = cps.invokeMethod( | 404 Primitive result = cps.invokeMethod( |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 (enclosingClass == backend.helpers.jsNumberClass || | 604 (enclosingClass == backend.helpers.jsNumberClass || |
605 enclosingClass == backend.helpers.jsDoubleClass || | 605 enclosingClass == backend.helpers.jsDoubleClass || |
606 enclosingClass == backend.helpers.jsIntClass)) { | 606 enclosingClass == backend.helpers.jsIntClass)) { |
607 // These should be handled by operator specialization. | 607 // These should be handled by operator specialization. |
608 return true; | 608 return true; |
609 } | 609 } |
610 if (target == backend.helpers.stringInterpolationHelper) return true; | 610 if (target == backend.helpers.stringInterpolationHelper) return true; |
611 return false; | 611 return false; |
612 } | 612 } |
613 } | 613 } |
OLD | NEW |