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

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

Issue 11264005: InvocationMirror implemented in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check JSInvocationMirror.invokeOn instead of InvocationMirror.invokeOn. Created 8 years, 2 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: lib/compiler/implementation/js_backend/emitter.dart
diff --git a/lib/compiler/implementation/js_backend/emitter.dart b/lib/compiler/implementation/js_backend/emitter.dart
index 3074aaf3e142096e2c86fe34df90cb4cee0c327e..98075c6b7063c8e514423cc3ba4bffd6e05ff9eb 100644
--- a/lib/compiler/implementation/js_backend/emitter.dart
+++ b/lib/compiler/implementation/js_backend/emitter.dart
@@ -1266,8 +1266,8 @@ $classesCollector.$mangledName = {'':
// Do not generate no such method handlers if there is no class.
if (compiler.codegenWorld.instantiatedClasses.isEmpty) return;
- String noSuchMethodName =
- namer.publicInstanceMethodNameByArity(Compiler.NO_SUCH_METHOD, 2);
+ String noSuchMethodName = namer.publicInstanceMethodNameByArity(
+ Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT);
// Keep track of the JavaScript names we've already added so we
// do not introduce duplicates (bad for code size).
@@ -1292,14 +1292,36 @@ $classesCollector.$mangledName = {'':
}
CodeBuffer generateMethod(String methodName, Selector selector) {
ahe 2012/10/29 12:14:05 Could you rename this function while you're at it?
+ // Values match JSInvocationMirror in js-helper library.
+ const int METHOD = 0;
+ const int GETTER = 1;
+ const int SETTER = 2;
+ int type = METHOD;
ahe 2012/10/29 12:14:05 In a compiler, type means something else. Please f
+ if (selector.isGetter()) {
+ type = GETTER;
+ } else if (selector.isSetter()) {
+ type = SETTER;
+ }
CodeBuffer args = new CodeBuffer();
for (int i = 0; i < selector.argumentCount; i++) {
if (i != 0) args.add(', ');
args.add('\$$i');
}
+ CodeBuffer argNames = new CodeBuffer();
+ List<SourceString> names = selector.getOrderedNamedArguments();
+ for (int i = 0; i < names.length; i++) {
+ if (i != 0) argNames.add(', ');
+ argNames.add('"');
+ argNames.add(names[i].slowToString());
+ argNames.add('"');
+ }
+ String internalName = namer.instanceMethodInvocationName(
+ selector.library, new SourceString(methodName), selector);
CodeBuffer buffer = new CodeBuffer();
buffer.add('function($args) {\n');
- buffer.add(' return this.$noSuchMethodName("$methodName", [$args]);\n');
+ buffer.add(' return this.$noSuchMethodName('
ahe 2012/10/29 12:14:05 Notice that $noSuchMethodName is string interpolat
+ '\$.createInvocationMirror("$methodName", "$internalName",'
ahe 2012/10/29 12:14:05 The same should be done here. The namer needs to h
+ ' $type, [$args], [$argNames]));\n');
buffer.add(' }');
return buffer;
}

Powered by Google App Engine
This is Rietveld 408576698