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

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

Issue 2314703002: Split World usage into open, inference, and closed world. (Closed)
Patch Set: Updated cf. comments. Created 4 years, 3 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 class ClassStubGenerator { 7 class ClassStubGenerator {
8 final Namer namer; 8 final Namer namer;
9 final Compiler compiler; 9 final Compiler compiler;
10 final JavaScriptBackend backend; 10 final JavaScriptBackend backend;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 Map<jsAst.Name, jsAst.Expression> generatedStubs = 77 Map<jsAst.Name, jsAst.Expression> generatedStubs =
78 <jsAst.Name, jsAst.Expression>{}; 78 <jsAst.Name, jsAst.Expression>{};
79 79
80 // Two selectors may match but differ only in type. To avoid generating 80 // Two selectors may match but differ only in type. To avoid generating
81 // identical stubs for each we track untyped selectors which already have 81 // identical stubs for each we track untyped selectors which already have
82 // stubs. 82 // stubs.
83 Set<Selector> generatedSelectors = new Set<Selector>(); 83 Set<Selector> generatedSelectors = new Set<Selector>();
84 for (Selector selector in selectors.keys) { 84 for (Selector selector in selectors.keys) {
85 if (generatedSelectors.contains(selector)) continue; 85 if (generatedSelectors.contains(selector)) continue;
86 if (!selector.appliesUnnamed(member, compiler.world)) continue; 86 if (!selector.appliesUnnamed(member, compiler.closedWorld)) continue;
87 if (selectors[selector].applies(member, selector, compiler.world)) { 87 if (selectors[selector].applies(member, selector, compiler.closedWorld)) {
88 generatedSelectors.add(selector); 88 generatedSelectors.add(selector);
89 89
90 jsAst.Name invocationName = namer.invocationName(selector); 90 jsAst.Name invocationName = namer.invocationName(selector);
91 Selector callSelector = new Selector.callClosureFrom(selector); 91 Selector callSelector = new Selector.callClosureFrom(selector);
92 jsAst.Name closureCallName = namer.invocationName(callSelector); 92 jsAst.Name closureCallName = namer.invocationName(callSelector);
93 93
94 List<jsAst.Parameter> parameters = <jsAst.Parameter>[]; 94 List<jsAst.Parameter> parameters = <jsAst.Parameter>[];
95 List<jsAst.Expression> arguments = <jsAst.Expression>[]; 95 List<jsAst.Expression> arguments = <jsAst.Expression>[];
96 if (isInterceptedMethod) { 96 if (isInterceptedMethod) {
97 parameters.add(new jsAst.Parameter(receiverArgumentName)); 97 parameters.add(new jsAst.Parameter(receiverArgumentName));
(...skipping 20 matching lines...) Expand all
118 118
119 // Do not generate no such method handlers if there is no class. 119 // Do not generate no such method handlers if there is no class.
120 if (compiler.codegenWorld.directlyInstantiatedClasses.isEmpty) { 120 if (compiler.codegenWorld.directlyInstantiatedClasses.isEmpty) {
121 return jsNames; 121 return jsNames;
122 } 122 }
123 123
124 void addNoSuchMethodHandlers( 124 void addNoSuchMethodHandlers(
125 String ignore, Map<Selector, SelectorConstraints> selectors) { 125 String ignore, Map<Selector, SelectorConstraints> selectors) {
126 for (Selector selector in selectors.keys) { 126 for (Selector selector in selectors.keys) {
127 SelectorConstraints maskSet = selectors[selector]; 127 SelectorConstraints maskSet = selectors[selector];
128 if (maskSet.needsNoSuchMethodHandling(selector, compiler.world)) { 128 if (maskSet.needsNoSuchMethodHandling(selector, compiler.closedWorld)) {
129 jsAst.Name jsName = namer.invocationMirrorInternalName(selector); 129 jsAst.Name jsName = namer.invocationMirrorInternalName(selector);
130 jsNames[jsName] = selector; 130 jsNames[jsName] = selector;
131 } 131 }
132 } 132 }
133 } 133 }
134 134
135 compiler.codegenWorld.forEachInvokedName(addNoSuchMethodHandlers); 135 compiler.codegenWorld.forEachInvokedName(addNoSuchMethodHandlers);
136 compiler.codegenWorld.forEachInvokedGetter(addNoSuchMethodHandlers); 136 compiler.codegenWorld.forEachInvokedGetter(addNoSuchMethodHandlers);
137 compiler.codegenWorld.forEachInvokedSetter(addNoSuchMethodHandlers); 137 compiler.codegenWorld.forEachInvokedSetter(addNoSuchMethodHandlers);
138 return jsNames; 138 return jsNames;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (cache === void 0) cache = #tearOff( 281 if (cache === void 0) cache = #tearOff(
282 this, funcs, reflectionInfo, true, [], name).prototype; 282 this, funcs, reflectionInfo, true, [], name).prototype;
283 return cache; 283 return cache;
284 } 284 }
285 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); 285 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted);
286 }''', 286 }''',
287 {'tearOff': tearOffAccessExpression}); 287 {'tearOff': tearOffAccessExpression});
288 288
289 return <jsAst.Statement>[tearOffGetter, tearOff]; 289 return <jsAst.Statement>[tearOffGetter, tearOff];
290 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698