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

Side by Side Diff: pkg/compiler/lib/src/kernel/env.dart

Issue 2972523002: Implement JsKernelToElementMap through KernelToElementMapBase (Closed)
Patch Set: Updated cf. comments Created 3 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 | « pkg/compiler/lib/src/kernel/element_map_impl.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 library dart2js.kernel.env; 5 library dart2js.kernel.env;
6 6
7 import 'package:kernel/ast.dart' as ir; 7 import 'package:kernel/ast.dart' as ir;
8 import 'package:kernel/clone.dart'; 8 import 'package:kernel/clone.dart';
9 import 'package:kernel/type_algebra.dart'; 9 import 'package:kernel/type_algebra.dart';
10 10
11 import '../common.dart'; 11 import '../common.dart';
12 import '../common/resolution.dart'; 12 import '../common/resolution.dart';
13 import '../constants/constructors.dart'; 13 import '../constants/constructors.dart';
14 import '../constants/expressions.dart'; 14 import '../constants/expressions.dart';
15 import '../constants/values.dart'; 15 import '../constants/values.dart';
16 import '../elements/entities.dart'; 16 import '../elements/entities.dart';
17 import '../elements/types.dart'; 17 import '../elements/types.dart';
18 import '../ordered_typeset.dart'; 18 import '../ordered_typeset.dart';
19 import '../ssa/kernel_impact.dart'; 19 import '../ssa/kernel_impact.dart';
20 import 'element_map.dart'; 20 import 'element_map.dart';
21 import 'element_map_impl.dart'; 21 import 'element_map_impl.dart';
22 import 'element_map_mixins.dart'; 22 import 'element_map_mixins.dart';
23 23
24 /// Environment for fast lookup of program libraries. 24 /// Environment for fast lookup of program libraries.
25 class ProgramEnv { 25 class ProgramEnv {
26 final Set<ir.Program> programs = new Set<ir.Program>(); 26 final Set<ir.Program> _programs = new Set<ir.Program>();
27 27
28 Map<Uri, LibraryEnv> _libraryMap; 28 Map<Uri, LibraryEnv> _libraryMap;
29 29
30 /// TODO(johnniwinther): Handle arbitrary load order if needed. 30 /// TODO(johnniwinther): Handle arbitrary load order if needed.
31 ir.Member get mainMethod => programs.first?.mainMethod; 31 ir.Member get mainMethod => _programs.first?.mainMethod;
32 32
33 void addProgram(ir.Program program) { 33 void addProgram(ir.Program program) {
34 if (programs.add(program)) { 34 if (_programs.add(program)) {
35 if (_libraryMap != null) { 35 if (_libraryMap != null) {
36 _addLibraries(program); 36 _addLibraries(program);
37 } 37 }
38 } 38 }
39 } 39 }
40 40
41 void _addLibraries(ir.Program program) { 41 void _addLibraries(ir.Program program) {
42 for (ir.Library library in program.libraries) { 42 for (ir.Library library in program.libraries) {
43 _libraryMap[library.importUri] = new LibraryEnv(library); 43 _libraryMap[library.importUri] = new LibraryEnv(library);
44 } 44 }
45 } 45 }
46 46
47 void _ensureLibraryMap() { 47 void _ensureLibraryMap() {
48 if (_libraryMap == null) { 48 if (_libraryMap == null) {
49 _libraryMap = <Uri, LibraryEnv>{}; 49 _libraryMap = <Uri, LibraryEnv>{};
50 for (ir.Program program in programs) { 50 for (ir.Program program in _programs) {
51 _addLibraries(program); 51 _addLibraries(program);
52 } 52 }
53 } 53 }
54 } 54 }
55 55
56 /// Return the [LibraryEnv] for the library with the canonical [uri]. 56 /// Return the [LibraryEnv] for the library with the canonical [uri].
57 LibraryEnv lookupLibrary(Uri uri) { 57 LibraryEnv lookupLibrary(Uri uri) {
58 _ensureLibraryMap(); 58 _ensureLibraryMap();
59 return _libraryMap[uri]; 59 return _libraryMap[uri];
60 } 60 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } else { 400 } else {
401 throw new SpannableAssertionFailure( 401 throw new SpannableAssertionFailure(
402 field, 402 field,
403 "Unexpected field $field in " 403 "Unexpected field $field in "
404 "KernelWorldBuilder._getConstructorConstant"); 404 "KernelWorldBuilder._getConstructorConstant");
405 } 405 }
406 } 406 }
407 return _constant; 407 return _constant;
408 } 408 }
409 } 409 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_map_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698