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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/registry.dart

Issue 661783002: dart2js: Add support for static fields to new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart ('k') | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 dart2js.js_emitter.program_builder; 5 part of dart2js.js_emitter.program_builder;
6 6
7 /// A Fragment maps [LibraryElement]s to their [Element]s. 7 /// A Fragment maps [LibraryElement]s to their [Element]s.
8 /// 8 ///
9 /// Fundamentally, this class nicely encapsulates a 9 /// Fundamentally, this class nicely encapsulates a
10 /// `Map<LibraryElement, List<Element>>`. 10 /// `Map<LibraryElement, List<Element>>`.
11 class Fragment { 11 class Fragment {
12 final Map<LibraryElement, List<Element>> _mapping = 12 final Map<LibraryElement, List<Element>> _mapping =
13 <LibraryElement, List<Element>>{}; 13 <LibraryElement, List<Element>>{};
14 14
15 // It is very common to access the same library multiple times in a row, so 15 // It is very common to access the same library multiple times in a row, so
16 // we cache the last access. 16 // we cache the last access.
17 LibraryElement _lastLibrary; 17 LibraryElement _lastLibrary;
18 List<Element> _lastElements; 18 List<Element> _lastElements;
19 19
20 /// A unique name representing this fragment. 20 /// A unique name representing this fragment.
21 final String name; 21 final String name;
22 final OutputUnit outputUnit; 22 final OutputUnit outputUnit;
23 23
24 Fragment.main(this.outputUnit) : name = ""; 24 Fragment.main(this.outputUnit) : name = "";
25 Fragment.deferred(this.outputUnit, this.name); 25
26 Fragment.deferred(this.outputUnit, this.name) {
27 assert(name != "");
28 }
26 29
27 void add(LibraryElement library, Element element) { 30 void add(LibraryElement library, Element element) {
28 if (_lastLibrary != library) { 31 if (_lastLibrary != library) {
29 _lastLibrary = library; 32 _lastLibrary = library;
30 _lastElements = _mapping.putIfAbsent(library, () => <Element>[]); 33 _lastElements = _mapping.putIfAbsent(library, () => <Element>[]);
31 } 34 }
32 _lastElements.add(element); 35 _lastElements.add(element);
33 } 36 }
34 37
35 int get length => _mapping.length; 38 int get length => _mapping.length;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 targetFragment.add(element.library, element); 88 targetFragment.add(element.library, element);
86 } 89 }
87 } 90 }
88 91
89 Holder registerHolder(String name) { 92 Holder registerHolder(String name) {
90 return _holdersMap.putIfAbsent( 93 return _holdersMap.putIfAbsent(
91 name, 94 name,
92 () => new Holder(name, _holdersMap.length)); 95 () => new Holder(name, _holdersMap.length));
93 } 96 }
94 } 97 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698