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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/interceptor_emitter.dart

Issue 2693163002: Split backend implementation of EnqueuerListener (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.js_emitter.full_emitter.interceptor_emitter; 5 library dart2js.js_emitter.full_emitter.interceptor_emitter;
6 6
7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
8 import '../../elements/entities.dart'; 8 import '../../elements/entities.dart';
9 import '../../js/js.dart' as jsAst; 9 import '../../js/js.dart' as jsAst;
10 import '../../js/js.dart' show js; 10 import '../../js/js.dart' show js;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 * If [JSInvocationMirror._invokeOn] has been compiled, emit all the 80 * If [JSInvocationMirror._invokeOn] has been compiled, emit all the
81 * possible selector names that are intercepted into the 81 * possible selector names that are intercepted into the
82 * [interceptedNames] embedded global. The implementation of 82 * [interceptedNames] embedded global. The implementation of
83 * [_invokeOn] will use it to determine whether it should call the 83 * [_invokeOn] will use it to determine whether it should call the
84 * method with an extra parameter. 84 * method with an extra parameter.
85 */ 85 */
86 jsAst.ObjectInitializer generateInterceptedNamesSet() { 86 jsAst.ObjectInitializer generateInterceptedNamesSet() {
87 // We could also generate the list of intercepted names at 87 // We could also generate the list of intercepted names at
88 // runtime, by running through the subclasses of Interceptor 88 // runtime, by running through the subclasses of Interceptor
89 // (which can easily be identified). 89 // (which can easily be identified).
90 if (!backend.hasInvokeOnSupport) return null; 90 if (!backend.backendUsage.isInvokeOnUsed) return null;
91 91
92 Iterable<jsAst.Name> invocationNames = interceptorInvocationNames.toList() 92 Iterable<jsAst.Name> invocationNames = interceptorInvocationNames.toList()
93 ..sort(); 93 ..sort();
94 ; 94 ;
95 List<jsAst.Property> properties = invocationNames.map((jsAst.Name name) { 95 List<jsAst.Property> properties = invocationNames.map((jsAst.Name name) {
96 return new jsAst.Property(js.quoteName(name), js.number(1)); 96 return new jsAst.Property(js.quoteName(name), js.number(1));
97 }).toList(); 97 }).toList();
98 return new jsAst.ObjectInitializer(properties, isOneLiner: true); 98 return new jsAst.ObjectInitializer(properties, isOneLiner: true);
99 } 99 }
100 100
101 /** 101 /**
102 * Emit initializer for `typeToInterceptorMap` data structure used by 102 * Emit initializer for `typeToInterceptorMap` data structure used by
103 * `findInterceptorForType`. See declaration of `typeToInterceptor` in 103 * `findInterceptorForType`. See declaration of `typeToInterceptor` in
104 * `interceptors.dart`. 104 * `interceptors.dart`.
105 */ 105 */
106 jsAst.Statement buildTypeToInterceptorMap(Program program) { 106 jsAst.Statement buildTypeToInterceptorMap(Program program) {
107 jsAst.Expression array = program.typeToInterceptorMap; 107 jsAst.Expression array = program.typeToInterceptorMap;
108 if (array == null) return js.comment("Empty type-to-interceptor map."); 108 if (array == null) return js.comment("Empty type-to-interceptor map.");
109 109
110 jsAst.Expression typeToInterceptorMap = emitter 110 jsAst.Expression typeToInterceptorMap = emitter
111 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); 111 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP);
112 return js.statement('# = #', [typeToInterceptorMap, array]); 112 return js.statement('# = #', [typeToInterceptorMap, array]);
113 } 113 }
114 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698