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

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
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,32 @@
&& namedArguments.length == other.namedArguments.length
&& sameNames(namedArguments, other.namedArguments);
}
+
+ void set orderedNamedArguments(List<SourceString> other) {
+ // It's ok to ignore [other] if it's empty because this type of
+ // selector should not have any named arguments.
+ assert(other.isEmpty());
+ }
+
+ 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> this.namedArguments = const <SourceString>[]])
+ : super(SelectorKind.INVOCATION, argumentCount),
+ orderedNamedArguments = const <SourceString>[];
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer();
+ for (SourceString name in orderedNamedArguments) {
+ buffer.add('\$$name');
+ }
+ return '$argumentCount$buffer';
+ }
}

Powered by Google App Engine
This is Rietveld 408576698