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

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

Issue 881363006: Store the aliasName of a method in the model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: REBASE Created 5 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 | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/container_builder.dart ('k') | 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 'js_emitter.dart' show computeMixinClass; 7 import 'js_emitter.dart' show computeMixinClass;
8 import 'model.dart'; 8 import 'model.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 js.Expression code = backend.generatedCode[element]; 418 js.Expression code = backend.generatedCode[element];
419 419
420 // TODO(kasperl): Figure out under which conditions code is null. 420 // TODO(kasperl): Figure out under which conditions code is null.
421 if (code == null) return null; 421 if (code == null) return null;
422 422
423 bool canTearOff = false; 423 bool canTearOff = false;
424 String tearOffName; 424 String tearOffName;
425 bool isClosure = false; 425 bool isClosure = false;
426 bool isNotApplyTarget = !element.isFunction || element.isAccessor; 426 bool isNotApplyTarget = !element.isFunction || element.isAccessor;
427 427
428 final bool canBeReflected = _methodCanBeReflected(element); 428 bool canBeReflected = _methodCanBeReflected(element);
429 final bool canBeApplied = _methodCanBeApplied(element); 429 bool needsStubs = _methodNeedsStubs(element);
430 final bool hasSuperAlias = backend.isAliasedSuperMember(element); 430 bool canBeApplied = _methodCanBeApplied(element);
431
432 String aliasName = backend.isAliasedSuperMember(element)
433 ? namer.getNameOfAliasedSuperMember(element)
434 : null;
431 435
432 if (isNotApplyTarget) { 436 if (isNotApplyTarget) {
433 canTearOff = false; 437 canTearOff = false;
434 } else { 438 } else {
435 if (element.enclosingClass.isClosure) { 439 if (element.enclosingClass.isClosure) {
436 canTearOff = false; 440 canTearOff = false;
437 isClosure = true; 441 isClosure = true;
438 } else { 442 } else {
439 // Careful with operators. 443 // Careful with operators.
440 canTearOff = universe.hasInvokedGetter(element, _compiler.world) || 444 canTearOff = universe.hasInvokedGetter(element, _compiler.world) ||
(...skipping 13 matching lines...) Expand all
454 String callName = null; 458 String callName = null;
455 if (canTearOff) { 459 if (canTearOff) {
456 Selector callSelector = 460 Selector callSelector =
457 new Selector.fromElement(element).toCallSelector(); 461 new Selector.fromElement(element).toCallSelector();
458 callName = namer.invocationName(callSelector); 462 callName = namer.invocationName(callSelector);
459 } 463 }
460 464
461 return new InstanceMethod(element, name, code, 465 return new InstanceMethod(element, name, code,
462 _generateParameterStubs(element, canTearOff), callName, 466 _generateParameterStubs(element, canTearOff), callName,
463 needsTearOff: canTearOff, tearOffName: tearOffName, 467 needsTearOff: canTearOff, tearOffName: tearOffName,
464 isClosure: isClosure, hasSuperAlias: hasSuperAlias, 468 isClosure: isClosure, aliasName: aliasName,
465 canBeApplied: canBeApplied, canBeReflected: canBeReflected); 469 canBeApplied: canBeApplied, canBeReflected: canBeReflected);
466 } 470 }
467 471
468 List<ParameterStubMethod> _generateParameterStubs(FunctionElement element, 472 List<ParameterStubMethod> _generateParameterStubs(FunctionElement element,
469 bool canTearOff) { 473 bool canTearOff) {
470 474
471 if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[]; 475 if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[];
472 476
473 ParameterStubGenerator generator = 477 ParameterStubGenerator generator =
474 new ParameterStubGenerator(_compiler, namer, backend); 478 new ParameterStubGenerator(_compiler, namer, backend);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 js.Expression code = stubGenerator.generateOneShotInterceptor(name); 577 js.Expression code = stubGenerator.generateOneShotInterceptor(name);
574 return new StaticStubMethod(name, holder, code); 578 return new StaticStubMethod(name, holder, code);
575 }); 579 });
576 } 580 }
577 581
578 StaticDartMethod _buildStaticMethod(FunctionElement element) { 582 StaticDartMethod _buildStaticMethod(FunctionElement element) {
579 String name = namer.getNameOfMember(element); 583 String name = namer.getNameOfMember(element);
580 String holder = namer.globalObjectFor(element); 584 String holder = namer.globalObjectFor(element);
581 js.Expression code = backend.generatedCode[element]; 585 js.Expression code = backend.generatedCode[element];
582 586
583 final bool isApplyTarget = !element.isConstructor && !element.isAccessor; 587 bool isApplyTarget = !element.isConstructor && !element.isAccessor;
584 final bool canBeApplied = _methodCanBeApplied(element); 588 bool canBeApplied = _methodCanBeApplied(element);
585 final bool canBeReflected = _methodCanBeReflected(element); 589 bool canBeReflected = _methodCanBeReflected(element);
586 590
587 final bool needsTearOff = isApplyTarget && 591 bool needsTearOff = isApplyTarget &&
588 (canBeReflected || 592 (canBeReflected ||
589 universe.staticFunctionsNeedingGetter.contains(element)); 593 universe.staticFunctionsNeedingGetter.contains(element));
590 594
591 final String tearOffName = 595 String tearOffName =
592 needsTearOff ? namer.getStaticClosureName(element) : null; 596 needsTearOff ? namer.getStaticClosureName(element) : null;
593 597
594 String callName = null; 598 String callName = null;
595 if (needsTearOff) { 599 if (needsTearOff) {
596 Selector callSelector = 600 Selector callSelector =
597 new Selector.fromElement(element).toCallSelector(); 601 new Selector.fromElement(element).toCallSelector();
598 callName = namer.invocationName(callSelector); 602 callName = namer.invocationName(callSelector);
599 } 603 }
600 604
601 return new StaticDartMethod(element, 605 return new StaticDartMethod(element,
(...skipping 14 matching lines...) Expand all
616 _registry.registerConstant(outputUnit, constantValue); 620 _registry.registerConstant(outputUnit, constantValue);
617 assert(!_constants.containsKey(constantValue)); 621 assert(!_constants.containsKey(constantValue));
618 String name = namer.constantName(constantValue); 622 String name = namer.constantName(constantValue);
619 String constantObject = namer.globalObjectForConstant(constantValue); 623 String constantObject = namer.globalObjectForConstant(constantValue);
620 Holder holder = _registry.registerHolder(constantObject); 624 Holder holder = _registry.registerHolder(constantObject);
621 Constant constant = new Constant(name, holder, constantValue); 625 Constant constant = new Constant(name, holder, constantValue);
622 _constants[constantValue] = constant; 626 _constants[constantValue] = constant;
623 } 627 }
624 } 628 }
625 } 629 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/container_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698