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

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart

Issue 833623003: dart2js: Merge intercepted names map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: replace TODO with comment. Created 5 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: pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
index a33b9c6e7312f41f923d95b50b40598027c8ed77..d82370826371809531b8a8aaf73d98bdf3369729 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart
@@ -62,31 +62,25 @@ class InterceptorEmitter extends CodeEmitterHelper {
/**
* If [JSInvocationMirror._invokeOn] has been compiled, emit all the
* possible selector names that are intercepted into the
- * [interceptedNames] top-level variable. The implementation of
+ * [interceptedNames] embedded global. The implementation of
* [_invokeOn] will use it to determine whether it should call the
* method with an extra parameter.
*/
- void emitInterceptedNames(CodeBuffer buffer) {
- // TODO(ahe): We should not generate the list of intercepted names at
- // compile time, it can be generated automatically at runtime given
- // subclasses of Interceptor (which can easily be identified).
- if (!compiler.enabledInvokeOn) return;
-
- // TODO(ahe): We should roll this into
- // [emitStaticNonFinalFieldInitializations].
- String name = backend.namer.getNameOfGlobalField(backend.interceptedNames);
+ jsAst.ObjectInitializer generateInterceptedNamesSet() {
+ // We could also generate the list of intercepted names at
+ // runtime, by running through the subclasses of Interceptor
+ // (which can easily be identified).
+ if (!compiler.enabledInvokeOn) return null;
int index = 0;
- var invocationNames = interceptorInvocationNames.toList()..sort();
- List<jsAst.Expression> elements = invocationNames.map(js.string).toList();
- jsAst.ArrayInitializer array =
- new jsAst.ArrayInitializer(elements);
-
- jsAst.Expression assignment =
- js('${emitter.isolateProperties}.# = #', [name, array]);
-
- buffer.write(jsAst.prettyPrint(assignment, compiler));
- buffer.write(N);
+ List<String> invocationNames = interceptorInvocationNames.toList()..sort();
+ List<jsAst.Property> properties =
+ new List<jsAst.Property>(invocationNames.length);
+ for (int i = 0; i < invocationNames.length; i++) {
+ String name = invocationNames[i];
+ properties[i] = new jsAst.Property(js.string(name), js.number(1));
+ }
+ return new jsAst.ObjectInitializer(properties, isOneLiner: true);
}
/**

Powered by Google App Engine
This is Rietveld 408576698