| 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 part of dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
| 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
| 9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
| 10 class ElementAst { | 10 class ElementAst { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 constantCompilerTask = new DartConstantTask(compiler), | 109 constantCompilerTask = new DartConstantTask(compiler), |
| 110 outputter = new DartOutputter( | 110 outputter = new DartOutputter( |
| 111 compiler, compiler.outputProvider, | 111 compiler, compiler.outputProvider, |
| 112 forceStripTypes: strips.indexOf('types') != -1, | 112 forceStripTypes: strips.indexOf('types') != -1, |
| 113 multiFile: multiFile, | 113 multiFile: multiFile, |
| 114 enableMinification: compiler.enableMinification), | 114 enableMinification: compiler.enableMinification), |
| 115 super(compiler) { | 115 super(compiler) { |
| 116 resolutionCallbacks = new DartResolutionCallbacks(this); | 116 resolutionCallbacks = new DartResolutionCallbacks(this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 Resolution get resolution => compiler.resolution; |
| 120 |
| 119 bool classNeedsRti(ClassElement cls) => false; | 121 bool classNeedsRti(ClassElement cls) => false; |
| 120 bool methodNeedsRti(FunctionElement function) => false; | 122 bool methodNeedsRti(FunctionElement function) => false; |
| 121 | 123 |
| 122 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { | 124 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { |
| 123 // Right now resolver doesn't always resolve interfaces needed | 125 // Right now resolver doesn't always resolve interfaces needed |
| 124 // for literals, so force them. TODO(antonm): fix in the resolver. | 126 // for literals, so force them. TODO(antonm): fix in the resolver. |
| 125 final LITERAL_TYPE_NAMES = const [ | 127 final LITERAL_TYPE_NAMES = const [ |
| 126 'Map', 'List', 'num', 'int', 'double', 'bool' | 128 'Map', 'List', 'num', 'int', 'double', 'bool' |
| 127 ]; | 129 ]; |
| 128 final coreLibrary = compiler.coreLibrary; | 130 final coreLibrary = compiler.coreLibrary; |
| 129 for (final name in LITERAL_TYPE_NAMES) { | 131 for (final name in LITERAL_TYPE_NAMES) { |
| 130 ClassElement classElement = coreLibrary.findLocal(name); | 132 ClassElement classElement = coreLibrary.findLocal(name); |
| 131 classElement.ensureResolved(compiler); | 133 classElement.ensureResolved(resolution); |
| 132 } | 134 } |
| 133 // Enqueue the methods that the VM might invoke on user objects because | 135 // Enqueue the methods that the VM might invoke on user objects because |
| 134 // we don't trust the resolution to always get these included. | 136 // we don't trust the resolution to always get these included. |
| 135 world.registerInvocation(new UniverseSelector(Selectors.toString_, null)); | 137 world.registerInvocation(new UniverseSelector(Selectors.toString_, null)); |
| 136 world.registerInvokedGetter( | 138 world.registerInvokedGetter( |
| 137 new UniverseSelector(Selectors.hashCode_, null)); | 139 new UniverseSelector(Selectors.hashCode_, null)); |
| 138 world.registerInvocation( | 140 world.registerInvocation( |
| 139 new UniverseSelector(new Selector.binaryOperator('=='), null)); | 141 new UniverseSelector(new Selector.binaryOperator('=='), null)); |
| 140 world.registerInvocation( | 142 world.registerInvocation( |
| 141 new UniverseSelector(Selectors.compareTo, null)); | 143 new UniverseSelector(Selectors.compareTo, null)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 220 |
| 219 @override | 221 @override |
| 220 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 222 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 221 // All platform classes must be resolved to ensure that their member names | 223 // All platform classes must be resolved to ensure that their member names |
| 222 // are preserved. | 224 // are preserved. |
| 223 loadedLibraries.forEachLibrary((LibraryElement library) { | 225 loadedLibraries.forEachLibrary((LibraryElement library) { |
| 224 if (library.isPlatformLibrary) { | 226 if (library.isPlatformLibrary) { |
| 225 library.forEachLocalMember((Element element) { | 227 library.forEachLocalMember((Element element) { |
| 226 if (element.isClass) { | 228 if (element.isClass) { |
| 227 ClassElement classElement = element; | 229 ClassElement classElement = element; |
| 228 classElement.ensureResolved(compiler); | 230 classElement.ensureResolved(resolution); |
| 229 } | 231 } |
| 230 }); | 232 }); |
| 231 } | 233 } |
| 232 }); | 234 }); |
| 233 if (useMirrorHelperLibrary && | 235 if (useMirrorHelperLibrary && |
| 234 loadedLibraries.containsLibrary(Uris.dart_mirrors)) { | 236 loadedLibraries.containsLibrary(Uris.dart_mirrors)) { |
| 235 return compiler.libraryLoader.loadLibrary( | 237 return compiler.libraryLoader.loadLibrary( |
| 236 compiler.translateResolvedUri( | 238 compiler.translateResolvedUri( |
| 237 loadedLibraries.getLibrary(Uris.dart_mirrors), | 239 loadedLibraries.getLibrary(Uris.dart_mirrors), |
| 238 MirrorRenamerImpl.DART_MIRROR_HELPER, null)). | 240 MirrorRenamerImpl.DART_MIRROR_HELPER, null)). |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 LibraryElement library = superclass.library; | 301 LibraryElement library = superclass.library; |
| 300 if (library.isPlatformLibrary) { | 302 if (library.isPlatformLibrary) { |
| 301 if (_userImplementedPlatformClasses.add(superclass)) { | 303 if (_userImplementedPlatformClasses.add(superclass)) { |
| 302 // Register selectors for all instance methods since these might | 304 // Register selectors for all instance methods since these might |
| 303 // be called on user classes from within the platform | 305 // be called on user classes from within the platform |
| 304 // implementation. | 306 // implementation. |
| 305 superclass.forEachLocalMember((MemberElement element) { | 307 superclass.forEachLocalMember((MemberElement element) { |
| 306 if (element.isConstructor || element.isStatic) return; | 308 if (element.isConstructor || element.isStatic) return; |
| 307 | 309 |
| 308 FunctionElement function = element.asFunctionElement(); | 310 FunctionElement function = element.asFunctionElement(); |
| 309 element.computeType(compiler); | 311 element.computeType(resolution); |
| 310 Selector selector = new Selector.fromElement(element); | 312 Selector selector = new Selector.fromElement(element); |
| 311 if (selector.isGetter) { | 313 if (selector.isGetter) { |
| 312 registry.registerDynamicGetter( | 314 registry.registerDynamicGetter( |
| 313 new UniverseSelector(selector, null)); | 315 new UniverseSelector(selector, null)); |
| 314 } else if (selector.isSetter) { | 316 } else if (selector.isSetter) { |
| 315 registry.registerDynamicSetter( | 317 registry.registerDynamicSetter( |
| 316 new UniverseSelector(selector, null)); | 318 new UniverseSelector(selector, null)); |
| 317 } else { | 319 } else { |
| 318 registry.registerDynamicInvocation( | 320 registry.registerDynamicInvocation( |
| 319 new UniverseSelector(selector, null)); | 321 new UniverseSelector(selector, null)); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 524 } |
| 523 | 525 |
| 524 // TODO(johnniwinther): Remove this when values are computed from the | 526 // TODO(johnniwinther): Remove this when values are computed from the |
| 525 // expressions. | 527 // expressions. |
| 526 @override | 528 @override |
| 527 void copyConstantValues(DartConstantTask task) { | 529 void copyConstantValues(DartConstantTask task) { |
| 528 constantCompiler.constantValueMap.addAll( | 530 constantCompiler.constantValueMap.addAll( |
| 529 task.constantCompiler.constantValueMap); | 531 task.constantCompiler.constantValueMap); |
| 530 } | 532 } |
| 531 } | 533 } |
| OLD | NEW |