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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_mirrors.dart

Issue 562853002: Recompute librariesByName after loading a deferred library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart._js_mirrors; 5 library dart._js_mirrors;
6 6
7 import 'shared/runtime_data.dart' as encoding; 7 import 'shared/runtime_data.dart' as encoding;
8 import 'shared/embedded_names.dart' show 8 import 'shared/embedded_names.dart' show
9 ALL_CLASSES, 9 ALL_CLASSES,
10 LAZIES, 10 LAZIES,
(...skipping 30 matching lines...) Expand all
41 TypeVariable, 41 TypeVariable,
42 UnimplementedNoSuchMethodError, 42 UnimplementedNoSuchMethodError,
43 createRuntimeType, 43 createRuntimeType,
44 createUnmangledInvocationMirror, 44 createUnmangledInvocationMirror,
45 getMangledTypeName, 45 getMangledTypeName,
46 getMetadata, 46 getMetadata,
47 getRuntimeType, 47 getRuntimeType,
48 runtimeTypeToString, 48 runtimeTypeToString,
49 setRuntimeTypeInfo, 49 setRuntimeTypeInfo,
50 throwInvalidReflectionError, 50 throwInvalidReflectionError,
51 TypeImpl; 51 TypeImpl,
52 deferredLoadHook;
52 53
53 import 'dart:_interceptors' show 54 import 'dart:_interceptors' show
54 Interceptor, 55 Interceptor,
55 JSArray, 56 JSArray,
56 JSExtendableArray, 57 JSExtendableArray,
57 getInterceptor; 58 getInterceptor;
58 59
59 import 'dart:_js_names'; 60 import 'dart:_js_names';
60 61
61 const String METHODS_WITH_OPTIONAL_ARGUMENTS = r'$methodsWithOptionalArguments'; 62 const String METHODS_WITH_OPTIONAL_ARGUMENTS = r'$methodsWithOptionalArguments';
(...skipping 28 matching lines...) Expand all
90 91
91 final IsolateMirror isolate = new JsIsolateMirror(); 92 final IsolateMirror isolate = new JsIsolateMirror();
92 93
93 JsTypeMirror get dynamicType => _dynamicType; 94 JsTypeMirror get dynamicType => _dynamicType;
94 JsTypeMirror get voidType => _voidType; 95 JsTypeMirror get voidType => _voidType;
95 96
96 static final JsTypeMirror _dynamicType = 97 static final JsTypeMirror _dynamicType =
97 new JsTypeMirror(const Symbol('dynamic')); 98 new JsTypeMirror(const Symbol('dynamic'));
98 static final JsTypeMirror _voidType = new JsTypeMirror(const Symbol('void')); 99 static final JsTypeMirror _voidType = new JsTypeMirror(const Symbol('void'));
99 100
100 static final Map<String, List<LibraryMirror>> librariesByName = 101 static Map<String, List<LibraryMirror>> _librariesByName;
101 computeLibrariesByName(); 102
103 // Will be set to `true` when we have installed a hook on [deferredLoadHook]
104 // to avoid installing it multiple times.
105 static bool _hasInstalledDeferredLoadHook = false;
106
107 static Map<String, List<LibraryMirror>> get librariesByName {
108 if (_librariesByName == null) {
109 _librariesByName = computeLibrariesByName();
110 if (!_hasInstalledDeferredLoadHook) {
111 _hasInstalledDeferredLoadHook = true;
112 // After a deferred import has been loaded new libraries might have
113 // been created, so in the hook we erase _librariesByName, so it will be
114 // recomputed on the next access.
115 deferredLoadHook = () => _librariesByName = null;
116 }
117 }
118 return _librariesByName;
119 }
102 120
103 Map<Uri, LibraryMirror> get libraries { 121 Map<Uri, LibraryMirror> get libraries {
104 if (_cachedLibraries != null) return _cachedLibraries; 122 if (_cachedLibraries != null) return _cachedLibraries;
105 Map<Uri, LibraryMirror> result = new Map(); 123 Map<Uri, LibraryMirror> result = new Map();
106 for (List<LibraryMirror> list in librariesByName.values) { 124 for (List<LibraryMirror> list in librariesByName.values) {
107 for (LibraryMirror library in list) { 125 for (LibraryMirror library in list) {
108 result[library.uri] = library; 126 result[library.uri] = library;
109 } 127 }
110 } 128 }
111 return _cachedLibraries = 129 return _cachedLibraries =
(...skipping 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 // have a part (following a '.') that starts with '_'. 2955 // have a part (following a '.') that starts with '_'.
2938 const int UNDERSCORE = 0x5f; 2956 const int UNDERSCORE = 0x5f;
2939 if (name.isEmpty) return true; 2957 if (name.isEmpty) return true;
2940 int index = -1; 2958 int index = -1;
2941 do { 2959 do {
2942 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; 2960 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false;
2943 index = name.indexOf('.', index + 1); 2961 index = name.indexOf('.', index + 1);
2944 } while (index >= 0 && index + 1 < name.length); 2962 } while (index >= 0 && index + 1 < name.length);
2945 return true; 2963 return true;
2946 } 2964 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_helper.dart ('k') | tests/lib/mirrors/deferred_mirrors_update_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698