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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 17450005: Include named parameters in reflection names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | « no previous file | dart/tests/lib/mirrors/get_symbol_name_no_such_method_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
index 6a1eaf46026472cd08cfaa6e74f09b75fc6e2891..a6b48d4b2cfb79780d85254e1bb5146491f4a1d6 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
@@ -1228,18 +1228,32 @@ class CodeEmitterTask extends CompilerTask {
|| elementOrSelector.isConstructor()) {
int requiredParameterCount;
int optionalParameterCount;
+ String namedArguments = '';
bool isConstructor;
if (elementOrSelector is Selector) {
- requiredParameterCount = elementOrSelector.argumentCount;
+ Selector selector = elementOrSelector;
+ requiredParameterCount = selector.argumentCount;
optionalParameterCount = 0;
isConstructor = false;
+ namedArguments = namedParametersAsReflectionNames(selector);
} else {
FunctionElement function = elementOrSelector;
requiredParameterCount = function.requiredParameterCount(compiler);
optionalParameterCount = function.optionalParameterCount(compiler);
isConstructor = function.isConstructor();
+ FunctionSignature signature = function.computeSignature(compiler);
+ if (signature.optionalParametersAreNamed) {
+ Selector selector = new Selector.call(
+ function.name,
+ function.getLibrary(),
+ requiredParameterCount,
+ optionalParameters.map((e) => e.name).toList());
+ namedArguments = namedParametersAsReflectionNames(selector);
+ }
}
- String suffix = '$name:$requiredParameterCount:$optionalParameterCount';
+ String suffix =
+ '$name:$requiredParameterCount:$optionalParameterCount'
+ '$namedArguments';
return (isConstructor) ? 'new $suffix' : suffix;
}
Element element = elementOrSelector;
@@ -1250,6 +1264,13 @@ class CodeEmitterTask extends CompilerTask {
element, 'Do not know how to reflect on this $element');
}
+ String namedParametersAsReflectionNames(Selector selector) {
+ if (selector.orderedNamedArguments.isEmpty) return '';
+ String names =
+ selector.orderedNamedArguments.map((x) => x.slowToString()).join(':');
+ return ':$names';
+ }
+
/**
* Documentation wanted -- johnniwinther
*
« no previous file with comments | « no previous file | dart/tests/lib/mirrors/get_symbol_name_no_such_method_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698