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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 final LITERAL_TYPE_NAMES = const [ | 122 final LITERAL_TYPE_NAMES = const [ |
123 'Map', 'List', 'num', 'int', 'double', 'bool' | 123 'Map', 'List', 'num', 'int', 'double', 'bool' |
124 ]; | 124 ]; |
125 final coreLibrary = compiler.coreLibrary; | 125 final coreLibrary = compiler.coreLibrary; |
126 for (final name in LITERAL_TYPE_NAMES) { | 126 for (final name in LITERAL_TYPE_NAMES) { |
127 ClassElement classElement = coreLibrary.findLocal(name); | 127 ClassElement classElement = coreLibrary.findLocal(name); |
128 classElement.ensureResolved(compiler); | 128 classElement.ensureResolved(compiler); |
129 } | 129 } |
130 // Enqueue the methods that the VM might invoke on user objects because | 130 // Enqueue the methods that the VM might invoke on user objects because |
131 // we don't trust the resolution to always get these included. | 131 // we don't trust the resolution to always get these included. |
132 world.registerInvocation( | 132 world.registerInvocation(new Selector.call("toString", null, 0)); |
133 new UniverseSelector(new Selector.call("toString", null, 0), null)); | 133 world.registerInvokedGetter(new Selector.getter("hashCode", null)); |
134 world.registerInvokedGetter( | 134 world.registerInvocation(new Selector.binaryOperator("==")); |
135 new UniverseSelector(new Selector.getter("hashCode", null), null)); | 135 world.registerInvocation(new Selector.call("compareTo", null, 1)); |
136 world.registerInvocation( | |
137 new UniverseSelector(new Selector.binaryOperator("=="), null)); | |
138 world.registerInvocation( | |
139 new UniverseSelector(new Selector.call("compareTo", null, 1), null)); | |
140 } | 136 } |
141 | 137 |
142 WorldImpact codegen(CodegenWorkItem work) => const WorldImpact(); | 138 WorldImpact codegen(CodegenWorkItem work) => const WorldImpact(); |
143 | 139 |
144 /** | 140 /** |
145 * Tells whether we should output given element. Corelib classes like | 141 * Tells whether we should output given element. Corelib classes like |
146 * Object should not be in the resulting code. | 142 * Object should not be in the resulting code. |
147 */ | 143 */ |
148 @override | 144 @override |
149 bool shouldOutput(Element element) { | 145 bool shouldOutput(Element element) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // Register selectors for all instance methods since these might | 293 // Register selectors for all instance methods since these might |
298 // be called on user classes from within the platform | 294 // be called on user classes from within the platform |
299 // implementation. | 295 // implementation. |
300 superclass.forEachLocalMember((MemberElement element) { | 296 superclass.forEachLocalMember((MemberElement element) { |
301 if (element.isConstructor || element.isStatic) return; | 297 if (element.isConstructor || element.isStatic) return; |
302 | 298 |
303 FunctionElement function = element.asFunctionElement(); | 299 FunctionElement function = element.asFunctionElement(); |
304 element.computeType(compiler); | 300 element.computeType(compiler); |
305 Selector selector = new Selector.fromElement(element); | 301 Selector selector = new Selector.fromElement(element); |
306 if (selector.isGetter) { | 302 if (selector.isGetter) { |
307 registry.registerDynamicGetter( | 303 registry.registerDynamicGetter(selector); |
308 new UniverseSelector(selector, null)); | |
309 } else if (selector.isSetter) { | 304 } else if (selector.isSetter) { |
310 registry.registerDynamicSetter( | 305 registry.registerDynamicSetter(selector); |
311 new UniverseSelector(selector, null)); | |
312 } else { | 306 } else { |
313 registry.registerDynamicInvocation( | 307 registry.registerDynamicInvocation(selector); |
314 new UniverseSelector(selector, null)); | |
315 } | 308 } |
316 }); | 309 }); |
317 } | 310 } |
318 } | 311 } |
319 } | 312 } |
320 } | 313 } |
321 | 314 |
322 } | 315 } |
323 | 316 |
324 @override | 317 @override |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 } | 501 } |
509 | 502 |
510 // TODO(johnniwinther): Remove this when values are computed from the | 503 // TODO(johnniwinther): Remove this when values are computed from the |
511 // expressions. | 504 // expressions. |
512 @override | 505 @override |
513 void copyConstantValues(DartConstantTask task) { | 506 void copyConstantValues(DartConstantTask task) { |
514 constantCompiler.constantValueMap.addAll( | 507 constantCompiler.constantValueMap.addAll( |
515 task.constantCompiler.constantValueMap); | 508 task.constantCompiler.constantValueMap); |
516 } | 509 } |
517 } | 510 } |
OLD | NEW |