| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 native; | 5 library native; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 import 'dart:uri'; | 8 import 'dart:uri'; |
| 9 import 'dart2jslib.dart' hide SourceString; | 9 import 'dart2jslib.dart' hide SourceString; |
| 10 import 'elements/elements.dart'; | 10 import 'elements/elements.dart'; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // be instantiated (abstract or simply unused). | 432 // be instantiated (abstract or simply unused). |
| 433 addSubtypes(cls.superclass, emitter); | 433 addSubtypes(cls.superclass, emitter); |
| 434 | 434 |
| 435 for (DartType type in cls.allSupertypes) { | 435 for (DartType type in cls.allSupertypes) { |
| 436 List<Element> subtypes = emitter.subtypes.putIfAbsent( | 436 List<Element> subtypes = emitter.subtypes.putIfAbsent( |
| 437 type.element, | 437 type.element, |
| 438 () => <ClassElement>[]); | 438 () => <ClassElement>[]); |
| 439 subtypes.add(cls); | 439 subtypes.add(cls); |
| 440 } | 440 } |
| 441 | 441 |
| 442 // Skip through all the mixin applications in the super class |
| 443 // chain. That way, the direct subtypes set only contain the |
| 444 // natives classes. |
| 445 ClassElement superclass = cls.superclass; |
| 446 while (superclass != null && superclass.isMixinApplication) { |
| 447 assert(!superclass.isNative()); |
| 448 superclass = superclass.superclass; |
| 449 } |
| 450 |
| 442 List<Element> directSubtypes = emitter.directSubtypes.putIfAbsent( | 451 List<Element> directSubtypes = emitter.directSubtypes.putIfAbsent( |
| 443 cls.superclass, | 452 superclass, |
| 444 () => <ClassElement>[]); | 453 () => <ClassElement>[]); |
| 445 directSubtypes.add(cls); | 454 directSubtypes.add(cls); |
| 446 } | 455 } |
| 447 | 456 |
| 448 void logSummary(log(message)) { | 457 void logSummary(log(message)) { |
| 449 log('Compiled ${registeredClasses.length} native classes, ' | 458 log('Compiled ${registeredClasses.length} native classes, ' |
| 450 '${unusedClasses.length} native classes omitted.'); | 459 '${unusedClasses.length} native classes omitted.'); |
| 451 } | 460 } |
| 452 } | 461 } |
| 453 | 462 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 } else { | 886 } else { |
| 878 if (parameters.parameterCount != 0) { | 887 if (parameters.parameterCount != 0) { |
| 879 compiler.cancel( | 888 compiler.cancel( |
| 880 'native "..." syntax is restricted to functions with zero parameters', | 889 'native "..." syntax is restricted to functions with zero parameters', |
| 881 node: nativeBody); | 890 node: nativeBody); |
| 882 } | 891 } |
| 883 LiteralString jsCode = nativeBody.asLiteralString(); | 892 LiteralString jsCode = nativeBody.asLiteralString(); |
| 884 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); | 893 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |
| 885 } | 894 } |
| 886 } | 895 } |
| OLD | NEW |