| 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:uri'; | 7 import 'dart:uri'; |
| 8 import 'dart2jslib.dart' hide SourceString; | 8 import 'dart2jslib.dart' hide SourceString; |
| 9 import 'elements/elements.dart'; | 9 import 'elements/elements.dart'; |
| 10 import 'js_backend/js_backend.dart'; | 10 import 'js_backend/js_backend.dart'; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 bool allUsedBefore = unusedClasses.isEmpty; | 229 bool allUsedBefore = unusedClasses.isEmpty; |
| 230 for (var type in behavior.typesInstantiated) { | 230 for (var type in behavior.typesInstantiated) { |
| 231 if (matchedTypeConstraints.contains(type)) continue; | 231 if (matchedTypeConstraints.contains(type)) continue; |
| 232 matchedTypeConstraints.add(type); | 232 matchedTypeConstraints.add(type); |
| 233 if (type is SpecialType) { | 233 if (type is SpecialType) { |
| 234 // The two special types (=Object, =List) are always instantiated. | 234 // The two special types (=Object, =List) are always instantiated. |
| 235 continue; | 235 continue; |
| 236 } | 236 } |
| 237 assert(type is DartType); | 237 assert(type is DartType); |
| 238 enqueueUnusedClassesMatching( | 238 enqueueUnusedClassesMatching( |
| 239 (nativeClass) => compiler.types.isSubtype(nativeClass.type, type), | 239 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), |
| 240 cause, | 240 cause, |
| 241 'subtypeof($type)'); | 241 'subtypeof($type)'); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Give an info so that library developers can compile with -v to find why | 244 // Give an info so that library developers can compile with -v to find why |
| 245 // all the native classes are included. | 245 // all the native classes are included. |
| 246 if (unusedClasses.isEmpty && !allUsedBefore) { | 246 if (unusedClasses.isEmpty && !allUsedBefore) { |
| 247 compiler.log('All native types marked as used due to $cause.'); | 247 compiler.log('All native types marked as used due to $cause.'); |
| 248 } | 248 } |
| 249 } | 249 } |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 String parameters) { | 845 String parameters) { |
| 846 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 846 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 847 buffer.add("('$methodName')) {\n"); | 847 buffer.add("('$methodName')) {\n"); |
| 848 buffer.add(" $code"); | 848 buffer.add(" $code"); |
| 849 buffer.add(" } else {\n"); | 849 buffer.add(" } else {\n"); |
| 850 buffer.add(" return Object.prototype.$methodName.call(this"); | 850 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 851 buffer.add(parameters == '' ? '' : ', $parameters'); | 851 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 852 buffer.add(");\n"); | 852 buffer.add(");\n"); |
| 853 buffer.add(" }\n"); | 853 buffer.add(" }\n"); |
| 854 } | 854 } |
| OLD | NEW |