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

Side by Side Diff: pkg/compiler/lib/src/js_backend/js_interop_analysis.dart

Issue 2625713002: Rename Enqueuer.universe to worldBuilder. (Closed)
Patch Set: Updated cf. comments Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Analysis to determine how to generate code for typed JavaScript interop. 5 /// Analysis to determine how to generate code for typed JavaScript interop.
6 library compiler.src.js_backend.js_interop_analysis; 6 library compiler.src.js_backend.js_interop_analysis;
7 7
8 import '../common.dart'; 8 import '../common.dart';
9 import '../constants/values.dart' 9 import '../constants/values.dart'
10 show ConstantValue, ConstructedConstantValue, StringConstantValue; 10 show ConstantValue, ConstructedConstantValue, StringConstantValue;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (element is FunctionElement) { 110 if (element is FunctionElement) {
111 _checkFunctionParameters(element); 111 _checkFunctionParameters(element);
112 } 112 }
113 113
114 if (!element.isClass) return; 114 if (!element.isClass) return;
115 115
116 ClassElement classElement = element; 116 ClassElement classElement = element;
117 117
118 // Skip classes that are completely unreachable. This should only happen 118 // Skip classes that are completely unreachable. This should only happen
119 // when all of jsinterop types are unreachable from main. 119 // when all of jsinterop types are unreachable from main.
120 if (!backend.compiler.resolverWorld.isImplemented(classElement)) return; 120 if (!backend.compiler.resolutionWorldBuilder
121 .isImplemented(classElement)) {
122 return;
123 }
121 124
122 if (!classElement.implementsInterface(helpers.jsJavaScriptObjectClass)) { 125 if (!classElement.implementsInterface(helpers.jsJavaScriptObjectClass)) {
123 backend.reporter.reportErrorMessage(classElement, 126 backend.reporter.reportErrorMessage(classElement,
124 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, { 127 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, {
125 'cls': classElement.name, 128 'cls': classElement.name,
126 'superclass': classElement.superclass.name 129 'superclass': classElement.superclass.name
127 }); 130 });
128 } 131 }
129 132
130 classElement.forEachMember((ClassElement classElement, Element member) { 133 classElement.forEachMember((ClassElement classElement, Element member) {
(...skipping 28 matching lines...) Expand all
159 _checkFunctionParameters(fn); 162 _checkFunctionParameters(fn);
160 } 163 }
161 } 164 }
162 }); 165 });
163 }); 166 });
164 } 167 }
165 168
166 jsAst.Statement buildJsInteropBootstrap() { 169 jsAst.Statement buildJsInteropBootstrap() {
167 if (!enabledJsInterop) return null; 170 if (!enabledJsInterop) return null;
168 List<jsAst.Statement> statements = <jsAst.Statement>[]; 171 List<jsAst.Statement> statements = <jsAst.Statement>[];
169 backend.compiler.codegenWorld.forEachInvokedName( 172 backend.compiler.codegenWorldBuilder.forEachInvokedName(
170 (String name, Map<Selector, SelectorConstraints> selectors) { 173 (String name, Map<Selector, SelectorConstraints> selectors) {
171 selectors.forEach((Selector selector, SelectorConstraints constraints) { 174 selectors.forEach((Selector selector, SelectorConstraints constraints) {
172 if (selector.isClosureCall) { 175 if (selector.isClosureCall) {
173 // TODO(jacobr): support named arguments. 176 // TODO(jacobr): support named arguments.
174 if (selector.namedArgumentCount > 0) return; 177 if (selector.namedArgumentCount > 0) return;
175 int argumentCount = selector.argumentCount; 178 int argumentCount = selector.argumentCount;
176 var candidateParameterNames = 179 var candidateParameterNames =
177 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 180 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
178 var parameters = new List<String>.generate( 181 var parameters = new List<String>.generate(
179 argumentCount, (i) => candidateParameterNames[i]); 182 argumentCount, (i) => candidateParameterNames[i]);
180 183
181 var name = backend.namer.invocationName(selector); 184 var name = backend.namer.invocationName(selector);
182 statements.add(js.statement( 185 statements.add(js.statement(
183 'Function.prototype.# = function(#) { return this(#) }', 186 'Function.prototype.# = function(#) { return this(#) }',
184 [name, parameters, parameters])); 187 [name, parameters, parameters]));
185 } 188 }
186 }); 189 });
187 }); 190 });
188 return new jsAst.Block(statements); 191 return new jsAst.Block(statements);
189 } 192 }
190 193
191 ResolutionFunctionType buildJsFunctionType() { 194 ResolutionFunctionType buildJsFunctionType() {
192 // TODO(jacobr): consider using codegenWorld.isChecks to determine the 195 // TODO(jacobr): consider using codegenWorldBuilder.isChecks to determine th e
193 // range of positional arguments that need to be supported by JavaScript 196 // range of positional arguments that need to be supported by JavaScript
194 // function types. 197 // function types.
195 return new ResolutionFunctionType.synthesized( 198 return new ResolutionFunctionType.synthesized(
196 const ResolutionDynamicType(), 199 const ResolutionDynamicType(),
197 [], 200 [],
198 new List<ResolutionDartType>.filled(16, const ResolutionDynamicType())); 201 new List<ResolutionDartType>.filled(16, const ResolutionDynamicType()));
199 } 202 }
200 } 203 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/enqueuer.dart ('k') | pkg/compiler/lib/src/js_backend/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698