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

Unified Diff: frog/leg/universe.dart

Issue 9316026: Support named arguments for dynamic calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | « frog/leg/ssa/js_names.dart ('k') | tests/language/language-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/universe.dart
===================================================================
--- frog/leg/universe.dart (revision 3781)
+++ frog/leg/universe.dart (working copy)
@@ -79,7 +79,8 @@
const Selector(SelectorKind.INDEX, 2);
static final Selector GETTER_AND_SETTER =
const Selector(SelectorKind.SETTER, 1);
- static final Selector INVOCATION_0 = const Invocation(0);
+ static final Selector INVOCATION_0 =
+ const Selector(SelectorKind.INVOCATION, 0);
bool applies(Compiler compiler, FunctionElement element) {
FunctionParameters parameters = element.computeParameters(compiler);
@@ -132,15 +133,42 @@
&& namedArguments.length == other.namedArguments.length
&& sameNames(namedArguments, other.namedArguments);
}
+
+ List<SourceString> getOrderedNamedArguments() => namedArguments;
+
+ String toString() => '$argumentCount';
}
class Invocation extends Selector {
final List<SourceString> namedArguments;
+ List<SourceString> orderedNamedArguments;
int get namedArgumentCount() => namedArguments.length;
int get positionalArgumentCount() => argumentCount - namedArgumentCount;
- const Invocation(
- int argumentCount,
- [List<SourceString> this.namedArguments = const <SourceString>[]])
- : super(SelectorKind.INVOCATION, argumentCount);
+ Invocation(int argumentCount,
+ [List<SourceString> names = const <SourceString>[]])
+ : super(SelectorKind.INVOCATION, argumentCount),
+ namedArguments = names,
+ orderedNamedArguments = const <SourceString>[];
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer();
+ for (SourceString name in orderedNamedArguments) {
+ buffer.add('\$$name');
+ }
+ return '$argumentCount$buffer';
+ }
+
+ List<SourceString> getOrderedNamedArguments() {
+ if (namedArguments.isEmpty()) return namedArguments;
+ // We use the empty const List as a sentinel.
+ if (!orderedNamedArguments.isEmpty()) return namedArguments;
+
+ List<SourceString> list = new List<SourceString>.from(namedArguments);
+ list.sort((SourceString first, SourceString second) {
+ return first.stringValue.compareTo(second.stringValue);
+ });
+ orderedNamedArguments = list;
+ return orderedNamedArguments;
+ }
}
« no previous file with comments | « frog/leg/ssa/js_names.dart ('k') | tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698