Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: lib/kernel.dart

Issue 2106103008: Update dart2js to fix #80. (Closed) Base URL: git@github.com:dart-lang/rasta.git@analyze
Patch Set: Mixin application names should be local to libraries. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | submodules.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library rasta.kernel; 5 library rasta.kernel;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:collection' show 10 import 'dart:collection' show
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 final Map<FieldElement, ir.Field> fields = <FieldElement, ir.Field>{}; 76 final Map<FieldElement, ir.Field> fields = <FieldElement, ir.Field>{};
77 77
78 final Map<TypeVariableElement, ir.TypeParameter> typeParameters = 78 final Map<TypeVariableElement, ir.TypeParameter> typeParameters =
79 <TypeVariableElement, ir.TypeParameter>{}; 79 <TypeVariableElement, ir.TypeParameter>{};
80 80
81 final Map<TypeVariableElement, ir.TypeParameter> factoryTypeParameters = 81 final Map<TypeVariableElement, ir.TypeParameter> factoryTypeParameters =
82 <TypeVariableElement, ir.TypeParameter>{}; 82 <TypeVariableElement, ir.TypeParameter>{};
83 83
84 final Set<ir.TreeNode> checkedNodes = new Set<ir.TreeNode>(); 84 final Set<ir.TreeNode> checkedNodes = new Set<ir.TreeNode>();
85 85
86 final Map<String, int> mixinApplicationNames = <String, int>{}; 86 final Map<LibraryElement, Map<String, int>> mixinApplicationNamesByLibrary =
87 <LibraryElement, Map<String, int>>{};
87 88
88 /// FIFO queue of work that needs to be completed before the returned AST 89 /// FIFO queue of work that needs to be completed before the returned AST
89 /// nodes are correct. 90 /// nodes are correct.
90 final Queue<WorkItem> workQueue = new Queue<WorkItem>(); 91 final Queue<WorkItem> workQueue = new Queue<WorkItem>();
91 92
92 Kernel(this.compiler); 93 Kernel(this.compiler);
93 94
94 bool hasMainMethod(Uri uri) { 95 bool hasMainMethod(Uri uri) {
95 LibraryElement library = compiler.libraryLoader.lookupLibrary(uri); 96 LibraryElement library = compiler.libraryLoader.lookupLibrary(uri);
96 return library.localLookup("main") != null; 97 return library.localLookup("main") != null;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return libraryNode; 179 return libraryNode;
179 }); 180 });
180 } 181 }
181 182
182 /// Compute a name for [cls]. We want to have unique names in a library, but 183 /// Compute a name for [cls]. We want to have unique names in a library, but
183 /// mixin applications can lead to multiple classes with the same name. So 184 /// mixin applications can lead to multiple classes with the same name. So
184 /// for those we append `#` and a number. 185 /// for those we append `#` and a number.
185 String computeName(ClassElement cls) { 186 String computeName(ClassElement cls) {
186 String name = cls.name; 187 String name = cls.name;
187 if (!cls.isUnnamedMixinApplication) return name; 188 if (!cls.isUnnamedMixinApplication) return name;
189 Map<String, int> mixinApplicationNames =
190 mixinApplicationNamesByLibrary.putIfAbsent(
191 cls.library.implementation, () => <String, int>{});
188 mixinApplicationNames.putIfAbsent(name, () => 0); 192 mixinApplicationNames.putIfAbsent(name, () => 0);
kasperl 2016/07/01 13:05:14 int count = mixinApplicationNames.putIfAbsent(name
ahe 2016/07/01 13:14:15 I like that better.
189 int count = mixinApplicationNames[name]++; 193 int count = mixinApplicationNames[name]++;
190 return "$name#$count"; 194 return "$name#$count";
191 } 195 }
192 196
193 ir.Class classToIr(ClassElement cls) { 197 ir.Class classToIr(ClassElement cls) {
194 cls = cls.declaration; 198 cls = cls.declaration;
195 return classes.putIfAbsent(cls, () { 199 return classes.putIfAbsent(cls, () {
196 cls.ensureResolved(compiler.resolution); 200 cls.ensureResolved(compiler.resolution);
197 compiler.enqueuer.resolution.emptyDeferredTaskQueue(); 201 compiler.enqueuer.resolution.emptyDeferredTaskQueue();
198 String name = computeName(cls); 202 String name = computeName(cls);
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 659 }
656 660
657 class ConstructorTarget { 661 class ConstructorTarget {
658 final ConstructorElement element; 662 final ConstructorElement element;
659 final DartType type; 663 final DartType type;
660 664
661 ConstructorTarget(this.element, this.type); 665 ConstructorTarget(this.element, this.type);
662 666
663 String toString() => "ConstructorTarget($element, $type)"; 667 String toString() => "ConstructorTarget($element, $type)";
664 } 668 }
OLDNEW
« no previous file with comments | « no previous file | submodules.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698