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

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

Issue 2871583002: Pass InterceptorData through ResolutionWorldBuilder and access it through ClosedWorld (Closed)
Patch Set: Created 3 years, 7 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;
11 import '../../world.dart' show ClosedWorld; 11 import '../../world.dart' show ClosedWorld;
12 import '../js_emitter.dart' hide Emitter, EmitterFactory; 12 import '../js_emitter.dart' hide Emitter, EmitterFactory;
13 import '../model.dart'; 13 import '../model.dart';
14 import 'emitter.dart'; 14 import 'emitter.dart';
15 15
16 class InterceptorEmitter extends CodeEmitterHelper { 16 class InterceptorEmitter extends CodeEmitterHelper {
17 final ClosedWorld closedWorld; 17 final ClosedWorld closedWorld;
18 final Set<jsAst.Name> interceptorInvocationNames = new Set<jsAst.Name>(); 18 final Set<jsAst.Name> interceptorInvocationNames = new Set<jsAst.Name>();
19 19
20 InterceptorEmitter(this.closedWorld); 20 InterceptorEmitter(this.closedWorld);
21 21
22 void recordMangledNameOfMemberMethod(MemberEntity member, jsAst.Name name) { 22 void recordMangledNameOfMemberMethod(MemberEntity member, jsAst.Name name) {
23 if (backend.interceptorData.isInterceptedMethod(member)) { 23 if (closedWorld.interceptorData.isInterceptedMethod(member)) {
24 interceptorInvocationNames.add(name); 24 interceptorInvocationNames.add(name);
25 } 25 }
26 } 26 }
27 27
28 jsAst.Expression buildGetInterceptorMethod( 28 jsAst.Expression buildGetInterceptorMethod(
29 jsAst.Name key, Set<ClassEntity> classes) { 29 jsAst.Name key, Set<ClassEntity> classes) {
30 InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator( 30 InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator(
31 compiler.options, 31 compiler.options,
32 compiler.commonElements, 32 compiler.commonElements,
33 backend.emitter, 33 backend.emitter,
34 backend.nativeCodegenEnqueuer, 34 backend.nativeCodegenEnqueuer,
35 backend.constants, 35 backend.constants,
36 namer, 36 namer,
37 backend.interceptorData,
38 backend.oneShotInterceptorData, 37 backend.oneShotInterceptorData,
39 backend.customElementsCodegenAnalysis, 38 backend.customElementsCodegenAnalysis,
40 compiler.codegenWorldBuilder, 39 compiler.codegenWorldBuilder,
41 closedWorld); 40 closedWorld);
42 jsAst.Expression function = 41 jsAst.Expression function =
43 stubGenerator.generateGetInterceptorMethod(classes); 42 stubGenerator.generateGetInterceptorMethod(classes);
44 43
45 return function; 44 return function;
46 } 45 }
47 46
(...skipping 26 matching lines...) Expand all
74 Iterable<jsAst.Name> names = 73 Iterable<jsAst.Name> names =
75 backend.oneShotInterceptorData.oneShotInterceptorNames; 74 backend.oneShotInterceptorData.oneShotInterceptorNames;
76 75
77 InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator( 76 InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator(
78 compiler.options, 77 compiler.options,
79 compiler.commonElements, 78 compiler.commonElements,
80 backend.emitter, 79 backend.emitter,
81 backend.nativeCodegenEnqueuer, 80 backend.nativeCodegenEnqueuer,
82 backend.constants, 81 backend.constants,
83 namer, 82 namer,
84 backend.interceptorData,
85 backend.oneShotInterceptorData, 83 backend.oneShotInterceptorData,
86 backend.customElementsCodegenAnalysis, 84 backend.customElementsCodegenAnalysis,
87 compiler.codegenWorldBuilder, 85 compiler.codegenWorldBuilder,
88 closedWorld); 86 closedWorld);
89 String globalObject = namer 87 String globalObject = namer
90 .globalObjectForLibrary(backend.commonElements.interceptorsLibrary); 88 .globalObjectForLibrary(backend.commonElements.interceptorsLibrary);
91 for (jsAst.Name name in names) { 89 for (jsAst.Name name in names) {
92 jsAst.Expression function = 90 jsAst.Expression function =
93 stubGenerator.generateOneShotInterceptor(name); 91 stubGenerator.generateOneShotInterceptor(name);
94 parts.add(js.statement('${globalObject}.# = #', [name, function])); 92 parts.add(js.statement('${globalObject}.# = #', [name, function]));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 */ 124 */
127 jsAst.Statement buildTypeToInterceptorMap(Program program) { 125 jsAst.Statement buildTypeToInterceptorMap(Program program) {
128 jsAst.Expression array = program.typeToInterceptorMap; 126 jsAst.Expression array = program.typeToInterceptorMap;
129 if (array == null) return js.comment("Empty type-to-interceptor map."); 127 if (array == null) return js.comment("Empty type-to-interceptor map.");
130 128
131 jsAst.Expression typeToInterceptorMap = emitter 129 jsAst.Expression typeToInterceptorMap = emitter
132 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); 130 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP);
133 return js.statement('# = #', [typeToInterceptorMap, array]); 131 return js.statement('# = #', [typeToInterceptorMap, array]);
134 } 132 }
135 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698