Chromium Code Reviews| Index: lib/compiler/implementation/dart_backend/backend.dart |
| diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart |
| index 3a33fd1c830f93a4ac3a15615da2367549e747c9..8f434e1426a0d6e0430b815b85f514d3d88dfc6d 100644 |
| --- a/lib/compiler/implementation/dart_backend/backend.dart |
| +++ b/lib/compiler/implementation/dart_backend/backend.dart |
| @@ -14,12 +14,53 @@ class DartBackend extends Backend { |
| : tasks = <CompilerTask>[], |
| super(compiler); |
| - void enqueueHelpers(Enqueuer world) { } |
| + void enqueueHelpers(Enqueuer world) { |
| + // Right now resolver doesn't always resolve interfaces needed |
| + // for literals, so force them. TODO(antonm): fix in the resolver. |
| + final LITERAL_TYPE_NAMES = const [ |
| + 'Map', 'List', 'num', 'int', 'double' |
|
Roman
2012/08/29 08:40:08
what about bool? There is also LiteralMapEntry, I
Anton Muhin
2012/08/29 09:43:46
Thanks a lot for bool, I just forgot about it, add
|
| + ]; |
| + final coreLibrary = compiler.coreLibrary; |
| + for (final name in LITERAL_TYPE_NAMES) { |
| + ClassElement classElement = coreLibrary.findLocal(new SourceString(name)); |
| + classElement.ensureResolved(compiler); |
| + } |
| + } |
| void codegen(WorkItem work) { } |
| void processNativeClasses(Enqueuer world, |
| Collection<LibraryElement> libraries) { } |
| void assembleProgram() { |
| + // Conservatively traverse all platform libraries and collect member names. |
| + // TODO(antonm): ideally we should only collect names of used members, |
| + // however as of today there are problems with names of some core library |
| + // interfaces, most probably for interfaces of literals. |
| + final fixedMemberNames = new Set<String>(); |
|
Roman
2012/08/29 08:40:08
do NoSuchMethodException and NoSuchMethod will be
Anton Muhin
2012/08/29 09:43:46
Yes, they get into this set. And fortunately enou
|
| + for (final library in compiler.libraries.getValues()) { |
| + if (!library.isPlatformLibrary) continue; |
| + for (final element in library.localMembers) { |
| + if (element is ClassElement) { |
| + ClassElement classElement = element; |
| + for (final member in classElement.localMembers) { |
| + final name = member.name.slowToString(); |
| + // Skip operator names. |
| + if (name.startsWith(@'operator$')) continue; |
| + // Fetch name of named constructors and factories if any, |
| + // otherwise store regular name. |
| + // TODO(antonm): better way to analyze the name. |
| + fixedMemberNames.add(name.split(@'$').last()); |
| + } |
| + } else { |
| + fixedMemberNames.add(element.name.slowToString()); |
| + } |
| + } |
| + } |
| + // TODO(antonm): TypeError along with other exceptions is defined in |
| + // runtime/lib/error.dart. Overall, all DartVM specific libs should be |
| + // accounted for. |
| + fixedMemberNames.add('srcType'); |
|
Roman
2012/08/29 08:40:08
Reading the comment I don't understand why srcType
Anton Muhin
2012/08/29 09:43:46
Sorry, I meant that those fields are declared in h
|
| + fixedMemberNames.add('dstType'); |
| + |
| /** |
| * Tells whether we should output given element. Corelib classes like |
| * Object should not be in the resulting code. |
| @@ -89,7 +130,8 @@ class DartBackend extends Backend { |
| }); |
| // Create all necessary placeholders. |
| - PlaceholderCollector collector = new PlaceholderCollector(compiler); |
| + PlaceholderCollector collector = |
| + new PlaceholderCollector(compiler, fixedMemberNames); |
| makePlaceholders(element) { |
| TreeElements treeElements = resolvedElements[element]; |
| if (treeElements === null) treeElements = emptyTreeElements; |
| @@ -104,7 +146,8 @@ class DartBackend extends Backend { |
| Map<Node, String> renames = new Map<Node, String>(); |
| Map<LibraryElement, String> imports = new Map<LibraryElement, String>(); |
| renamePlaceholders( |
| - compiler, collector, renames, imports, minify, cutDeclarationTypes); |
| + compiler, collector, renames, imports, |
| + fixedMemberNames, minify, cutDeclarationTypes); |
| // Sort elements. |
| final sortedTopLevels = sortElements(topLevelElements); |