| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 NativeBehavior.ofJsCall(node, compiler, resolver), | 283 NativeBehavior.ofJsCall(node, compiler, resolver), |
| 284 node); | 284 node); |
| 285 flushQueue(); | 285 flushQueue(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 processNativeBehavior(NativeBehavior behavior, cause) { | 288 processNativeBehavior(NativeBehavior behavior, cause) { |
| 289 bool allUsedBefore = unusedClasses.isEmpty; | 289 bool allUsedBefore = unusedClasses.isEmpty; |
| 290 for (var type in behavior.typesInstantiated) { | 290 for (var type in behavior.typesInstantiated) { |
| 291 if (matchedTypeConstraints.contains(type)) continue; | 291 if (matchedTypeConstraints.contains(type)) continue; |
| 292 matchedTypeConstraints.add(type); | 292 matchedTypeConstraints.add(type); |
| 293 if (type is SpecialType) { | 293 if (type == SpecialType.JsArray) { |
| 294 // The two special types (=Object, =List) are always instantiated. | 294 world.registerInstantiatedClass(compiler.listClass); |
| 295 continue; | 295 } else if (type == SpecialType.JsObject) { |
| 296 world.registerInstantiatedClass(compiler.objectClass); |
| 297 } else if (type is InterfaceType) { |
| 298 if (type.element == compiler.intClass) { |
| 299 world.registerInstantiatedClass(compiler.intClass); |
| 300 } else if (type.element == compiler.doubleClass) { |
| 301 world.registerInstantiatedClass(compiler.doubleClass); |
| 302 } else if (type.element == compiler.numClass) { |
| 303 world.registerInstantiatedClass(compiler.numClass); |
| 304 } else if (type.element == compiler.stringClass) { |
| 305 world.registerInstantiatedClass(compiler.stringClass); |
| 306 } else if (type.element == compiler.nullClass) { |
| 307 world.registerInstantiatedClass(compiler.nullClass); |
| 308 } else if (type.element == compiler.boolClass) { |
| 309 world.registerInstantiatedClass(compiler.boolClass); |
| 310 } |
| 296 } | 311 } |
| 297 assert(type is DartType); | 312 assert(type is DartType); |
| 298 enqueueUnusedClassesMatching( | 313 enqueueUnusedClassesMatching( |
| 299 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), | 314 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), |
| 300 cause, | 315 cause, |
| 301 'subtypeof($type)'); | 316 'subtypeof($type)'); |
| 302 } | 317 } |
| 303 | 318 |
| 304 // Give an info so that library developers can compile with -v to find why | 319 // Give an info so that library developers can compile with -v to find why |
| 305 // all the native classes are included. | 320 // all the native classes are included. |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 builder.add(new HForeign( | 878 builder.add(new HForeign( |
| 864 new DartString.literal('${parameter.name.slowToString()} = #'), | 879 new DartString.literal('${parameter.name.slowToString()} = #'), |
| 865 const LiteralDartString('void'), | 880 const LiteralDartString('void'), |
| 866 <HInstruction>[jsClosure])); | 881 <HInstruction>[jsClosure])); |
| 867 } | 882 } |
| 868 }); | 883 }); |
| 869 LiteralString jsCode = nativeBody.asLiteralString(); | 884 LiteralString jsCode = nativeBody.asLiteralString(); |
| 870 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); | 885 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |
| 871 } | 886 } |
| 872 } | 887 } |
| OLD | NEW |