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

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

Issue 858433005: dart2js: Don't reference mixins when they are only used for RTI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 423 }
424 424
425 /** Needs defineClass to be defined. */ 425 /** Needs defineClass to be defined. */
426 jsAst.Expression buildInheritFrom() { 426 jsAst.Expression buildInheritFrom() {
427 jsAst.Expression result = js(r''' 427 jsAst.Expression result = js(r'''
428 function() { 428 function() {
429 function tmp() {} 429 function tmp() {}
430 var hasOwnProperty = Object.prototype.hasOwnProperty; 430 var hasOwnProperty = Object.prototype.hasOwnProperty;
431 return function (constructor, superConstructor) { 431 return function (constructor, superConstructor) {
432 if (superConstructor == null) { 432 if (superConstructor == null) {
433 // TODO(21896): this test shouldn't be necessary. Without it
434 // we have a crash in language/mixin_only_for_rti and
435 // pkg/analysis_server/tool/spec/check_all_test.
436 if (constructor == null) return;
437
438 // Fix up the the Dart Object class' prototype. 433 // Fix up the the Dart Object class' prototype.
439 var prototype = constructor.prototype; 434 var prototype = constructor.prototype;
440 prototype.constructor = constructor; 435 prototype.constructor = constructor;
441 return prototype; 436 return prototype;
442 } 437 }
443 tmp.prototype = superConstructor.prototype; 438 tmp.prototype = superConstructor.prototype;
444 var object = new tmp(); 439 var object = new tmp();
445 var properties = constructor.prototype; 440 var properties = constructor.prototype;
446 for (var member in properties) { 441 for (var member in properties) {
447 if (hasOwnProperty.call(properties, member)) { 442 if (hasOwnProperty.call(properties, member)) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 477
483 var superclass = processedClasses.pending[cls]; 478 var superclass = processedClasses.pending[cls];
484 479
485 if (#needsMixinSupport) { 480 if (#needsMixinSupport) {
486 if (superclass && superclass.indexOf("+") > 0) { 481 if (superclass && superclass.indexOf("+") > 0) {
487 var s = superclass.split("+"); 482 var s = superclass.split("+");
488 superclass = s[0]; 483 superclass = s[0];
489 var mixinClass = s[1]; 484 var mixinClass = s[1];
490 finishClass(mixinClass); 485 finishClass(mixinClass);
491 var mixin = allClasses[mixinClass]; 486 var mixin = allClasses[mixinClass];
492 // TODO(21896): this test shouldn't be necessary. Without it 487 var mixinPrototype = mixin.prototype;
493 // we have a crash in language/mixin_only_for_rti and 488 var clsPrototype = allClasses[cls].prototype;
494 // pkg/analysis_server/tool/spec/check_all_test. 489 for (var d in mixinPrototype) {
495 if (mixin) { 490 if (hasOwnProperty.call(mixinPrototype, d) &&
496 var mixinPrototype = mixin.prototype; 491 !hasOwnProperty.call(clsPrototype, d))
497 var clsPrototype = allClasses[cls].prototype; 492 clsPrototype[d] = mixinPrototype[d];
498 for (var d in mixinPrototype) {
499 if (hasOwnProperty.call(mixinPrototype, d) &&
500 !hasOwnProperty.call(clsPrototype, d))
501 clsPrototype[d] = mixinPrototype[d];
502 }
503 } 493 }
504 } 494 }
505 } 495 }
506 496
507 // The superclass is only false (empty string) for the Dart Object 497 // The superclass is only false (empty string) for the Dart Object
508 // class. The minifier together with noSuchMethod can put methods on 498 // class. The minifier together with noSuchMethod can put methods on
509 // the Object.prototype object, and they show through here, so we check 499 // the Object.prototype object, and they show through here, so we check
510 // that we have a string. 500 // that we have a string.
511 if (!superclass || typeof superclass != "string") { 501 if (!superclass || typeof superclass != "string") {
512 inheritFrom(allClasses[cls], null); 502 inheritFrom(allClasses[cls], null);
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2079 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2090 if (element.isInstanceMember) { 2080 if (element.isInstanceMember) {
2091 cachedClassBuilders.remove(element.enclosingClass); 2081 cachedClassBuilders.remove(element.enclosingClass);
2092 2082
2093 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2083 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2094 2084
2095 } 2085 }
2096 } 2086 }
2097 } 2087 }
2098 } 2088 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/class_emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698