OLD | NEW |
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 native; | 5 part of native; |
6 | 6 |
7 /** | 7 /** |
8 * This could be an abstract class but we use it as a stub for the dart_backend. | 8 * This could be an abstract class but we use it as a stub for the dart_backend. |
9 */ | 9 */ |
10 class NativeEnqueuer { | 10 class NativeEnqueuer { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 processClass(BaseClassElementX classElement, cause) { | 363 processClass(BaseClassElementX classElement, cause) { |
364 // TODO(ahe): Fix this assertion to work in incremental compilation. | 364 // TODO(ahe): Fix this assertion to work in incremental compilation. |
365 assert(compiler.hasIncrementalSupport || | 365 assert(compiler.hasIncrementalSupport || |
366 !registeredClasses.contains(classElement)); | 366 !registeredClasses.contains(classElement)); |
367 | 367 |
368 bool firstTime = registeredClasses.isEmpty; | 368 bool firstTime = registeredClasses.isEmpty; |
369 pendingClasses.remove(classElement); | 369 pendingClasses.remove(classElement); |
370 registeredClasses.add(classElement); | 370 registeredClasses.add(classElement); |
371 | 371 |
372 // TODO(ahe): Is this really a global dependency? | 372 // TODO(ahe): Is this really a global dependency? |
373 world.registerInstantiatedClass(classElement, compiler.globalDependencies); | 373 classElement.ensureResolved(compiler); |
| 374 world.registerInstantiatedType( |
| 375 classElement.rawType, compiler.globalDependencies); |
374 | 376 |
375 // Also parse the node to know all its methods because otherwise it will | 377 // Also parse the node to know all its methods because otherwise it will |
376 // only be parsed if there is a call to one of its constructors. | 378 // only be parsed if there is a call to one of its constructors. |
377 classElement.parseNode(compiler); | 379 classElement.parseNode(compiler); |
378 | 380 |
379 if (firstTime) { | 381 if (firstTime) { |
380 queue.add(onFirstNativeClass); | 382 queue.add(onFirstNativeClass); |
381 } | 383 } |
382 } | 384 } |
383 | 385 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 518 |
517 processNativeBehavior(NativeBehavior behavior, cause) { | 519 processNativeBehavior(NativeBehavior behavior, cause) { |
518 // TODO(ahe): Is this really a global dependency? | 520 // TODO(ahe): Is this really a global dependency? |
519 Registry registry = compiler.globalDependencies; | 521 Registry registry = compiler.globalDependencies; |
520 bool allUsedBefore = unusedClasses.isEmpty; | 522 bool allUsedBefore = unusedClasses.isEmpty; |
521 for (var type in behavior.typesInstantiated) { | 523 for (var type in behavior.typesInstantiated) { |
522 if (matchedTypeConstraints.contains(type)) continue; | 524 if (matchedTypeConstraints.contains(type)) continue; |
523 matchedTypeConstraints.add(type); | 525 matchedTypeConstraints.add(type); |
524 if (type is SpecialType) { | 526 if (type is SpecialType) { |
525 if (type == SpecialType.JsObject) { | 527 if (type == SpecialType.JsObject) { |
526 world.registerInstantiatedClass(compiler.objectClass, registry); | 528 world.registerInstantiatedType( |
| 529 compiler.coreTypes.objectType, registry); |
527 } | 530 } |
528 continue; | 531 continue; |
529 } | 532 } |
530 if (type is InterfaceType) { | 533 if (type is InterfaceType) { |
531 if (type.element == compiler.intClass) { | 534 if (type.element == compiler.intClass) { |
532 world.registerInstantiatedClass(compiler.intClass, registry); | 535 world.registerInstantiatedType(type, registry); |
533 } else if (type.element == compiler.doubleClass) { | 536 } else if (type.element == compiler.doubleClass) { |
534 world.registerInstantiatedClass(compiler.doubleClass, registry); | 537 world.registerInstantiatedType(type, registry); |
535 } else if (type.element == compiler.numClass) { | 538 } else if (type.element == compiler.numClass) { |
536 world.registerInstantiatedClass(compiler.doubleClass, registry); | 539 world.registerInstantiatedType( |
537 world.registerInstantiatedClass(compiler.intClass, registry); | 540 compiler.coreTypes.doubleType, registry); |
| 541 world.registerInstantiatedType( |
| 542 compiler.coreTypes.intType, registry); |
538 } else if (type.element == compiler.stringClass) { | 543 } else if (type.element == compiler.stringClass) { |
539 world.registerInstantiatedClass(compiler.stringClass, registry); | 544 world.registerInstantiatedType(type, registry); |
540 } else if (type.element == compiler.nullClass) { | 545 } else if (type.element == compiler.nullClass) { |
541 world.registerInstantiatedClass(compiler.nullClass, registry); | 546 world.registerInstantiatedType(type, registry); |
542 } else if (type.element == compiler.boolClass) { | 547 } else if (type.element == compiler.boolClass) { |
543 world.registerInstantiatedClass(compiler.boolClass, registry); | 548 world.registerInstantiatedType(type, registry); |
544 } else if (compiler.types.isSubtype( | 549 } else if (compiler.types.isSubtype( |
545 type, backend.listImplementation.rawType)) { | 550 type, backend.listImplementation.rawType)) { |
546 world.registerInstantiatedClass(type.element, registry); | 551 world.registerInstantiatedType(type, registry); |
547 } | 552 } |
548 } | 553 } |
549 assert(type is DartType); | 554 assert(type is DartType); |
550 enqueueUnusedClassesMatching( | 555 enqueueUnusedClassesMatching( |
551 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), | 556 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), |
552 cause, | 557 cause, |
553 'subtypeof($type)'); | 558 'subtypeof($type)'); |
554 } | 559 } |
555 | 560 |
556 // Give an info so that library developers can compile with -v to find why | 561 // Give an info so that library developers can compile with -v to find why |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 superclass, | 688 superclass, |
684 () => <ClassElement>[]); | 689 () => <ClassElement>[]); |
685 directSubtypes.add(cls); | 690 directSubtypes.add(cls); |
686 } | 691 } |
687 | 692 |
688 void logSummary(log(message)) { | 693 void logSummary(log(message)) { |
689 log('Compiled ${registeredClasses.length} native classes, ' | 694 log('Compiled ${registeredClasses.length} native classes, ' |
690 '${unusedClasses.length} native classes omitted.'); | 695 '${unusedClasses.length} native classes omitted.'); |
691 } | 696 } |
692 } | 697 } |
OLD | NEW |