Chromium Code Reviews| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); | 107 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); |
| 108 flushQueue(); | 108 flushQueue(); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 void processNativeClassesInLibrary(LibraryElement library) { | 112 void processNativeClassesInLibrary(LibraryElement library) { |
| 113 // Use implementation to ensure the inclusion of injected members. | 113 // Use implementation to ensure the inclusion of injected members. |
| 114 library.implementation.forEachLocalMember((Element element) { | 114 library.implementation.forEachLocalMember((Element element) { |
| 115 if (element.kind == ElementKind.CLASS) { | 115 if (element.kind == ElementKind.CLASS) { |
| 116 ClassElement classElement = element; | 116 ClassElement classElement = element; |
| 117 if (classElement.isNative()) { | 117 if (classElement.isNative() || classElement == compiler.listClass) { |
|
sra1
2012/12/12 04:28:02
And compile.stringClass?
It would be better to ad
ngeoffray
2012/12/12 11:54:56
Done. I also added string, int, double and bool as
| |
| 118 nativeClasses.add(classElement); | 118 nativeClasses.add(classElement); |
| 119 unusedClasses.add(classElement); | 119 unusedClasses.add(classElement); |
| 120 | 120 |
| 121 // Resolve class to ensure the class has valid inheritance info. | 121 // Resolve class to ensure the class has valid inheritance info. |
| 122 classElement.ensureResolved(compiler); | 122 classElement.ensureResolved(compiler); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 }); | 125 }); |
| 126 } | 126 } |
| 127 | 127 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 flushQueue(); | 303 flushQueue(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 processNativeBehavior(NativeBehavior behavior, cause) { | 306 processNativeBehavior(NativeBehavior behavior, cause) { |
| 307 bool allUsedBefore = unusedClasses.isEmpty; | 307 bool allUsedBefore = unusedClasses.isEmpty; |
| 308 for (var type in behavior.typesInstantiated) { | 308 for (var type in behavior.typesInstantiated) { |
| 309 if (matchedTypeConstraints.contains(type)) continue; | 309 if (matchedTypeConstraints.contains(type)) continue; |
| 310 matchedTypeConstraints.add(type); | 310 matchedTypeConstraints.add(type); |
| 311 if (type is SpecialType) { | 311 if (type is SpecialType) { |
| 312 if (type == SpecialType.JsArray) { | 312 if (type == SpecialType.JsArray) { |
| 313 world.registerInstantiatedClass(compiler.listClass); | 313 enqueueClass(compiler.listClass, 'core type'); |
| 314 } else if (type == SpecialType.JsObject) { | 314 } else if (type == SpecialType.JsObject) { |
| 315 world.registerInstantiatedClass(compiler.objectClass); | 315 enqueueClass(compiler.objectClass, 'core type'); |
| 316 } | 316 } |
| 317 continue; | 317 continue; |
| 318 } | 318 } |
| 319 if (type is InterfaceType) { | 319 if (type is InterfaceType) { |
| 320 if (type.element == compiler.intClass) { | 320 if (type.element == compiler.intClass) { |
| 321 world.registerInstantiatedClass(compiler.intClass); | 321 world.registerInstantiatedClass(compiler.intClass); |
| 322 } else if (type.element == compiler.doubleClass) { | 322 } else if (type.element == compiler.doubleClass) { |
| 323 world.registerInstantiatedClass(compiler.doubleClass); | 323 world.registerInstantiatedClass(compiler.doubleClass); |
| 324 } else if (type.element == compiler.numClass) { | 324 } else if (type.element == compiler.numClass) { |
| 325 world.registerInstantiatedClass(compiler.numClass); | 325 world.registerInstantiatedClass(compiler.numClass); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 builder.add(new HForeign( | 901 builder.add(new HForeign( |
| 902 new DartString.literal('${parameter.name.slowToString()} = #'), | 902 new DartString.literal('${parameter.name.slowToString()} = #'), |
| 903 const LiteralDartString('void'), | 903 const LiteralDartString('void'), |
| 904 <HInstruction>[jsClosure])); | 904 <HInstruction>[jsClosure])); |
| 905 } | 905 } |
| 906 }); | 906 }); |
| 907 LiteralString jsCode = nativeBody.asLiteralString(); | 907 LiteralString jsCode = nativeBody.asLiteralString(); |
| 908 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); | 908 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |
| 909 } | 909 } |
| 910 } | 910 } |
| OLD | NEW |