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

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

Issue 799553002: dart2js: fix mixin support in deferred libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added tests Created 6 years 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
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 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 split = supr.split(":"); 522 split = supr.split(":");
523 if (split.length == 2) { 523 if (split.length == 2) {
524 supr = split[0]; 524 supr = split[0];
525 var functionSignature = split[1]; 525 var functionSignature = split[1];
526 if (functionSignature) 526 if (functionSignature)
527 desc.$signaturePropertyName = (function(s) { 527 desc.$signaturePropertyName = (function(s) {
528 return function(){ return #metadata[s]; }; 528 return function(){ return #metadata[s]; };
529 })(functionSignature); 529 })(functionSignature);
530 } 530 }
531 531
532 if (#needsMixinSupport)
533 if (supr && supr.indexOf("+") > 0) {
534 s = supr.split("+");
535 supr = s[0];
536 var mixin = collectedClasses[s[1]];
537 if (mixin instanceof Array) mixin = mixin[1];
538 for (var d in mixin) {
539 if (hasOwnProperty.call(mixin, d) &&
540 !hasOwnProperty.call(desc, d))
541 desc[d] = mixin[d];
542 }
543 }
544
545 if (typeof dart_precompiled != "function") { 532 if (typeof dart_precompiled != "function") {
546 combinedConstructorFunction += defineClass(cls, fields); 533 combinedConstructorFunction += defineClass(cls, fields);
547 constructorsList.push(cls); 534 constructorsList.push(cls);
548 } 535 }
549 if (supr) pendingClasses[cls] = supr; 536 if (supr) pendingClasses[cls] = supr;
550 } 537 }
551 538
552 if (typeof dart_precompiled != "function") { 539 if (typeof dart_precompiled != "function") {
553 combinedConstructorFunction += 540 combinedConstructorFunction +=
554 "return [\\n " + constructorsList.join(",\\n ") + "\\n]"; 541 "return [\\n " + constructorsList.join(",\\n ") + "\\n]";
(...skipping 22 matching lines...) Expand all
577 564
578 #finishClassFunction; 565 #finishClassFunction;
579 566
580 #trivialNsmHandlers; 567 #trivialNsmHandlers;
581 568
582 for (var cls in pendingClasses) finishClass(cls); 569 for (var cls in pendingClasses) finishClass(cls);
583 }''', { 'allClasses': allClassesAccess, 570 }''', { 'allClasses': allClassesAccess,
584 'debugFastObjects': DEBUG_FAST_OBJECTS, 571 'debugFastObjects': DEBUG_FAST_OBJECTS,
585 'hasRetainedMetadata': backend.hasRetainedMetadata, 572 'hasRetainedMetadata': backend.hasRetainedMetadata,
586 'metadata': metadataAccess, 573 'metadata': metadataAccess,
587 'needsMixinSupport': needsMixinSupport,
588 'isTreeShakingDisabled': backend.isTreeShakingDisabled, 574 'isTreeShakingDisabled': backend.isTreeShakingDisabled,
589 'finishClassFunction': buildFinishClass(), 575 'finishClassFunction': buildFinishClass(),
590 'trivialNsmHandlers': nsmEmitter.buildTrivialNsmHandlers()}); 576 'trivialNsmHandlers': nsmEmitter.buildTrivialNsmHandlers()});
591 } 577 }
592 578
593 jsAst.Node optional(bool condition, jsAst.Node node) { 579 jsAst.Node optional(bool condition, jsAst.Node node) {
594 return condition ? node : new jsAst.EmptyStatement(); 580 return condition ? node : new jsAst.EmptyStatement();
595 } 581 }
596 582
597 jsAst.Statement buildFinishClass() { 583 jsAst.Statement buildFinishClass() {
598 String specProperty = '"${namer.nativeSpecProperty}"'; // "%" 584 String specProperty = '"${namer.nativeSpecProperty}"'; // "%"
599 585
600 jsAst.Expression finishedClassesAccess = 586 jsAst.Expression finishedClassesAccess =
601 generateEmbeddedGlobalAccess(embeddedNames.FINISHED_CLASSES); 587 generateEmbeddedGlobalAccess(embeddedNames.FINISHED_CLASSES);
602 jsAst.Expression interceptorsByTagAccess = 588 jsAst.Expression interceptorsByTagAccess =
603 generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTORS_BY_TAG); 589 generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTORS_BY_TAG);
604 jsAst.Expression leafTagsAccess = 590 jsAst.Expression leafTagsAccess =
605 generateEmbeddedGlobalAccess(embeddedNames.LEAF_TAGS); 591 generateEmbeddedGlobalAccess(embeddedNames.LEAF_TAGS);
606 592
607 return js.statement(''' 593 return js.statement('''
608 { 594 {
609 var finishedClasses = #finishedClassesAccess; 595 var finishedClasses = #finishedClassesAccess;
610 596
611 function finishClass(cls) { 597 function finishClass(cls) {
612 598
613 if (finishedClasses[cls]) return; 599 if (finishedClasses[cls]) return;
614 finishedClasses[cls] = true; 600 finishedClasses[cls] = true;
615 601
616 var superclass = pendingClasses[cls]; 602 var superclass = pendingClasses[cls];
603
604 if (#needsMixinSupport) {
605 if (superclass && superclass.indexOf("+") > 0) {
606 var s = superclass.split("+");
607 superclass = s[0];
608 var mixinClass = s[1];
609 finishClass(mixinClass);
610 var mixin = allClasses[mixinClass];
611 // TODO(floitsch): this test shouldn't be necessary. Without it
612 // we have a crash in pkg/analysis_server/tool/spec/check_all_test.
613 if (mixin) {
614 var mixinPrototype = mixin.prototype;
615 var clsPrototype = allClasses[cls].prototype;
616 for (var d in mixinPrototype) {
617 if (hasOwnProperty.call(mixinPrototype, d) &&
618 !hasOwnProperty.call(clsPrototype, d))
619 clsPrototype[d] = mixinPrototype[d];
620 }
621 }
622 }
623 }
624
617 // The superclass is only false (empty string) for the Dart Object 625 // The superclass is only false (empty string) for the Dart Object
618 // class. The minifier together with noSuchMethod can put methods on 626 // class. The minifier together with noSuchMethod can put methods on
619 // the Object.prototype object, and they show through here, so we check 627 // the Object.prototype object, and they show through here, so we check
620 // that we have a string. 628 // that we have a string.
621 if (!superclass || typeof superclass != "string") return; 629 if (!superclass || typeof superclass != "string") return;
622 finishClass(superclass); 630 finishClass(superclass);
623 var superConstructor = allClasses[superclass]; 631 var superConstructor = allClasses[superclass];
624 632
625 if (!superConstructor) 633 if (!superConstructor)
626 superConstructor = existingIsolateProperties[superclass]; 634 superConstructor = existingIsolateProperties[superclass];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 for (i = 0; i < tags.length; i++) { 680 for (i = 0; i < tags.length; i++) {
673 #interceptorsByTagAccess[tags[i]] = constructor; 681 #interceptorsByTagAccess[tags[i]] = constructor;
674 #leafTagsAccess[tags[i]] = false; 682 #leafTagsAccess[tags[i]] = false;
675 } 683 }
676 } 684 }
677 } 685 }
678 } 686 }
679 } 687 }
680 } 688 }
681 }''', {'finishedClassesAccess': finishedClassesAccess, 689 }''', {'finishedClassesAccess': finishedClassesAccess,
690 'needsMixinSupport': needsMixinSupport,
682 'hasNativeClasses': nativeClasses.isNotEmpty, 691 'hasNativeClasses': nativeClasses.isNotEmpty,
683 'interceptorsByTagAccess': interceptorsByTagAccess, 692 'interceptorsByTagAccess': interceptorsByTagAccess,
684 'leafTagsAccess': leafTagsAccess, 693 'leafTagsAccess': leafTagsAccess,
685 'allowNativesSubclassing': true}); 694 'allowNativesSubclassing': true});
686 } 695 }
687 696
688 jsAst.Fun get finishIsolateConstructorFunction { 697 jsAst.Fun get finishIsolateConstructorFunction {
689 // We replace the old Isolate function with a new one that initializes 698 // We replace the old Isolate function with a new one that initializes
690 // all its fields with the initial (and often final) value of all globals. 699 // all its fields with the initial (and often final) value of all globals.
691 // 700 //
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2261 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2253 if (element.isInstanceMember) { 2262 if (element.isInstanceMember) {
2254 cachedClassBuilders.remove(element.enclosingClass); 2263 cachedClassBuilders.remove(element.enclosingClass);
2255 2264
2256 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2265 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2257 2266
2258 } 2267 }
2259 } 2268 }
2260 } 2269 }
2261 } 2270 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/deferred_mixin_lib1.dart » ('j') | tests/language/deferred_mixin_lib1.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698