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

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

Issue 1975133004: Switch to using resolverWorld from codegenWorld to determine whether JS interop interceptors need t… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library dart2js.js_emitter.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import '../../closure.dart' show ClosureFieldElement; 7 import '../../closure.dart' show ClosureFieldElement;
8 import '../../common.dart'; 8 import '../../common.dart';
9 import '../../common/names.dart' show Names, Selectors; 9 import '../../common/names.dart' show Names, Selectors;
10 import '../../compiler.dart' show Compiler; 10 import '../../compiler.dart' show Compiler;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // that conflict on whether the member is a getter or a method. 341 // that conflict on whether the member is a getter or a method.
342 var interceptorClass = _classes[helpers.jsJavaScriptObjectClass]; 342 var interceptorClass = _classes[helpers.jsJavaScriptObjectClass];
343 var stubNames = new Set<String>(); 343 var stubNames = new Set<String>();
344 librariesMap.forEach((LibraryElement library, List<Element> elements) { 344 librariesMap.forEach((LibraryElement library, List<Element> elements) {
345 for (Element e in elements) { 345 for (Element e in elements) {
346 if (e is ClassElement && backend.isJsInterop(e)) { 346 if (e is ClassElement && backend.isJsInterop(e)) {
347 e.declaration.forEachMember((_, Element member) { 347 e.declaration.forEachMember((_, Element member) {
348 if (!member.isInstanceMember) return; 348 if (!member.isInstanceMember) return;
349 if (member.isGetter || member.isField || member.isFunction) { 349 if (member.isGetter || member.isField || member.isFunction) {
350 var selectors = 350 var selectors =
351 _compiler.codegenWorld.getterInvocationsByName(member.name); 351 _compiler.resolverWorld.getterInvocationsByName(member.name);
Siggi Cherem (dart-lang) 2016/05/13 23:46:53 let's add a TODO + reference to a bug so we know t
Jacob 2016/05/13 23:55:35 Done.
352 if (selectors != null && !selectors.isEmpty) { 352 if (selectors != null && !selectors.isEmpty) {
353 for (var selector in selectors.keys) { 353 for (var selector in selectors.keys) {
354 var stubName = namer.invocationName(selector); 354 var stubName = namer.invocationName(selector);
355 if (stubNames.add(stubName.key)) { 355 if (stubNames.add(stubName.key)) {
356 interceptorClass.callStubs.add(_buildStubMethod(stubName, 356 interceptorClass.callStubs.add(_buildStubMethod(stubName,
357 js.js('function(obj) { return obj.# }', [member.name]), 357 js.js('function(obj) { return obj.# }', [member.name]),
358 element: member)); 358 element: member));
359 } 359 }
360 } 360 }
361 } 361 }
362 } 362 }
363 363
364 if (member.isSetter || (member.isField && !member.isConst)) { 364 if (member.isSetter || (member.isField && !member.isConst)) {
365 var selectors = 365 var selectors =
366 _compiler.codegenWorld.setterInvocationsByName(member.name); 366 _compiler.resolverWorld.setterInvocationsByName(member.name);
367 if (selectors != null && !selectors.isEmpty) { 367 if (selectors != null && !selectors.isEmpty) {
368 var stubName = namer.setterForElement(member); 368 var stubName = namer.setterForElement(member);
369 if (stubNames.add(stubName.key)) { 369 if (stubNames.add(stubName.key)) {
370 interceptorClass.callStubs.add(_buildStubMethod( 370 interceptorClass.callStubs.add(_buildStubMethod(
371 stubName, 371 stubName,
372 js.js('function(obj, v) { return obj.# = v }', 372 js.js('function(obj, v) { return obj.# = v }',
373 [member.name]), 373 [member.name]),
374 element: member)); 374 element: member));
375 } 375 }
376 } 376 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 int minArgs; 412 int minArgs;
413 int maxArgs; 413 int maxArgs;
414 if (functionType != null) { 414 if (functionType != null) {
415 minArgs = functionType.parameterTypes.length; 415 minArgs = functionType.parameterTypes.length;
416 maxArgs = minArgs + functionType.optionalParameterTypes.length; 416 maxArgs = minArgs + functionType.optionalParameterTypes.length;
417 } else { 417 } else {
418 minArgs = 0; 418 minArgs = 0;
419 maxArgs = 32767; 419 maxArgs = 32767;
420 } 420 }
421 var selectors = 421 var selectors =
422 _compiler.codegenWorld.invocationsByName(member.name); 422 _compiler.resolverWorld.invocationsByName(member.name);
423
423 // Named arguments are not yet supported. In the future we 424 // Named arguments are not yet supported. In the future we
424 // may want to map named arguments to an object literal containing 425 // may want to map named arguments to an object literal containing
425 // all named arguments. 426 // all named arguments.
426 if (selectors != null && !selectors.isEmpty) { 427 if (selectors != null && !selectors.isEmpty) {
427 for (var selector in selectors.keys) { 428 for (var selector in selectors.keys) {
429
428 // Check whether the arity matches this member. 430 // Check whether the arity matches this member.
429 var argumentCount = selector.argumentCount; 431 var argumentCount = selector.argumentCount;
430 // JS interop does not support named arguments. 432 // JS interop does not support named arguments.
431 if (selector.namedArgumentCount > 0) break; 433 if (selector.namedArgumentCount > 0) break;
432 if (argumentCount < minArgs) break; 434 if (argumentCount < minArgs) break;
433 if (argumentCount > maxArgs) break; 435 if (argumentCount > maxArgs) break;
434 var stubName = namer.invocationName(selector); 436 var stubName = namer.invocationName(selector);
435 if (!stubNames.add(stubName.key)) break; 437 if (!stubNames.add(stubName.key)) break;
436 var parameters = 438 var parameters =
437 new List<String>.generate(argumentCount, (i) => 'p$i'); 439 new List<String>.generate(argumentCount, (i) => 'p$i');
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 Constant constant = new Constant(name, holder, constantValue); 977 Constant constant = new Constant(name, holder, constantValue);
976 _constants[constantValue] = constant; 978 _constants[constantValue] = constant;
977 } 979 }
978 } 980 }
979 981
980 Holder _registerStaticStateHolder() { 982 Holder _registerStaticStateHolder() {
981 return _registry.registerHolder(namer.staticStateHolder, 983 return _registry.registerHolder(namer.staticStateHolder,
982 isStaticStateHolder: true); 984 isStaticStateHolder: true);
983 } 985 }
984 } 986 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698