8dd2b15951
This is implemented as a separate pass, although going forward I would like the new frontend to insert these checks. R=kmillikin@google.com Review-Url: https://codereview.chromium.org/2619193003 .
28 lines
922 B
Dart
28 lines
922 B
Dart
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
library kernel.repository;
|
|
|
|
import 'ast.dart';
|
|
|
|
/// Keeps track of which [Library] objects have been created for a given URI.
|
|
///
|
|
/// To load different files into the same IR, pass in the same repository
|
|
/// object to the loaders.
|
|
class Repository {
|
|
final Map<Uri, Library> _uriToLibrary = <Uri, Library>{};
|
|
final List<Library> libraries = <Library>[];
|
|
|
|
Library getLibraryReference(Uri uri) {
|
|
assert(uri.hasScheme);
|
|
return _uriToLibrary.putIfAbsent(uri, () => _buildLibraryReference(uri));
|
|
}
|
|
|
|
Library _buildLibraryReference(Uri uri) {
|
|
assert(uri.hasScheme);
|
|
var library = new Library(uri, isExternal: true)..fileUri = '$uri';
|
|
libraries.add(library);
|
|
return library;
|
|
}
|
|
}
|