Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: pkg/compiler/lib/src/universe/universe.dart

Issue 879483005: Revert "dart2js cps: Handle optional parameters in builder." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_basic_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/universe/universe.dart
diff --git a/pkg/compiler/lib/src/universe/universe.dart b/pkg/compiler/lib/src/universe/universe.dart
index 3deffcba75cd27966bafcbcc8b0126afc809a713..a7ddbb03bd91dbda5eafd2af2d45e2c0c780f12d 100644
--- a/pkg/compiler/lib/src/universe/universe.dart
+++ b/pkg/compiler/lib/src/universe/universe.dart
@@ -506,7 +506,49 @@ class Selector {
*
* Invariant: [element] must be the implementation element.
*/
- /*<T>*/ List/*<T>*/ makeArgumentsList(
+ /*<S, T>*/ List/*<T>*/ makeArgumentsList(
+ FunctionElement element,
+ List/*<T>*/ compiledArguments,
+ /*T*/ compileDefaultValue(ParameterElement element)) {
+ assert(invariant(element, element.isImplementation));
+ List/*<T>*/ result = new List();
+ FunctionSignature parameters = element.functionSignature;
+ int i = 0;
+ parameters.forEachRequiredParameter((ParameterElement element) {
+ result.add(compiledArguments[i]);
+ ++i;
+ });
+
+ if (!parameters.optionalParametersAreNamed) {
+ parameters.forEachOptionalParameter((ParameterElement element) {
+ if (i < compiledArguments.length) {
+ result.add(compiledArguments[i]);
+ ++i;
+ } else {
+ result.add(compileDefaultValue(element));
+ }
+ });
+ } else {
+ int offset = i;
+ // Iterate over the optional parameters of the signature, and try to
+ // find them in [compiledNamedArguments]. If found, we use the
+ // value in the temporary list, otherwise the default value.
+ parameters.orderedOptionalParameters
+ .forEach((ParameterElement element) {
+ int foundIndex = namedArguments.indexOf(element.name);
+ if (foundIndex != -1) {
+ result.add(compiledArguments[offset + foundIndex]);
+ } else {
+ result.add(compileDefaultValue(element));
+ }
+ });
+ }
+ return result;
+ }
+
+ /// This is a version of [makeArgumentsList] that works for a `Link`
+ /// representation of arguments.
+ /*<T>*/ List/*<T>*/ makeArgumentsList2(
Link<Node> arguments,
FunctionElement element,
/*T*/ compileArgument(Node argument),
@@ -551,6 +593,7 @@ class Selector {
return result;
}
+
/**
* Fills [list] with the arguments in the order expected by
* [callee], and where [caller] is a synthesized element
@@ -618,10 +661,10 @@ class Selector {
namedParameters);
if (!selector.applies(callee, world)) return false;
- list.addAll(selector.makeArgumentsList(nodes,
- callee,
- internalCompileArgument,
- compileConstant));
+ list.addAll(selector.makeArgumentsList2(nodes,
+ callee,
+ internalCompileArgument,
+ compileConstant));
return true;
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_basic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698