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