OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 universe; | 5 library universe; |
6 | 6 |
7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
8 import '../dart2jslib.dart'; | 8 import '../dart2jslib.dart'; |
9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
10 import '../types/types.dart'; | 10 import '../types/types.dart'; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 } | 490 } |
491 | 491 |
492 bool applies(Element element, World world) { | 492 bool applies(Element element, World world) { |
493 if (!sameNameHack(element, world)) return false; | 493 if (!sameNameHack(element, world)) return false; |
494 return appliesUnnamed(element, world); | 494 return appliesUnnamed(element, world); |
495 } | 495 } |
496 | 496 |
497 /** | 497 /** |
498 * Returns a `List` with the evaluated arguments in the normalized order. | 498 * Returns a `List` with the evaluated arguments in the normalized order. |
499 * | 499 * |
500 * [compileArgument] is a function that returns a compiled version | |
501 * of an argument located in [arguments]. | |
502 * | |
floitsch
2014/11/27 15:57:27
I don't like this change.
We shouldn't compile arg
sigurdm
2014/11/28 09:24:24
They are all compiled anyways.
| |
503 * [compileDefaultValue] is a function that returns a compiled constant | 500 * [compileDefaultValue] is a function that returns a compiled constant |
504 * of an optional argument that is not in [arguments]. | 501 * of an optional argument that is not in [compiledArguments]. |
505 * | 502 * |
506 * Precondition: `this.applies(element, world)`. | 503 * Precondition: `this.applies(element, world)`. |
507 * | 504 * |
508 * Invariant: [element] must be the implementation element. | 505 * Invariant: [element] must be the implementation element. |
509 */ | 506 */ |
510 /*<S, T>*/ List/*<T>*/ makeArgumentsList( | 507 /*<S, T>*/ List/*<T>*/ makeArgumentsList( |
511 List/*<S>*/ arguments, | |
512 FunctionElement element, | 508 FunctionElement element, |
513 /*T*/ compileArgument(/*S*/ argument), | 509 List/*<T>*/ compiledArguments, |
514 /*T*/ compileDefaultValue(ParameterElement element)) { | 510 /*T*/ compileDefaultValue(ParameterElement element)) { |
515 assert(invariant(element, element.isImplementation)); | 511 assert(invariant(element, element.isImplementation)); |
516 List/*<T>*/ result = new List(); | 512 List/*<T>*/ result = new List(); |
517 FunctionSignature parameters = element.functionSignature; | 513 FunctionSignature parameters = element.functionSignature; |
518 int i = 0; | 514 int i = 0; |
519 parameters.forEachRequiredParameter((ParameterElement element) { | 515 parameters.forEachRequiredParameter((ParameterElement element) { |
520 result.add(compileArgument(arguments[i])); | 516 result.add(compiledArguments[i]); |
521 ++i; | 517 ++i; |
522 }); | 518 }); |
523 | 519 |
524 if (!parameters.optionalParametersAreNamed) { | 520 if (!parameters.optionalParametersAreNamed) { |
525 parameters.forEachOptionalParameter((ParameterElement element) { | 521 parameters.forEachOptionalParameter((ParameterElement element) { |
526 if (i < arguments.length) { | 522 if (i < compiledArguments.length) { |
527 result.add(compileArgument(arguments[i])); | 523 result.add(compiledArguments[i]); |
528 ++i; | 524 ++i; |
529 } else { | 525 } else { |
530 result.add(compileDefaultValue(element)); | 526 result.add(compileDefaultValue(element)); |
531 } | 527 } |
532 }); | 528 }); |
533 } else { | 529 } else { |
534 // Visit named arguments and add them into a temporary list. | 530 // Visit named arguments and add them into a temporary list. |
535 List compiledNamedArguments = []; | 531 List compiledNamedArguments = []; |
536 for (; i < arguments.length; ++i) { | 532 for (; i < compiledArguments.length; ++i) { |
537 compiledNamedArguments.add(compileArgument(arguments[i])); | 533 compiledNamedArguments.add(compiledArguments[i]); |
538 } | 534 } |
539 // Iterate over the optional parameters of the signature, and try to | 535 // Iterate over the optional parameters of the signature, and try to |
540 // find them in [compiledNamedArguments]. If found, we use the | 536 // find them in [compiledNamedArguments]. If found, we use the |
541 // value in the temporary list, otherwise the default value. | 537 // value in the temporary list, otherwise the default value. |
542 parameters.orderedOptionalParameters | 538 parameters.orderedOptionalParameters |
543 .forEach((ParameterElement element) { | 539 .forEach((ParameterElement element) { |
544 int foundIndex = namedArguments.indexOf(element.name); | 540 int foundIndex = namedArguments.indexOf(element.name); |
545 if (foundIndex != -1) { | 541 if (foundIndex != -1) { |
546 result.add(compiledNamedArguments[foundIndex]); | 542 result.add(compiledNamedArguments[foundIndex]); |
547 } else { | 543 } else { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 | 846 |
851 Selector extendIfReachesAll(Compiler compiler) { | 847 Selector extendIfReachesAll(Compiler compiler) { |
852 bool canReachAll = compiler.enabledInvokeOn | 848 bool canReachAll = compiler.enabledInvokeOn |
853 && mask.needsNoSuchMethodHandling(this, compiler.world); | 849 && mask.needsNoSuchMethodHandling(this, compiler.world); |
854 return canReachAll | 850 return canReachAll |
855 ? new TypedSelector( | 851 ? new TypedSelector( |
856 compiler.typesTask.dynamicType, this, compiler.world) | 852 compiler.typesTask.dynamicType, this, compiler.world) |
857 : this; | 853 : this; |
858 } | 854 } |
859 } | 855 } |
OLD | NEW |