Rename Program to Component
Change-Id: I1a3cc03fba9783807fa637a9d42fdbad68ee7686
Reviewed-on: https://dart-review.googlesource.com/31040
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart b/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart
index 88bdde6..9340caf 100644
--- a/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart
@@ -114,16 +114,16 @@
/// Each value is the compilation result of the key library.
final Map<Uri, LibraryCompilationResult> _results = {};
- /// The [Program] with currently valid libraries. When a file is invalidated,
- /// we remove the file, its library, and everything affected from [_program].
- Program _program = new Program();
+ /// The [Component] with currently valid libraries. When a file is invalidated,
+ /// we remove the file, its library, and everything affected from [_component].
+ Component _component = new Component();
/// Each key is the file system URI of a library.
/// Each value is the libraries that directly depend on the key library.
final Map<Uri, Set<Uri>> _directLibraryDependencies = {};
/// Each key is the file system URI of a library.
- /// Each value is the [Library] that is still in the [_program].
+ /// Each value is the [Library] that is still in the [_component].
final Map<Uri, Library> _uriToLibrary = {};
/// Each key is the file system URI of a part.
@@ -227,9 +227,9 @@
var dillTarget =
new DillTarget(_options.ticker, uriTranslator, _options.target);
- // Append all libraries what we still have in the current program.
+ // Append all libraries what we still have in the current component.
await _logger.runAsync('Load dill libraries', () async {
- dillTarget.loader.appendLibraries(_program);
+ dillTarget.loader.appendLibraries(_component);
await dillTarget.buildOutlines();
});
@@ -238,23 +238,23 @@
uriTranslator, new AnalyzerMetadataCollector());
kernelTarget.read(uri);
- // Compile the entry point into the new program.
- _program = await _logger.runAsync('Compile', () async {
- await kernelTarget.buildOutlines(nameRoot: _program.root);
- return await kernelTarget.buildProgram() ?? _program;
+ // Compile the entry point into the new component.
+ _component = await _logger.runAsync('Compile', () async {
+ await kernelTarget.buildOutlines(nameRoot: _component.root);
+ return await kernelTarget.buildComponent() ?? _component;
});
// TODO(scheglov) Only for new libraries?
- _program.computeCanonicalNames();
+ _component.computeCanonicalNames();
_logger.run('Compute dependencies', _computeDependencies);
// TODO(scheglov) Can we keep the same instance?
var types = new TypeEnvironment(
- new CoreTypes(_program), new ClassHierarchy(_program));
+ new CoreTypes(_component), new ClassHierarchy(_component));
// Add results for new libraries.
- for (var library in _program.libraries) {
+ for (var library in _component.libraries) {
if (!_results.containsKey(library.importUri)) {
Map<Uri, List<CollectedResolution>> libraryResolutions =
kernelTarget.resolutions[library.fileUri];
@@ -276,7 +276,7 @@
}
var libraryResult = new LibraryCompilationResult(
- _program, types, library.importUri, library, files);
+ _component, types, library.importUri, library, files);
_results[library.importUri] = libraryResult;
}
}
@@ -299,9 +299,9 @@
if (library == null) return;
// Invalidate the library.
- _program.libraries.remove(library);
- _program.root.removeChild('${library.importUri}');
- _program.uriToSource.remove(libraryUri);
+ _component.libraries.remove(library);
+ _component.root.removeChild('${library.importUri}');
+ _component.uriToSource.remove(libraryUri);
_results.remove(library.importUri);
// Recursively invalidate dependencies.
@@ -314,7 +314,7 @@
invalidateLibrary(libraryUri);
}
- /// Recompute [_directLibraryDependencies] for the current [_program].
+ /// Recompute [_directLibraryDependencies] for the current [_component].
void _computeDependencies() {
_directLibraryDependencies.clear();
_uriToLibrary.clear();
@@ -341,8 +341,8 @@
}
}
- // Record dependencies for every library in the program.
- _program.libraries.forEach(processLibrary);
+ // Record dependencies for every library in the component.
+ _component.libraries.forEach(processLibrary);
}
Future<T> _runWithFrontEndContext<T>(String msg, Future<T> f()) async {
@@ -355,13 +355,13 @@
/// The compilation result for a single library.
class LibraryCompilationResult {
- /// The full current [Program]. It has all libraries that are required by
+ /// The full current [Component]. It has all libraries that are required by
/// this library, but might also have other libraries, that are not required.
///
/// The object is mutable, and is changed when files are invalidated.
- final Program program;
+ final Component component;
- /// The [TypeEnvironment] for the [program].
+ /// The [TypeEnvironment] for the [component].
final TypeEnvironment types;
/// The absolute URI of the library.
@@ -374,7 +374,7 @@
final Map<Uri, FileCompilationResult> files;
LibraryCompilationResult(
- this.program, this.types, this.uri, this.kernel, this.files);
+ this.component, this.types, this.uri, this.kernel, this.files);
}
/// The [DietListener] that record resolution information.
diff --git a/pkg/analyzer/lib/src/dart/analysis/kernel_context.dart b/pkg/analyzer/lib/src/dart/analysis/kernel_context.dart
index e0323b2..0ce8c48 100644
--- a/pkg/analyzer/lib/src/dart/analysis/kernel_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/kernel_context.dart
@@ -88,7 +88,7 @@
// This is probably OK, because we consume them lazily.
var libraryMap = <String, kernel.Library>{};
var libraryExistMap = <String, bool>{};
- for (var library in compilationResult.program.libraries) {
+ for (var library in compilationResult.component.libraries) {
String uriStr = library.importUri.toString();
libraryMap[uriStr] = library;
FileState file = fsState.getFileForUri(library.importUri);
diff --git a/pkg/analyzer/lib/src/dart/analysis/kernel_metadata.dart b/pkg/analyzer/lib/src/dart/analysis/kernel_metadata.dart
index 9ec5360..f96c5c6 100644
--- a/pkg/analyzer/lib/src/dart/analysis/kernel_metadata.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/kernel_metadata.dart
@@ -21,7 +21,7 @@
/// Return the [AnalyzerMetadata] for the [node], or `null` absent.
static AnalyzerMetadata forNode(kernel.TreeNode node) {
var repository =
- node.enclosingProgram.metadata[AnalyzerMetadataRepository.TAG];
+ node.enclosingComponent.metadata[AnalyzerMetadataRepository.TAG];
if (repository != null) {
return repository.mapping[node];
}
diff --git a/pkg/analyzer/lib/src/kernel/loader.dart b/pkg/analyzer/lib/src/kernel/loader.dart
index 24808f0..73dd076 100644
--- a/pkg/analyzer/lib/src/kernel/loader.dart
+++ b/pkg/analyzer/lib/src/kernel/loader.dart
@@ -90,7 +90,7 @@
}
class DartLoader implements ReferenceLevelLoader {
- final ast.Program program;
+ final ast.Component component;
final ApplicationRoot applicationRoot;
final Bimap<ClassElement, ast.Class> _classes =
new Bimap<ClassElement, ast.Class>();
@@ -119,7 +119,7 @@
bool get strongMode => context.analysisOptions.strongMode;
- DartLoader(this.program, DartOptions options, Packages packages,
+ DartLoader(this.component, DartOptions options, Packages packages,
{DartSdk dartSdk,
AnalysisContext context,
this.ignoreRedirectingFactories: true})
@@ -145,7 +145,7 @@
..isExternal = true
..name = getLibraryName(element)
..fileUri = element.source.uri;
- program.libraries.add(library..parent = program);
+ component.libraries.add(library..parent = component);
_libraries[element] = library;
}
return library;
@@ -732,7 +732,7 @@
}
}
- void loadSdkInterface(ast.Program program, Target target) {
+ void loadSdkInterface(ast.Component component, Target target) {
var requiredSdkMembers = target.requiredSdkClasses;
for (var libraryUri in requiredSdkMembers.keys) {
var source = context.sourceFactory.forUri2(Uri.parse(libraryUri));
@@ -764,8 +764,8 @@
}
}
}
- for (int i = 0; i < program.libraries.length; ++i) {
- var library = program.libraries[i];
+ for (int i = 0; i < component.libraries.length; ++i) {
+ var library = component.libraries[i];
if (compileSdk || library.importUri.scheme != 'dart') {
ensureLibraryIsLoaded(library);
}
@@ -777,7 +777,7 @@
/// This operation may be expensive and should only be used for diagnostics.
List<String> getLoadedFileNames() {
var list = <String>[];
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
LibraryElement element = context.computeLibraryElement(context
.sourceFactory
.forUri2(applicationRoot.absoluteUri(library.importUri)));
@@ -829,14 +829,14 @@
new ast.Name('main'),
ast.ProcedureKind.Method,
new ast.FunctionNode(new ast.ExpressionStatement(new ast.Throw(
- new ast.StringLiteral('Program has no main method')))),
+ new ast.StringLiteral('Component has no main method')))),
isStatic: true)
..fileUri = library.fileUri;
library.addMember(main);
return main;
}
- void loadProgram(Uri mainLibrary, {Target target, bool compileSdk}) {
+ void loadComponent(Uri mainLibrary, {Target target, bool compileSdk}) {
ast.Library library = getLibraryReferenceFromUri(mainLibrary);
ensureLibraryIsLoaded(library);
var mainMethod = _getMainMethod(mainLibrary);
@@ -844,7 +844,7 @@
if (mainMethod == null) {
mainMethod = _makeMissingMainMethod(library);
}
- program.mainMethod = mainMethod;
+ component.mainMethod = mainMethod;
for (LibraryElement libraryElement in libraryElements) {
for (CompilationUnitElement compilationUnitElement
in libraryElement.units) {
@@ -858,7 +858,7 @@
// The source's contents could not be accessed.
sourceCode = const <int>[];
}
- program.uriToSource[source.uri] =
+ component.uriToSource[source.uri] =
new ast.Source(lineInfo.lineStarts, sourceCode);
}
}
@@ -896,7 +896,7 @@
String lastPackagePath;
bool lastStrongMode;
- Future<DartLoader> getLoader(ast.Program program, DartOptions options,
+ Future<DartLoader> getLoader(ast.Component component, DartOptions options,
{String packageDiscoveryPath}) async {
if (dartSdk == null ||
lastSdk != options.sdk ||
@@ -912,7 +912,7 @@
packages = await createPackages(options.packagePath,
discoveryPath: packageDiscoveryPath);
}
- return new DartLoader(program, options, packages, dartSdk: dartSdk);
+ return new DartLoader(component, options, packages, dartSdk: dartSdk);
}
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart b/pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart
index 952d08c..fcc0791 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart
@@ -401,7 +401,7 @@
// Remember Kernel libraries produced by the compiler.
var libraryMap = <String, kernel.Library>{};
var libraryExistMap = <String, bool>{};
- for (var library in libraryResult.program.libraries) {
+ for (var library in libraryResult.component.libraries) {
String uriStr = library.importUri.toString();
libraryMap[uriStr] = library;
FileState file = fsState.getFileForUri(library.importUri);
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index ab0a2ae..326e6a0 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -323,7 +323,7 @@
}
/**
- * A node representing a resolved element of the program. The kind of
+ * A node representing a resolved element of the component. The kind of
* elements that need an [ElementTypeInformation] are:
*
* - Functions (including getters and setters)
diff --git a/pkg/compiler/lib/src/io/kernel_source_information.dart b/pkg/compiler/lib/src/io/kernel_source_information.dart
index 93d324e..586b0f7 100644
--- a/pkg/compiler/lib/src/io/kernel_source_information.dart
+++ b/pkg/compiler/lib/src/io/kernel_source_information.dart
@@ -90,7 +90,7 @@
ir.Location location;
if (offset != null) {
location = node.location;
- location = node.enclosingProgram.getLocation(location.file, offset);
+ location = node.enclosingComponent.getLocation(location.file, offset);
} else {
while (node != null && node.fileOffset == ir.TreeNode.noOffset) {
node = node.parent;
diff --git a/pkg/compiler/lib/src/kernel/dart2js_target.dart b/pkg/compiler/lib/src/kernel/dart2js_target.dart
index db3de60..ba98796 100644
--- a/pkg/compiler/lib/src/kernel/dart2js_target.dart
+++ b/pkg/compiler/lib/src/kernel/dart2js_target.dart
@@ -69,7 +69,7 @@
{void logger(String msg)}) {}
@override
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {}
@override
diff --git a/pkg/compiler/lib/src/kernel/element_map.dart b/pkg/compiler/lib/src/kernel/element_map.dart
index bfb8531..cc058e6 100644
--- a/pkg/compiler/lib/src/kernel/element_map.dart
+++ b/pkg/compiler/lib/src/kernel/element_map.dart
@@ -126,11 +126,11 @@
abstract class KernelToElementMapForImpact extends KernelToElementMap {
NativeBasicData get nativeBasicData;
- /// Adds libraries in [program] to the set of libraries.
+ /// Adds libraries in [component] to the set of libraries.
///
- /// The main method of the first program is used as the main method for the
+ /// The main method of the first component is used as the main method for the
/// compilation.
- void addProgram(ir.Program program);
+ void addProgram(ir.Component component);
/// Returns the [ConstructorEntity] corresponding to a super initializer in
/// [constructor].
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 53b132c..ccec600 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -1216,12 +1216,12 @@
@override
NativeBasicData get nativeBasicData => _frontendStrategy.nativeBasicData;
- /// Adds libraries in [program] to the set of libraries.
+ /// Adds libraries in [component] to the set of libraries.
///
- /// The main method of the first program is used as the main method for the
+ /// The main method of the first component is used as the main method for the
/// compilation.
- void addProgram(ir.Program program) {
- _env.addProgram(program);
+ void addProgram(ir.Component component) {
+ _env.addProgram(component);
}
@override
diff --git a/pkg/compiler/lib/src/kernel/env.dart b/pkg/compiler/lib/src/kernel/env.dart
index 782c999..0870b99 100644
--- a/pkg/compiler/lib/src/kernel/env.dart
+++ b/pkg/compiler/lib/src/kernel/env.dart
@@ -23,25 +23,25 @@
import 'element_map_mixins.dart';
import 'kelements.dart' show KImport;
-/// Environment for fast lookup of program libraries.
+/// Environment for fast lookup of component libraries.
class ProgramEnv {
- final Set<ir.Program> _programs = new Set<ir.Program>();
+ final Set<ir.Component> _programs = new Set<ir.Component>();
Map<Uri, LibraryEnv> _libraryMap;
/// TODO(johnniwinther): Handle arbitrary load order if needed.
ir.Member get mainMethod => _programs.first?.mainMethod;
- void addProgram(ir.Program program) {
- if (_programs.add(program)) {
+ void addProgram(ir.Component component) {
+ if (_programs.add(component)) {
if (_libraryMap != null) {
- _addLibraries(program);
+ _addLibraries(component);
}
}
}
- void _addLibraries(ir.Program program) {
- for (ir.Library library in program.libraries) {
+ void _addLibraries(ir.Component component) {
+ for (ir.Library library in component.libraries) {
_libraryMap[library.importUri] = new LibraryEnv(library);
}
}
@@ -49,8 +49,8 @@
void _ensureLibraryMap() {
if (_libraryMap == null) {
_libraryMap = <Uri, LibraryEnv>{};
- for (ir.Program program in _programs) {
- _addLibraries(program);
+ for (ir.Component component in _programs) {
+ _addLibraries(component);
}
}
}
diff --git a/pkg/compiler/lib/src/library_loader.dart b/pkg/compiler/lib/src/library_loader.dart
index a2d7c31..ace0223 100644
--- a/pkg/compiler/lib/src/library_loader.dart
+++ b/pkg/compiler/lib/src/library_loader.dart
@@ -815,8 +815,7 @@
}
}
-/// A loader that builds a kernel IR representation of the program (or set of
-/// libraries).
+/// A loader that builds a kernel IR representation of the component.
///
/// It supports loading both .dart source files or pre-compiled .dill files.
/// When given .dart source files, it invokes the shared frontend
@@ -832,7 +831,7 @@
final api.CompilerInput compilerInput;
/// Holds the mapping of Kernel IR to KElements that is constructed as a
- /// result of loading a program.
+ /// result of loading a component.
final KernelToElementMapForImpactImpl _elementMap;
final bool verbose;
@@ -847,7 +846,7 @@
: _allLoadedLibraries = new List<LibraryEntity>(),
super(measurer);
- /// Loads an entire Kernel [Program] from a file on disk (note, not just a
+ /// Loads an entire Kernel [Component] from a file on disk (note, not just a
/// library, so this name is actually a bit of a misnomer).
// TODO(efortuna): Rename this once the Element library loader class goes
// away.
@@ -855,12 +854,12 @@
{bool skipFileWithPartOfTag: false}) {
return measure(() async {
var isDill = resolvedUri.path.endsWith('.dill');
- ir.Program program;
+ ir.Component component;
if (isDill) {
api.Input input = await compilerInput.readFromUri(resolvedUri,
inputKind: api.InputKind.binary);
- program = new ir.Program();
- new BinaryBuilder(input.data).readProgram(program);
+ component = new ir.Component();
+ new BinaryBuilder(input.data).readComponent(component);
} else {
bool strongMode = _elementMap.options.strongMode;
String platform = strongMode
@@ -871,28 +870,28 @@
new Dart2jsTarget(new TargetFlags(strongMode: strongMode)),
platformBinaries.resolve(platform),
_packageConfig);
- program = await fe.compile(
+ component = await fe.compile(
initializedCompilerState,
verbose,
new CompilerFileSystem(compilerInput),
(e) => reportFrontEndMessage(reporter, e),
resolvedUri);
}
- if (program == null) return null;
- return createLoadedLibraries(program);
+ if (component == null) return null;
+ return createLoadedLibraries(component);
});
}
// Only visible for unit testing.
- LoadedLibraries createLoadedLibraries(ir.Program program) {
- _elementMap.addProgram(program);
+ LoadedLibraries createLoadedLibraries(ir.Component component) {
+ _elementMap.addProgram(component);
LibraryEntity rootLibrary = null;
- Iterable<ir.Library> libraries = program.libraries;
- if (program.mainMethod != null) {
- var root = program.mainMethod.enclosingLibrary;
+ Iterable<ir.Library> libraries = component.libraries;
+ if (component.mainMethod != null) {
+ var root = component.mainMethod.enclosingLibrary;
rootLibrary = _elementMap.lookupLibrary(root.importUri);
- // Filter unreachable libraries: [Program] was built by linking in the
+ // Filter unreachable libraries: [Component] was built by linking in the
// entire SDK libraries, not all of them are used. We include anything
// that is reachable from `main`. Note that all internal libraries that
// the compiler relies on are reachable from `dart:core`.
@@ -907,7 +906,7 @@
search(root);
// Libraries dependencies do not show implicit imports to `dart:core`.
- var dartCore = program.libraries.firstWhere((lib) {
+ var dartCore = component.libraries.firstWhere((lib) {
return lib.importUri.scheme == 'dart' && lib.importUri.path == 'core';
});
search(dartCore);
diff --git a/pkg/compiler/tool/generate_kernel.dart b/pkg/compiler/tool/generate_kernel.dart
index 9887aaa..a649997 100644
--- a/pkg/compiler/tool/generate_kernel.dart
+++ b/pkg/compiler/tool/generate_kernel.dart
@@ -40,8 +40,8 @@
}
Uri entry = Uri.base.resolve(nativeToUriPath(flags.rest.first));
- var program = await kernelForProgram(entry, options);
- await writeProgramToBinary(program, flags['out']);
+ var component = await kernelForProgram(entry, options);
+ await writeComponentToBinary(component, flags['out']);
}
ArgParser _argParser = new ArgParser()
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index f3f1108..810aa8e 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -197,12 +197,12 @@
if (!file.parent.existsSync()) file.parent.createSync(recursive: true);
// Useful for debugging:
- writeProgramToText(result.program, path: output + '.txt');
+ writeComponentToText(result.component, path: output + '.txt');
// TODO(jmesserly): Save .dill file so other modules can link in this one.
- //await writeProgramToBinary(program, output);
+ //await writeComponentToBinary(component, output);
var jsModule = compileToJSModule(
- result.program, result.inputSummaries, summaryUris, declaredVariables);
+ result.component, result.inputSummaries, summaryUris, declaredVariables);
var jsCode = jsProgramToCode(jsModule, moduleFormat,
buildSourceMap: argResults['source-map'] as bool,
jsUrl: path.toUri(output).toString(),
@@ -219,7 +219,7 @@
return new CompilerResult(compilerState, true);
}
-JS.Program compileToJSModule(Program p, List<Program> summaries,
+JS.Program compileToJSModule(Component p, List<Component> summaries,
List<Uri> summaryUris, Map<String, String> declaredVariables) {
var compiler = new ProgramCompiler(p, declaredVariables: declaredVariables);
return compiler.emitProgram(p, summaries, summaryUris);
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 85d73eb..d3f8a9f 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -44,10 +44,10 @@
/// Maps a library URI import, that is not in [_libraries], to the
/// corresponding Kernel summary module we imported it with.
- final _importToSummary = new Map<Library, Program>.identity();
+ final _importToSummary = new Map<Library, Component>.identity();
/// Maps a summary to the file URI we used to load it from disk.
- final _summaryToUri = new Map<Program, Uri>.identity();
+ final _summaryToUri = new Map<Component, Uri>.identity();
/// Imported libraries, and the temporaries used to refer to them.
final _imports = new Map<Library, JS.TemporaryId>();
@@ -92,7 +92,7 @@
/// The current source file URI for emitting in the source map.
Uri _currentUri;
- Program _program;
+ Component _component;
Library _currentLibrary;
@@ -200,13 +200,13 @@
final NullableInference _nullableInference;
- factory ProgramCompiler(Program program,
+ factory ProgramCompiler(Component component,
{bool emitMetadata: true,
bool replCompile: false,
Map<String, String> declaredVariables: const {}}) {
- var nativeTypes = new NativeTypeSet(program);
+ var nativeTypes = new NativeTypeSet(component);
var types = new TypeSchemaEnvironment(
- nativeTypes.coreTypes, new ClassHierarchy(program), true);
+ nativeTypes.coreTypes, new ClassHierarchy(component), true);
return new ProgramCompiler._(
nativeTypes, new JSTypeRep(types, nativeTypes.sdk),
emitMetadata: emitMetadata,
@@ -246,11 +246,11 @@
ClassHierarchy get hierarchy => types.hierarchy;
JS.Program emitProgram(
- Program p, List<Program> summaries, List<Uri> summaryUris) {
+ Component p, List<Component> summaries, List<Uri> summaryUris) {
if (_moduleItems.isNotEmpty) {
throw new StateError('Can only call emitModule once.');
}
- _program = p;
+ _component = p;
for (var i = 0; i < summaries.length; i++) {
var summary = summaries[i];
@@ -3185,7 +3185,7 @@
if (offset == -1) return null;
var fileUri = _currentUri;
if (fileUri == null) return null;
- var loc = _program.getLocation(fileUri, offset);
+ var loc = _component.getLocation(fileUri, offset);
if (loc == null) return null;
return new SourceLocation(offset,
sourceUrl: fileUri, line: loc.line - 1, column: loc.column - 1);
diff --git a/pkg/dev_compiler/lib/src/kernel/native_types.dart b/pkg/dev_compiler/lib/src/kernel/native_types.dart
index deaff11..e862eb9 100644
--- a/pkg/dev_compiler/lib/src/kernel/native_types.dart
+++ b/pkg/dev_compiler/lib/src/kernel/native_types.dart
@@ -36,9 +36,9 @@
final _nativeTypes = new HashSet<Class>.identity();
final _pendingLibraries = new HashSet<Library>.identity();
- NativeTypeSet(Program program)
- : sdk = new LibraryIndex.coreLibraries(program),
- coreTypes = new CoreTypes(program) {
+ NativeTypeSet(Component component)
+ : sdk = new LibraryIndex.coreLibraries(component),
+ coreTypes = new CoreTypes(component) {
// First, core types:
// TODO(vsm): If we're analyzing against the main SDK, those
// types are not explicitly annotated.
diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart
index cb4f95b..1e1277a 100644
--- a/pkg/dev_compiler/lib/src/kernel/target.dart
+++ b/pkg/dev_compiler/lib/src/kernel/target.dart
@@ -63,7 +63,7 @@
{void logger(String msg)}) {}
@override
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {}
@override
diff --git a/pkg/dev_compiler/test/nullable_inference_test.dart b/pkg/dev_compiler/test/nullable_inference_test.dart
index 3d9348e..742508b 100644
--- a/pkg/dev_compiler/test/nullable_inference_test.dart
+++ b/pkg/dev_compiler/test/nullable_inference_test.dart
@@ -465,9 +465,9 @@
/// to be produced in the set of expressions that cannot be null by DDC's null
/// inference.
Future expectNotNull(String code, String expectedNotNull) async {
- var program = await kernelCompile(code);
+ var component = await kernelCompile(code);
var collector = new NotNullCollector();
- program.accept(collector);
+ component.accept(collector);
var actualNotNull =
collector.notNullExpressions.map((e) => e.toString()).join(', ');
expect(actualNotNull, equals(expectedNotNull));
@@ -485,7 +485,7 @@
int _functionNesting = 0;
@override
- visitProgram(Program node) {
+ visitComponent(Component node) {
inference ??= new NullableInference(new JSTypeRep(
new TypeSchemaEnvironment(
new CoreTypes(node), new ClassHierarchy(node), true),
@@ -495,7 +495,7 @@
inference.allowNotNullDeclarations = useAnnotations;
inference.allowPackageMetaAnnotations = useAnnotations;
}
- super.visitProgram(node);
+ super.visitComponent(node);
}
@override
@@ -542,7 +542,7 @@
fe.InitializedCompilerState _compilerState;
final _fileSystem = new MemoryFileSystem(new Uri.file('/memory/'));
-Future<Program> kernelCompile(String code) async {
+Future<Component> kernelCompile(String code) async {
var succeeded = true;
void errorHandler(fe.CompilationMessage error) {
if (error.severity == fe.Severity.error) {
@@ -577,5 +577,5 @@
fe.DdcResult result =
await fe.compile(_compilerState, [mainUri], errorHandler);
expect(succeeded, true);
- return result.program;
+ return result.component;
}
diff --git a/pkg/dev_compiler/tool/kernel_sdk.dart b/pkg/dev_compiler/tool/kernel_sdk.dart
index b94a9bb..4e8a20b 100755
--- a/pkg/dev_compiler/tool/kernel_sdk.dart
+++ b/pkg/dev_compiler/tool/kernel_sdk.dart
@@ -39,13 +39,13 @@
..target = target;
var inputs = target.extraRequiredLibraries.map(Uri.parse).toList();
- var program = await kernelForBuildUnit(inputs, options);
+ var component = await kernelForComponent(inputs, options);
var outputDir = path.dirname(outputPath);
await new Directory(outputDir).create(recursive: true);
- await writeProgramToBinary(program, outputPath);
+ await writeComponentToBinary(component, outputPath);
- var jsModule = compileToJSModule(program, [], [], {});
+ var jsModule = compileToJSModule(component, [], [], {});
var moduleFormats = {
'amd': ModuleFormat.amd,
'common': ModuleFormat.common,
diff --git a/pkg/front_end/lib/src/api_prototype/compiler_options.dart b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
index ccfe2ea..4710a15 100644
--- a/pkg/front_end/lib/src/api_prototype/compiler_options.dart
+++ b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
@@ -83,7 +83,7 @@
/// of [inputSummaries] or [sdkSummary].
List<Uri> inputSummaries = [];
- /// URIs of other kernel programs to link.
+ /// URIs of other kernel components to link.
///
/// Commonly used to link the code for the SDK libraries that was compiled
/// separately. For example, dart2js needs to link the SDK so it can
@@ -91,8 +91,8 @@
/// always embeds the SDK internally and doesn't need it as part of the
/// program.
///
- /// The programs provided here should be closed and acyclic: any libraries
- /// that they reference should be defined in a program in [linkedDependencies]
+ /// The components provided here should be closed and acyclic: any libraries
+ /// that they reference should be defined in a component in [linkedDependencies]
/// or any of the [inputSummaries] or [sdkSummary].
List<Uri> linkedDependencies = [];
@@ -125,7 +125,7 @@
/// Whether to generate code for the SDK.
///
- /// By default the front end resolves programs using a prebuilt SDK summary.
+ /// By default the front end resolves components using a prebuilt SDK summary.
/// When this option is `true`, [sdkSummary] must be null.
bool compileSdk = false;
@@ -134,7 +134,7 @@
///
/// This option has different defaults depending on the API.
///
- /// For modular APIs like `kernelForBuildUnit` and `summaryFor` the default
+ /// For modular APIs like `kernelForComponent` and `summaryFor` the default
/// behavior is `false`. These APIs want to ensure that builds are hermetic,
/// where all files that will be compiled are listed explicitly and all other
/// dependencies are covered by summary files.
@@ -169,7 +169,7 @@
/// * the set of libraries are part of a platform's SDK (e.g. dart:html for
/// dart2js, dart:ui for flutter).
///
- /// * what kernel transformations should be applied to the program
+ /// * what kernel transformations should be applied to the component
/// (async/await, mixin inlining, etc).
///
/// * how to deal with non-standard features like `native` extensions.
@@ -185,14 +185,14 @@
// verbose data (Issue #30056)
bool verbose = false;
- /// Whether to run extra verification steps to validate that compiled programs
+ /// Whether to run extra verification steps to validate that compiled components
/// are well formed.
///
/// Errors are reported via the [onError] callback.
// TODO(sigmund): ensure we don't print errors to stdout (Issue #30056)
bool verify = false;
- /// Whether to dump generated programs in a text format (also mainly for
+ /// Whether to dump generated components in a text format (also mainly for
/// debugging).
///
/// Dumped data is printed in stdout.
@@ -202,9 +202,9 @@
/// warning, etc.) is encountered during compilation.
bool setExitCodeOnProblem = false;
- /// Whether to embed the input sources in generated kernel programs.
+ /// Whether to embed the input sources in generated kernel components.
///
- /// The kernel `Program` API includes a `uriToSource` map field that is used
+ /// The kernel `Component` API includes a `uriToSource` map field that is used
/// to embed the entire contents of the source files. This part of the kernel
/// API is in flux and it is not necessary for some tools. Today it is used
/// for translating error locations and stack traces in the VM.
diff --git a/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart b/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
index aac0185..460e203 100644
--- a/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
+++ b/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
@@ -4,7 +4,7 @@
import 'dart:async' show Future;
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
import '../base/processed_options.dart' show ProcessedOptions;
@@ -22,9 +22,8 @@
bootstrapDill);
}
- /// Returns a component (nee program) whose libraries are the recompiled
- /// libraries.
- Future<Program> computeDelta({Uri entryPoint});
+ /// Returns a component whose libraries are the recompiled libraries.
+ Future<Component> computeDelta({Uri entryPoint});
/// Remove the file associated with the given file [uri] from the set of
/// valid files. This guarantees that those files will be re-read on the
diff --git a/pkg/front_end/lib/src/api_prototype/kernel_generator.dart b/pkg/front_end/lib/src/api_prototype/kernel_generator.dart
index ddf30e1..94a6d0f 100644
--- a/pkg/front_end/lib/src/api_prototype/kernel_generator.dart
+++ b/pkg/front_end/lib/src/api_prototype/kernel_generator.dart
@@ -7,7 +7,7 @@
import 'dart:async' show Future;
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
import '../base/processed_options.dart' show ProcessedOptions;
@@ -25,13 +25,13 @@
/// Generates a kernel representation of the program whose main library is in
/// the given [source].
///
-/// Intended for whole program (non-modular) compilation.
+/// Intended for whole-program (non-modular) compilation.
///
/// Given the Uri of a file containing a program's `main` method, this function
/// follows `import`, `export`, and `part` declarations to discover the whole
/// program, and converts the result to Dart Kernel format.
///
-/// If `compileSdk` in [options] is true, the generated program will include
+/// If `compileSdk` in [options] is true, the generated component will include
/// code for the SDK.
///
/// If summaries are provided in [options], the compiler will use them instead
@@ -42,19 +42,19 @@
/// The input [source] is expected to be a script with a main method, otherwise
/// an error is reported.
// TODO(sigmund): rename to kernelForScript?
-Future<Program> kernelForProgram(Uri source, CompilerOptions options) async {
+Future<Component> kernelForProgram(Uri source, CompilerOptions options) async {
var pOptions = new ProcessedOptions(options, false, [source]);
return await CompilerContext.runWithOptions(pOptions, (context) async {
- var program = (await generateKernelInternal())?.program;
- if (program == null) return null;
+ var component = (await generateKernelInternal())?.component;
+ if (component == null) return null;
- if (program.mainMethod == null) {
+ if (component.mainMethod == null) {
context.options.report(
messageMissingMain.withLocation(source, -1, noLength),
Severity.error);
return null;
}
- return program;
+ return component;
});
}
@@ -84,11 +84,11 @@
/// are also listed in the build unit sources, otherwise an error results. (It
/// is not permitted to refer to a part file declared in another build unit).
///
-/// The return value is a [Program] object with no main method set. The
-/// [Program] includes external libraries for those libraries loaded through
+/// The return value is a [Component] object with no main method set. The
+/// [Component] includes external libraries for those libraries loaded through
/// summaries.
-Future<Program> kernelForBuildUnit(
+Future<Component> kernelForComponent(
List<Uri> sources, CompilerOptions options) async {
return (await generateKernel(new ProcessedOptions(options, true, sources)))
- ?.program;
+ ?.component;
}
diff --git a/pkg/front_end/lib/src/api_prototype/summary_generator.dart b/pkg/front_end/lib/src/api_prototype/summary_generator.dart
index 8bd633a..4a2974c 100644
--- a/pkg/front_end/lib/src/api_prototype/summary_generator.dart
+++ b/pkg/front_end/lib/src/api_prototype/summary_generator.dart
@@ -43,6 +43,6 @@
Future<List<int>> summaryFor(List<Uri> sources, CompilerOptions options,
{bool truncate: false}) async {
return (await generateKernel(new ProcessedOptions(options, true, sources),
- buildSummary: true, buildProgram: false, truncateSummary: truncate))
+ buildSummary: true, buildComponent: false, truncateSummary: truncate))
?.summary;
}
diff --git a/pkg/front_end/lib/src/api_unstable/dart2js.dart b/pkg/front_end/lib/src/api_unstable/dart2js.dart
index bad1ff9..c8151c0 100644
--- a/pkg/front_end/lib/src/api_unstable/dart2js.dart
+++ b/pkg/front_end/lib/src/api_unstable/dart2js.dart
@@ -4,7 +4,7 @@
import 'dart:async' show Future;
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/target/targets.dart' show Target;
@@ -46,7 +46,7 @@
return new InitializedCompilerState(options, processedOpts);
}
-Future<Program> compile(InitializedCompilerState state, bool verbose,
+Future<Component> compile(InitializedCompilerState state, bool verbose,
FileSystem fileSystem, ErrorHandler onError, Uri input) async {
CompilerOptions options = state.options;
options
@@ -62,9 +62,9 @@
var compilerResult = await CompilerContext.runWithOptions(processedOpts,
(CompilerContext context) async {
var compilerResult = await generateKernelInternal();
- Program program = compilerResult?.program;
- if (program == null) return null;
- if (program.mainMethod == null) {
+ Component component = compilerResult?.component;
+ if (component == null) return null;
+ if (component.mainMethod == null) {
context.options.report(
messageMissingMain.withLocation(input, -1, noLength), Severity.error);
return null;
@@ -72,5 +72,5 @@
return compilerResult;
});
- return compilerResult?.program;
+ return compilerResult?.component;
}
diff --git a/pkg/front_end/lib/src/api_unstable/ddc.dart b/pkg/front_end/lib/src/api_unstable/ddc.dart
index 5e0cf2c..0b9545f 100644
--- a/pkg/front_end/lib/src/api_unstable/ddc.dart
+++ b/pkg/front_end/lib/src/api_unstable/ddc.dart
@@ -8,7 +8,7 @@
import 'package:front_end/src/api_prototype/standard_file_system.dart';
import 'package:front_end/src/base/processed_options.dart';
import 'package:front_end/src/kernel_generator_impl.dart';
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/target/targets.dart' show Target;
import '../api_prototype/compiler_options.dart';
@@ -19,10 +19,10 @@
export '../api_prototype/compilation_message.dart';
class DdcResult {
- final Program program;
- final List<Program> inputSummaries;
+ final Component component;
+ final List<Component> inputSummaries;
- DdcResult(this.program, this.inputSummaries);
+ DdcResult(this.component, this.inputSummaries);
}
Future<InitializedCompilerState> initializeCompiler(
@@ -85,10 +85,10 @@
var compilerResult = await generateKernel(processedOpts);
- var program = compilerResult?.program;
- if (program == null) return null;
+ var component = compilerResult?.component;
+ if (component == null) return null;
// This should be cached.
var summaries = await processedOpts.loadInputSummaries(null);
- return new DdcResult(program, summaries);
+ return new DdcResult(component, summaries);
}
diff --git a/pkg/front_end/lib/src/api_unstable/summary_worker.dart b/pkg/front_end/lib/src/api_unstable/summary_worker.dart
index d5c8b18..2144265 100644
--- a/pkg/front_end/lib/src/api_unstable/summary_worker.dart
+++ b/pkg/front_end/lib/src/api_unstable/summary_worker.dart
@@ -56,6 +56,6 @@
processedOpts.inputs.addAll(inputs);
var result = await generateKernel(processedOpts,
- buildSummary: true, buildProgram: false, truncateSummary: true);
+ buildSummary: true, buildComponent: false, truncateSummary: true);
return result?.summary;
}
diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
index 3dc85f7..cbe7ebc 100644
--- a/pkg/front_end/lib/src/base/processed_options.dart
+++ b/pkg/front_end/lib/src/base/processed_options.dart
@@ -6,7 +6,7 @@
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
-import 'package:kernel/kernel.dart' show CanonicalName, Location, Program;
+import 'package:kernel/kernel.dart' show CanonicalName, Component, Location;
import 'package:kernel/target/targets.dart' show Target, TargetFlags;
@@ -98,23 +98,23 @@
/// The SDK summary, or `null` if it has not been read yet.
///
- /// A summary, also referred to as "outline" internally, is a [Program] where
+ /// A summary, also referred to as "outline" internally, is a [Component] where
/// all method bodies are left out. In essence, it contains just API
/// signatures and constants. When strong-mode is enabled, the summary already
/// includes inferred types.
- Program _sdkSummaryProgram;
+ Component _sdkSummaryProgram;
/// The summary for each uri in `options.inputSummaries`.
///
- /// A summary, also referred to as "outline" internally, is a [Program] where
+ /// A summary, also referred to as "outline" internally, is a [Component] where
/// all method bodies are left out. In essence, it contains just API
/// signatures and constants. When strong-mode is enabled, the summary already
/// includes inferred types.
- List<Program> _inputSummariesPrograms;
+ List<Component> _inputSummariesPrograms;
/// Other programs that are meant to be linked and compiled with the input
/// sources.
- List<Program> _linkedDependencies;
+ List<Component> _linkedDependencies;
/// The location of the SDK, or `null` if the location hasn't been determined
/// yet.
@@ -306,18 +306,18 @@
Target get target => _target ??=
_raw.target ?? new VmTarget(new TargetFlags(strongMode: strongMode));
- /// Get an outline program that summarizes the SDK, if any.
+ /// Get an outline component that summarizes the SDK, if any.
// TODO(sigmund): move, this doesn't feel like an "option".
- Future<Program> loadSdkSummary(CanonicalName nameRoot) async {
+ Future<Component> loadSdkSummary(CanonicalName nameRoot) async {
if (_sdkSummaryProgram == null) {
if (sdkSummary == null) return null;
var bytes = await loadSdkSummaryBytes();
- _sdkSummaryProgram = loadProgram(bytes, nameRoot);
+ _sdkSummaryProgram = loadComponent(bytes, nameRoot);
}
return _sdkSummaryProgram;
}
- void set sdkSummaryComponent(Program platform) {
+ void set sdkSummaryComponent(Component platform) {
if (_sdkSummaryProgram != null) {
throw new StateError("sdkSummary already loaded.");
}
@@ -327,42 +327,42 @@
/// Get the summary programs for each of the underlying `inputSummaries`
/// provided via [CompilerOptions].
// TODO(sigmund): move, this doesn't feel like an "option".
- Future<List<Program>> loadInputSummaries(CanonicalName nameRoot) async {
+ Future<List<Component>> loadInputSummaries(CanonicalName nameRoot) async {
if (_inputSummariesPrograms == null) {
var uris = _raw.inputSummaries;
- if (uris == null || uris.isEmpty) return const <Program>[];
+ if (uris == null || uris.isEmpty) return const <Component>[];
// TODO(sigmund): throttle # of concurrent opreations.
var allBytes = await Future
.wait(uris.map((uri) => fileSystem.entityForUri(uri).readAsBytes()));
_inputSummariesPrograms =
- allBytes.map((bytes) => loadProgram(bytes, nameRoot)).toList();
+ allBytes.map((bytes) => loadComponent(bytes, nameRoot)).toList();
}
return _inputSummariesPrograms;
}
/// Load each of the [CompilerOptions.linkedDependencies] programs.
// TODO(sigmund): move, this doesn't feel like an "option".
- Future<List<Program>> loadLinkDependencies(CanonicalName nameRoot) async {
+ Future<List<Component>> loadLinkDependencies(CanonicalName nameRoot) async {
if (_linkedDependencies == null) {
var uris = _raw.linkedDependencies;
- if (uris == null || uris.isEmpty) return const <Program>[];
+ if (uris == null || uris.isEmpty) return const <Component>[];
// TODO(sigmund): throttle # of concurrent opreations.
var allBytes = await Future
.wait(uris.map((uri) => fileSystem.entityForUri(uri).readAsBytes()));
_linkedDependencies =
- allBytes.map((bytes) => loadProgram(bytes, nameRoot)).toList();
+ allBytes.map((bytes) => loadComponent(bytes, nameRoot)).toList();
}
return _linkedDependencies;
}
/// Helper to load a .dill file from [uri] using the existing [nameRoot].
- Program loadProgram(List<int> bytes, CanonicalName nameRoot) {
- Program program = new Program(nameRoot: nameRoot);
+ Component loadComponent(List<int> bytes, CanonicalName nameRoot) {
+ Component component = new Component(nameRoot: nameRoot);
// TODO(ahe): Pass file name to BinaryBuilder.
// TODO(ahe): Control lazy loading via an option.
new BinaryBuilder(bytes, filename: null, disableLazyReading: false)
- .readProgram(program);
- return program;
+ .readComponent(component);
+ return component;
}
/// Get the [UriTranslator] which resolves "package:" and "dart:" URIs.
diff --git a/pkg/front_end/lib/src/external_state_snapshot.dart b/pkg/front_end/lib/src/external_state_snapshot.dart
index cdb31e9..0484dc0 100644
--- a/pkg/front_end/lib/src/external_state_snapshot.dart
+++ b/pkg/front_end/lib/src/external_state_snapshot.dart
@@ -4,15 +4,15 @@
// TODO(ahe): Remove this file.
-import 'package:kernel/kernel.dart' show Library, Program;
+import 'package:kernel/kernel.dart' show Library, Component;
/// Helper class to work around modifications in [kernel_generator_impl.dart].
class ExternalStateSnapshot {
final List<ExternalState> snapshots;
- ExternalStateSnapshot(Program program)
+ ExternalStateSnapshot(Component component)
: snapshots = new List<ExternalState>.from(
- program.libraries.map((l) => new ExternalState(l, l.isExternal)));
+ component.libraries.map((l) => new ExternalState(l, l.isExternal)));
void restore() {
for (ExternalState state in snapshots) {
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
index 713a5e6..2be3fcf 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
@@ -6,7 +6,7 @@
import 'dart:async' show Future;
-import 'package:kernel/ast.dart' show Library, Program, Source;
+import 'package:kernel/ast.dart' show Library, Component, Source;
import '../fasta_codes.dart'
show SummaryTemplate, Template, templateDillOutlineSummary;
@@ -33,12 +33,12 @@
Template<SummaryTemplate> get outlineSummaryTemplate =>
templateDillOutlineSummary;
- /// Append compiled libraries from the given [program]. If the [filter] is
+ /// Append compiled libraries from the given [component]. If the [filter] is
/// provided, append only libraries whose [Uri] is accepted by the [filter].
- List<DillLibraryBuilder> appendLibraries(Program program,
+ List<DillLibraryBuilder> appendLibraries(Component component,
{bool filter(Uri uri), int byteCount: 0}) {
var builders = <DillLibraryBuilder>[];
- for (Library library in program.libraries) {
+ for (Library library in component.libraries) {
if (filter == null || filter(library.importUri)) {
libraries.add(library);
DillLibraryBuilder builder = read(library.importUri, -1);
@@ -46,7 +46,7 @@
builders.add(builder);
}
}
- uriToSource.addAll(program.uriToSource);
+ uriToSource.addAll(component.uriToSource);
this.byteCount += byteCount;
return builders;
}
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_target.dart b/pkg/front_end/lib/src/fasta/dill/dill_target.dart
index 7da0d21..405f1f8 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_target.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_target.dart
@@ -43,8 +43,8 @@
}
@override
- Future<Null> buildProgram() {
- return new Future<Null>.sync(() => unsupported("buildProgram", -1, null));
+ Future<Null> buildComponent() {
+ return new Future<Null>.sync(() => unsupported("buildComponent", -1, null));
}
@override
diff --git a/pkg/front_end/lib/src/fasta/get_dependencies.dart b/pkg/front_end/lib/src/fasta/get_dependencies.dart
index b9d7999..14165b7 100644
--- a/pkg/front_end/lib/src/fasta/get_dependencies.dart
+++ b/pkg/front_end/lib/src/fasta/get_dependencies.dart
@@ -6,7 +6,7 @@
import 'dart:async' show Future;
-import 'package:kernel/kernel.dart' show loadProgramFromBytes;
+import 'package:kernel/kernel.dart' show loadComponentFromBytes;
import 'package:kernel/target/targets.dart' show Target;
@@ -47,7 +47,7 @@
new DillTarget(c.options.ticker, uriTranslator, c.options.target);
if (platform != null) {
var bytes = await fileSystem.entityForUri(platform).readAsBytes();
- var platformProgram = loadProgramFromBytes(bytes);
+ var platformProgram = loadComponentFromBytes(bytes);
dillTarget.loader.appendLibraries(platformProgram);
}
KernelTarget kernelTarget = new KernelTarget(
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index c530048..eba0a79 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -8,7 +8,7 @@
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
-import 'package:kernel/kernel.dart' show Library, Procedure, Program, Source;
+import 'package:kernel/kernel.dart' show Library, Procedure, Component, Source;
import '../api_prototype/incremental_kernel_generator.dart'
show IncrementalKernelGenerator;
@@ -52,10 +52,10 @@
: ticker = context.options.ticker;
@override
- Future<Program> computeDelta({Uri entryPoint}) async {
+ Future<Component> computeDelta({Uri entryPoint}) async {
ticker.reset();
entryPoint ??= context.options.inputs.single;
- return context.runInContext<Future<Program>>((CompilerContext c) async {
+ return context.runInContext<Future<Component>>((CompilerContext c) async {
IncrementalCompilerData data = new IncrementalCompilerData();
if (dillLoadedData == null) {
UriTranslator uriTranslator = await c.options.getUriTranslator();
@@ -67,7 +67,7 @@
try {
bytesLength += await initializeFromDill(summaryBytes, c, data);
} catch (e) {
- // We might have loaded x out of y libraries into the program.
+ // We might have loaded x out of y libraries into the component.
// To avoid any unforeseen problems start over.
bytesLength = prepareSummary(summaryBytes, uriTranslator, c, data);
}
@@ -131,10 +131,10 @@
await userCode.buildOutlines();
- // This is not the full program. It is the program including all
+ // This is not the full program. It is the component including all
// libraries loaded from .dill files.
- Program programWithDill =
- await userCode.buildProgram(verify: c.options.verify);
+ Component programWithDill =
+ await userCode.buildComponent(verify: c.options.verify);
List<Library> libraries =
new List<Library>.from(userCode.loader.libraries);
@@ -158,11 +158,12 @@
});
}
- // This is the incremental program.
+ // This component represents the parts of the program that were
+ // recompiled.
Procedure mainMethod = programWithDill == null
? data.userLoadedUriMain
: programWithDill.mainMethod;
- return new Program(libraries: libraries, uriToSource: data.uriToSource)
+ return new Component(libraries: libraries, uriToSource: data.uriToSource)
..mainMethod = mainMethod;
});
}
@@ -174,9 +175,9 @@
if (summaryBytes != null) {
ticker.logMs("Read ${c.options.sdkSummary}");
- data.program = new Program();
+ data.component = new Component();
new BinaryBuilder(summaryBytes, disableLazyReading: false)
- .readProgram(data.program);
+ .readComponent(data.component);
ticker.logMs("Deserialized ${c.options.sdkSummary}");
bytesLength += summaryBytes.length;
}
@@ -194,32 +195,32 @@
List<int> initializationBytes = await entity.readAsBytes();
if (initializationBytes != null) {
Set<Uri> prevLibraryUris = new Set<Uri>.from(
- data.program.libraries.map((Library lib) => lib.importUri));
+ data.component.libraries.map((Library lib) => lib.importUri));
ticker.logMs("Read $initializeFromDillUri");
// We're going to output all we read here so lazy loading it
// doesn't make sense.
new BinaryBuilder(initializationBytes, disableLazyReading: true)
- .readProgram(data.program);
+ .readComponent(data.component);
initializedFromDill = true;
bytesLength += initializationBytes.length;
- for (Library lib in data.program.libraries) {
+ for (Library lib in data.component.libraries) {
if (prevLibraryUris.contains(lib.importUri)) continue;
data.importUriToOrder[lib.importUri] = data.importUriToOrder.length;
}
- data.userLoadedUriMain = data.program.mainMethod;
+ data.userLoadedUriMain = data.component.mainMethod;
data.includeUserLoadedLibraries = true;
- data.uriToSource.addAll(data.program.uriToSource);
+ data.uriToSource.addAll(data.component.uriToSource);
}
}
return bytesLength;
}
void appendLibraries(IncrementalCompilerData data, int bytesLength) {
- if (data.program != null) {
+ if (data.component != null) {
dillLoadedData.loader
- .appendLibraries(data.program, byteCount: bytesLength);
+ .appendLibraries(data.component, byteCount: bytesLength);
}
ticker.logMs("Appended libraries");
}
@@ -327,7 +328,7 @@
Map<Uri, Source> uriToSource;
Map<Uri, int> importUriToOrder;
Procedure userLoadedUriMain;
- Program program;
+ Component component;
IncrementalCompilerData() {
reset();
@@ -338,6 +339,6 @@
uriToSource = <Uri, Source>{};
importUriToOrder = <Uri, int>{};
userLoadedUriMain = null;
- program = null;
+ component = null;
}
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_outline_shaker.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_outline_shaker.dart
index 979fc5f..687e5ff 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_outline_shaker.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_outline_shaker.dart
@@ -17,11 +17,11 @@
/// the included libraries. Only outlines are serialized, even for included
/// libraries, all function bodies are ignored.
void serializeTrimmedOutline(
- Sink<List<int>> sink, Program program, bool isIncluded(Uri uri)) {
+ Sink<List<int>> sink, Component component, bool isIncluded(Uri uri)) {
var data = new _RetainedDataBuilder();
- data._markRequired(program);
+ data._markRequired(component);
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
if (!isIncluded(library.importUri)) continue;
data.markAdditionalExports(library);
for (var clazz in library.classes) {
@@ -42,35 +42,36 @@
}
}
- new _TrimmedBinaryPrinter(sink, isIncluded, data).writeProgramFile(program);
+ new _TrimmedBinaryPrinter(sink, isIncluded, data)
+ .writeComponentFile(component);
}
-/// Removes unnecessary libraries, classes, and members from [program].
+/// Removes unnecessary libraries, classes, and members from [component].
///
/// This applies a simple "tree-shaking" technique: the full body of libraries
/// whose URI match [isIncluded] is preserved, and so is the outline of the
/// members and classes which are transitively visible from the
/// included libraries.
///
-/// The intent is that the resulting program has the entire code that is meant
+/// The intent is that the resulting component has the entire code that is meant
/// to be included and the minimum required to prevent dangling references and
/// allow modular program transformations.
///
-/// Note that the resulting program may include libraries not in [isIncluded],
+/// Note that the resulting component may include libraries not in [isIncluded],
/// but those will be marked as external. There should be no method bodies for
/// any members of those libraries.
-void trimProgram(Program program, bool isIncluded(Uri uri)) {
+void trimProgram(Component component, bool isIncluded(Uri uri)) {
var data = new _RetainedDataBuilder();
- data._markRequired(program);
+ data._markRequired(component);
- data.markMember(program.mainMethod);
- for (var library in program.libraries) {
+ data.markMember(component.mainMethod);
+ for (var library in component.libraries) {
if (isIncluded(library.importUri)) {
library.accept(data);
}
}
- new _KernelOutlineShaker(isIncluded, data).transform(program);
+ new _KernelOutlineShaker(isIncluded, data).transform(component);
}
/// Transformer that trims everything in the excluded libraries that is not
@@ -109,9 +110,9 @@
@override
TreeNode defaultTreeNode(TreeNode node) => node;
- void transform(Program program) {
+ void transform(Component component) {
var toRemove = new Set<Library>();
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
if (!isIncluded(library.importUri)) {
if (!data.isLibraryUsed(library)) {
toRemove.add(library);
@@ -121,7 +122,7 @@
}
}
}
- program.libraries.removeWhere(toRemove.contains);
+ component.libraries.removeWhere(toRemove.contains);
}
@override
@@ -530,8 +531,8 @@
/// transformers.
// TODO(sigmund): consider being more fine-grained and only marking what is
// seen and used.
- void _markRequired(Program program) {
- var coreTypes = new CoreTypes(program);
+ void _markRequired(Component component) {
+ var coreTypes = new CoreTypes(component);
coreTypes.objectClass.members.forEach(markMember);
// These are assumed to be available by fasta:
@@ -660,8 +661,8 @@
}
@override
- void writeLibraries(Program program) {
- for (var library in program.libraries) {
+ void writeLibraries(Component component) {
+ for (var library in component.libraries) {
if (isIncluded(library.importUri) || data.isLibraryUsed(library)) {
librariesToWrite.add(library);
}
@@ -697,8 +698,8 @@
}
@override
- void writeProgramIndex(Program program, List<Library> libraries) {
- super.writeProgramIndex(program, librariesToWrite);
+ void writeComponentIndex(Component component, List<Library> libraries) {
+ super.writeComponentIndex(component, librariesToWrite);
}
@override
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index 388fd98..9550057 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -30,7 +30,7 @@
NullLiteral,
Procedure,
ProcedureKind,
- Program,
+ Component,
Source,
Statement,
StringLiteral,
@@ -92,7 +92,7 @@
import 'metadata_collector.dart' show MetadataCollector;
-import 'verifier.dart' show verifyProgram;
+import 'verifier.dart' show verifyComponent;
class KernelTarget extends TargetImplementation {
/// The [FileSystem] which should be used to access files.
@@ -111,7 +111,7 @@
SourceLoader<Library> loader;
- Program program;
+ Component component;
final List<LocatedMessage> errors = <LocatedMessage>[];
@@ -220,17 +220,17 @@
builder.mixedInType = null;
}
- void handleInputError(deprecated_InputError error, {bool isFullProgram}) {
+ void handleInputError(deprecated_InputError error, {bool isFullComponent}) {
if (error != null) {
LocatedMessage message = deprecated_InputError.toMessage(error);
context.report(message, Severity.error);
errors.add(message);
}
- program = erroneousProgram(isFullProgram);
+ component = erroneousComponent(isFullComponent);
}
@override
- Future<Program> buildOutlines({CanonicalName nameRoot}) async {
+ Future<Component> buildOutlines({CanonicalName nameRoot}) async {
if (loader.first == null) return null;
try {
loader.createTypeInferenceEngine();
@@ -248,14 +248,14 @@
List<SourceClassBuilder> myClasses = collectMyClasses();
loader.checkSemantics(myClasses);
loader.finishTypeVariables(objectClassBuilder);
- loader.buildProgram();
+ loader.buildComponent();
installDefaultSupertypes();
installDefaultConstructors(myClasses);
loader.resolveConstructors();
- program =
+ component =
link(new List<Library>.from(loader.libraries), nameRoot: nameRoot);
if (metadataCollector != null) {
- program.addMetadataRepository(metadataCollector.repository);
+ component.addMetadataRepository(metadataCollector.repository);
}
computeCoreTypes();
loader.computeHierarchy();
@@ -266,30 +266,30 @@
loader.checkOverrides(myClasses);
} on deprecated_InputError catch (e) {
ticker.logMs("Got deprecated_InputError");
- handleInputError(e, isFullProgram: false);
+ handleInputError(e, isFullComponent: false);
} catch (e, s) {
return reportCrash(e, s, loader?.currentUriForCrashReporting);
}
- return program;
+ return component;
}
- /// Build the kernel representation of the program loaded by this target. The
- /// program will contain full bodies for the code loaded from sources, and
+ /// Build the kernel representation of the component loaded by this target. The
+ /// component will contain full bodies for the code loaded from sources, and
/// only references to the code loaded by the [DillTarget], which may or may
/// not include method bodies (depending on what was loaded into that target,
- /// an outline or a full kernel program).
+ /// an outline or a full kernel component).
///
- /// If [verify], run the default kernel verification on the resulting program.
+ /// If [verify], run the default kernel verification on the resulting component.
@override
- Future<Program> buildProgram({bool verify: false}) async {
+ Future<Component> buildComponent({bool verify: false}) async {
if (loader.first == null) return null;
if (errors.isNotEmpty) {
- handleInputError(null, isFullProgram: true);
- return program;
+ handleInputError(null, isFullComponent: true);
+ return component;
}
try {
- ticker.logMs("Building program");
+ ticker.logMs("Building component");
await loader.buildBodies();
loader.finishDeferredLoadTearoffs();
List<SourceClassBuilder> myClasses = collectMyClasses();
@@ -300,16 +300,16 @@
if (verify) this.verify();
if (errors.isNotEmpty) {
- handleInputError(null, isFullProgram: true);
+ handleInputError(null, isFullComponent: true);
}
handleRecoverableErrors(loader.unhandledErrors);
} on deprecated_InputError catch (e) {
ticker.logMs("Got deprecated_InputError");
- handleInputError(e, isFullProgram: true);
+ handleInputError(e, isFullComponent: true);
} catch (e, s) {
return reportCrash(e, s, loader?.currentUriForCrashReporting);
}
- return program;
+ return component;
}
/// Adds a synthetic field named `#errors` to the main library that contains
@@ -317,13 +317,13 @@
///
/// If [recoverableErrors] is empty, this method does nothing.
///
- /// If there's no main library, this method uses [erroneousProgram] to
- /// replace [program].
+ /// If there's no main library, this method uses [erroneousComponent] to
+ /// replace [component].
void handleRecoverableErrors(List<LocatedMessage> recoverableErrors) {
if (recoverableErrors.isEmpty) return;
KernelLibraryBuilder mainLibrary = loader.first;
if (mainLibrary == null) {
- program = erroneousProgram(true);
+ component = erroneousComponent(true);
return;
}
List<Expression> expressions = <Expression>[];
@@ -337,13 +337,13 @@
isStatic: true));
}
- Program erroneousProgram(bool isFullProgram) {
+ Component erroneousComponent(bool isFullComponent) {
Uri uri = loader.first?.uri ?? Uri.parse("error:error");
Uri fileUri = loader.first?.fileUri ?? uri;
KernelLibraryBuilder library =
new KernelLibraryBuilder(uri, fileUri, loader, null);
loader.first = library;
- if (isFullProgram) {
+ if (isFullComponent) {
// If this is an outline, we shouldn't add an executable main
// method. Similarly considerations apply to separate compilation. It
// could also make sense to add a way to mark .dill files as having
@@ -360,9 +360,9 @@
return link(<Library>[library.library]);
}
- /// Creates a program by combining [libraries] with the libraries of
- /// `dillTarget.loader.program`.
- Program link(List<Library> libraries, {CanonicalName nameRoot}) {
+ /// Creates a component by combining [libraries] with the libraries of
+ /// `dillTarget.loader.component`.
+ Component link(List<Library> libraries, {CanonicalName nameRoot}) {
libraries.addAll(dillTarget.loader.libraries);
Map<Uri, Source> uriToSource = new Map<Uri, Source>();
@@ -374,22 +374,22 @@
this.uriToSource.forEach(copySource);
dillTarget.loader.uriToSource.forEach(copySource);
- Program program = new Program(
+ Component component = new Component(
nameRoot: nameRoot, libraries: libraries, uriToSource: uriToSource);
if (loader.first != null) {
// TODO(sigmund): do only for full program
Builder builder = loader.first.exportScope.lookup("main", -1, null);
if (builder is KernelProcedureBuilder) {
- program.mainMethod = builder.procedure;
+ component.mainMethod = builder.procedure;
} else if (builder is DillMemberBuilder) {
if (builder.member is Procedure) {
- program.mainMethod = builder.member;
+ component.mainMethod = builder.member;
}
}
}
- ticker.logMs("Linked program");
- return program;
+ ticker.logMs("Linked component");
+ return component;
}
void installDefaultSupertypes() {
@@ -575,7 +575,7 @@
libraries.add(library.target);
}
}
- Program plaformLibraries = new Program();
+ Component plaformLibraries = new Component();
// Add libraries directly to prevent that their parents are changed.
plaformLibraries.libraries.addAll(libraries);
loader.computeCoreTypes(plaformLibraries);
@@ -711,8 +711,8 @@
}
void verify() {
- errors.addAll(verifyProgram(program));
- ticker.logMs("Verified program");
+ errors.addAll(verifyComponent(component));
+ ticker.logMs("Verified component");
}
/// Return `true` if the given [library] was built by this [KernelTarget]
diff --git a/pkg/front_end/lib/src/fasta/kernel/metadata_collector.dart b/pkg/front_end/lib/src/fasta/kernel/metadata_collector.dart
index 944540a..2b73d92 100644
--- a/pkg/front_end/lib/src/fasta/kernel/metadata_collector.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/metadata_collector.dart
@@ -7,7 +7,7 @@
/// The collector to add target specific metadata to.
abstract class MetadataCollector {
/// Metadata is remembered in this repository, so that when it is added
- /// to a program, metadata is serialized with the program.
+ /// to a component, metadata is serialized with the component.
MetadataRepository get repository;
void setConstructorNameOffset(Member node, Object name);
diff --git a/pkg/front_end/lib/src/fasta/kernel/utils.dart b/pkg/front_end/lib/src/fasta/kernel/utils.dart
index 4a9bd7f0..8bcda60 100644
--- a/pkg/front_end/lib/src/fasta/kernel/utils.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/utils.dart
@@ -6,7 +6,7 @@
import 'dart:io' show BytesBuilder, File, IOSink;
-import 'package:kernel/ast.dart' show Library, Program;
+import 'package:kernel/ast.dart' show Library, Component;
import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
@@ -15,13 +15,14 @@
import 'package:kernel/text/ast_to_text.dart' show Printer;
-/// Print the given [program]. Do nothing if it is `null`. If the
+/// Print the given [component]. Do nothing if it is `null`. If the
/// [libraryFilter] is provided, then only libraries that satisfy it are
/// printed.
-void printProgramText(Program program, {bool libraryFilter(Library library)}) {
- if (program == null) return;
+void printComponentText(Component component,
+ {bool libraryFilter(Library library)}) {
+ if (component == null) return;
StringBuffer sb = new StringBuffer();
- for (Library library in program.libraries) {
+ for (Library library in component.libraries) {
if (libraryFilter != null && !libraryFilter(library)) continue;
Printer printer = new Printer(sb);
printer.writeLibraryFile(library);
@@ -29,8 +30,8 @@
print(sb);
}
-/// Write [program] to file only including libraries that match [filter].
-Future<Null> writeProgramToFile(Program program, Uri uri,
+/// Write [component] to file only including libraries that match [filter].
+Future<Null> writeComponentToFile(Component component, Uri uri,
{bool filter(Library library)}) async {
File output = new File.fromUri(uri);
IOSink sink = output.openWrite();
@@ -38,22 +39,22 @@
BinaryPrinter printer = filter == null
? new BinaryPrinter(sink)
: new LimitedBinaryPrinter(sink, filter ?? (_) => true, false);
- printer.writeProgramFile(program);
- program.unbindCanonicalNames();
+ printer.writeComponentFile(component);
+ component.unbindCanonicalNames();
} finally {
await sink.close();
}
}
-/// Serialize the libraries in [program] that match [filter].
-List<int> serializeProgram(Program program,
+/// Serialize the libraries in [component] that match [filter].
+List<int> serializeComponent(Component component,
{bool filter(Library library), bool excludeUriToSource: false}) {
ByteSink byteSink = new ByteSink();
BinaryPrinter printer = filter == null && !excludeUriToSource
? new BinaryPrinter(byteSink)
: new LimitedBinaryPrinter(
byteSink, filter ?? (_) => true, excludeUriToSource);
- printer.writeProgramFile(program);
+ printer.writeComponentFile(component);
return byteSink.builder.takeBytes();
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/verifier.dart b/pkg/front_end/lib/src/fasta/kernel/verifier.dart
index b091b02..86aaafd 100644
--- a/pkg/front_end/lib/src/fasta/kernel/verifier.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/verifier.dart
@@ -14,7 +14,7 @@
Library,
Member,
Procedure,
- Program,
+ Component,
StaticInvocation,
SuperMethodInvocation,
SuperPropertyGet,
@@ -37,11 +37,11 @@
import 'redirecting_factory_body.dart'
show RedirectingFactoryBody, getRedirectingFactoryBody;
-List<LocatedMessage> verifyProgram(Program program,
+List<LocatedMessage> verifyComponent(Component component,
{bool isOutline: false, bool skipPlatform: false}) {
FastaVerifyingVisitor verifier =
new FastaVerifyingVisitor(isOutline, skipPlatform);
- program.accept(verifier);
+ component.accept(verifier);
return verifier.errors;
}
diff --git a/pkg/front_end/lib/src/fasta/messages.dart b/pkg/front_end/lib/src/fasta/messages.dart
index 9c654de..397ce96 100644
--- a/pkg/front_end/lib/src/fasta/messages.dart
+++ b/pkg/front_end/lib/src/fasta/messages.dart
@@ -4,7 +4,7 @@
library fasta.messages;
-import 'package:kernel/ast.dart' show Library, Location, Program, TreeNode;
+import 'package:kernel/ast.dart' show Library, Location, Component, TreeNode;
import 'compiler_context.dart' show CompilerContext;
@@ -28,18 +28,18 @@
}
Location getLocationFromNode(TreeNode node) {
- if (node.enclosingProgram == null) {
+ if (node.enclosingComponent == null) {
TreeNode parent = node;
while (parent != null && parent is! Library) {
parent = parent.parent;
}
if (parent is Library) {
- Program program =
- new Program(uriToSource: CompilerContext.current.uriToSource);
- program.libraries.add(parent);
- parent.parent = program;
+ Component component =
+ new Component(uriToSource: CompilerContext.current.uriToSource);
+ component.libraries.add(parent);
+ parent.parent = component;
Location result = node.location;
- program.libraries.clear();
+ component.libraries.clear();
parent.parent = null;
return result;
} else {
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index fb478c7..83396f3 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -15,7 +15,7 @@
Expression,
Library,
LibraryDependency,
- Program,
+ Component,
Supertype;
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
@@ -544,7 +544,7 @@
ticker.logMs("Checked restricted supertypes");
}
- void buildProgram() {
+ void buildComponent() {
builders.forEach((Uri uri, LibraryBuilder library) {
if (library.loader == this) {
SourceLibraryBuilder sourceLibrary = library;
@@ -554,10 +554,10 @@
}
}
});
- ticker.logMs("Built program");
+ ticker.logMs("Built component");
}
- Program computeFullProgram() {
+ Component computeFullProgram() {
Set<Library> libraries = new Set<Library>();
List<Library> workList = <Library>[];
builders.forEach((Uri uri, LibraryBuilder library) {
@@ -575,7 +575,7 @@
}
}
}
- return new Program()..libraries.addAll(libraries);
+ return new Component()..libraries.addAll(libraries);
}
void computeHierarchy() {
@@ -614,8 +614,8 @@
void ignoreAmbiguousSupertypes(Class cls, Supertype a, Supertype b) {}
- void computeCoreTypes(Program program) {
- coreTypes = new CoreTypes(program);
+ void computeCoreTypes(Component component) {
+ coreTypes = new CoreTypes(component);
ticker.logMs("Computed core types");
}
diff --git a/pkg/front_end/lib/src/fasta/target.dart b/pkg/front_end/lib/src/fasta/target.dart
index c49da71..30b3754 100644
--- a/pkg/front_end/lib/src/fasta/target.dart
+++ b/pkg/front_end/lib/src/fasta/target.dart
@@ -12,7 +12,7 @@
/// A compilation target.
///
/// A target reads source files with [read], builds outlines when
-/// [buildOutlines] is called and builds the full program when [buildProgram]
+/// [buildOutlines] is called and builds the full component when [buildComponent]
/// is called.
abstract class Target {
final Ticker ticker;
@@ -23,8 +23,8 @@
void read(Uri uri);
/// Build and return outlines for all libraries.
- Future<Program> buildOutlines();
+ Future<Component> buildOutlines();
- /// Build and return the full program for all libraries.
- Future<Program> buildProgram();
+ /// Build and return the full component for all libraries.
+ Future<Component> buildComponent();
}
diff --git a/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart b/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart
index 40c7011..49b1793 100644
--- a/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart
+++ b/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart
@@ -13,7 +13,7 @@
import 'dart:typed_data' show Uint8List;
-import 'package:kernel/ast.dart' show Library, Program;
+import 'package:kernel/ast.dart' show Library, Component;
import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
@@ -21,7 +21,7 @@
import 'package:kernel/error_formatter.dart' show ErrorFormatter;
-import 'package:kernel/kernel.dart' show loadProgramFromBinary;
+import 'package:kernel/kernel.dart' show loadComponentFromBinary;
import 'package:kernel/naive_type_checker.dart' show StrongModeTypeChecker;
@@ -42,16 +42,16 @@
import '../compiler_context.dart';
-import '../kernel/verifier.dart' show verifyProgram;
+import '../kernel/verifier.dart' show verifyComponent;
-class Print extends Step<Program, Program, ChainContext> {
+class Print extends Step<Component, Component, ChainContext> {
const Print();
String get name => "print";
- Future<Result<Program>> run(Program program, _) async {
+ Future<Result<Component>> run(Component component, _) async {
StringBuffer sb = new StringBuffer();
- for (Library library in program.libraries) {
+ for (Library library in component.libraries) {
Printer printer = new Printer(sb);
if (library.importUri.scheme != "dart" &&
library.importUri.scheme != "package") {
@@ -59,54 +59,59 @@
}
}
print("$sb");
- return pass(program);
+ return pass(component);
}
}
-class Verify extends Step<Program, Program, ChainContext> {
+class Verify extends Step<Component, Component, ChainContext> {
final bool fullCompile;
const Verify(this.fullCompile);
String get name => "verify";
- Future<Result<Program>> run(Program program, ChainContext context) async {
+ Future<Result<Component>> run(
+ Component component, ChainContext context) async {
var options = new ProcessedOptions(new CompilerOptions());
return await CompilerContext.runWithOptions(options, (_) async {
- var errors =
- verifyProgram(program, isOutline: !fullCompile, skipPlatform: true);
+ var errors = verifyComponent(component,
+ isOutline: !fullCompile, skipPlatform: true);
if (errors.isEmpty) {
- return pass(program);
+ return pass(component);
} else {
- return new Result<Program>(
+ return new Result<Component>(
null, context.expectationSet["VerificationError"], errors, null);
}
});
}
}
-class TypeCheck extends Step<Program, Program, ChainContext> {
+class TypeCheck extends Step<Component, Component, ChainContext> {
const TypeCheck();
String get name => "typeCheck";
- Future<Result<Program>> run(Program program, ChainContext context) async {
+ Future<Result<Component>> run(
+ Component component, ChainContext context) async {
var errorFormatter = new ErrorFormatter();
var checker =
- new StrongModeTypeChecker(errorFormatter, program, ignoreSdk: true);
- checker.checkProgram(program);
+ new StrongModeTypeChecker(errorFormatter, component, ignoreSdk: true);
+ checker.checkComponent(component);
if (errorFormatter.numberOfFailures == 0) {
- return pass(program);
+ return pass(component);
} else {
errorFormatter.failures.forEach(print);
print('------- Found ${errorFormatter.numberOfFailures} errors -------');
- return new Result<Program>(null, context.expectationSet["TypeCheckError"],
- '${errorFormatter.numberOfFailures} type errors', null);
+ return new Result<Component>(
+ null,
+ context.expectationSet["TypeCheckError"],
+ '${errorFormatter.numberOfFailures} type errors',
+ null);
}
}
}
-class MatchExpectation extends Step<Program, Program, ChainContext> {
+class MatchExpectation extends Step<Component, Component, ChainContext> {
final String suffix;
// TODO(ahe): This is true by default which doesn't match well with the class
@@ -117,8 +122,8 @@
String get name => "match expectations";
- Future<Result<Program>> run(Program program, _) async {
- Library library = program.libraries
+ Future<Result<Component>> run(Component component, _) async {
+ Library library = component.libraries
.firstWhere((Library library) => library.importUri.scheme != "dart");
Uri uri = library.importUri;
Uri base = uri.resolve(".");
@@ -135,37 +140,37 @@
return fail(null, "$uri doesn't match ${expectedFile.uri}\n$diff");
}
} else {
- return pass(program);
+ return pass(component);
}
}
if (updateExpectations) {
await openWrite(expectedFile.uri, (IOSink sink) {
sink.writeln(actual.trim());
});
- return pass(program);
+ return pass(component);
} else {
- return fail(program, """
+ return fail(component, """
Please create file ${expectedFile.path} with this content:
$actual""");
}
}
}
-class WriteDill extends Step<Program, Uri, ChainContext> {
+class WriteDill extends Step<Component, Uri, ChainContext> {
const WriteDill();
String get name => "write .dill";
- Future<Result<Uri>> run(Program program, _) async {
+ Future<Result<Uri>> run(Component component, _) async {
Directory tmp = await Directory.systemTemp.createTemp();
Uri uri = tmp.uri.resolve("generated.dill");
File generated = new File.fromUri(uri);
IOSink sink = generated.openWrite();
try {
try {
- new BinaryPrinter(sink).writeProgramFile(program);
+ new BinaryPrinter(sink).writeComponentFile(component);
} finally {
- program.unbindCanonicalNames();
+ component.unbindCanonicalNames();
}
} catch (e, s) {
return fail(uri, e, s);
@@ -184,7 +189,7 @@
Future<Result<Uri>> run(Uri uri, _) async {
try {
- loadProgramFromBinary(uri.toFilePath());
+ loadComponentFromBinary(uri.toFilePath());
} catch (e, s) {
return fail(uri, e, s);
}
@@ -192,34 +197,34 @@
}
}
-class Copy extends Step<Program, Program, ChainContext> {
+class Copy extends Step<Component, Component, ChainContext> {
const Copy();
- String get name => "copy program";
+ String get name => "copy component";
- Future<Result<Program>> run(Program program, _) async {
+ Future<Result<Component>> run(Component component, _) async {
BytesCollector sink = new BytesCollector();
- new BinaryPrinter(sink).writeProgramFile(program);
- program.unbindCanonicalNames();
+ new BinaryPrinter(sink).writeComponentFile(component);
+ component.unbindCanonicalNames();
Uint8List bytes = sink.collect();
- new BinaryBuilder(bytes).readProgram(program);
- return pass(program);
+ new BinaryBuilder(bytes).readComponent(component);
+ return pass(component);
}
}
/// A `package:testing` step that runs the `package:front_end` compiler to
-/// generate a kernel program for an individual file.
+/// generate a kernel component for an individual file.
///
/// Most options are hard-coded, but if necessary they could be moved to the
/// [CompileContext] object in the future.
-class Compile extends Step<TestDescription, Program, CompileContext> {
+class Compile extends Step<TestDescription, Component, CompileContext> {
const Compile();
String get name => "fasta compilation";
- Future<Result<Program>> run(
+ Future<Result<Component>> run(
TestDescription description, CompileContext context) async {
- Result<Program> result;
+ Result<Component> result;
reportError(CompilationMessage error) {
result ??= fail(null, error.message);
}
@@ -241,7 +246,7 @@
computePlatformBinariesLocation().resolve("vm_platform.dill"),
];
}
- Program p = await kernelForProgram(description.uri, options);
+ Component p = await kernelForProgram(description.uri, options);
return result ??= pass(p);
}
}
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
index 0f78fba..87723e6 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
@@ -229,7 +229,7 @@
/// corresponding fields.
void finishTopLevelInitializingFormals();
- /// Gets ready to do top level type inference for the program having the given
+ /// Gets ready to do top level type inference for the component having the given
/// [hierarchy], using the given [coreTypes].
void prepareTopLevel(CoreTypes coreTypes, ClassHierarchy hierarchy);
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_promotion.dart b/pkg/front_end/lib/src/fasta/type_inference/type_promotion.dart
index d40ee3d..fa4b1ea 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_promotion.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_promotion.dart
@@ -16,7 +16,7 @@
/// methods maintain a linked list of [TypePromotionFact] objects tracking what
/// is known about the state of each variable at the current point in the code,
/// as well as a linked list of [TypePromotionScope] objects tracking the
-/// program's nesting structure. Whenever a variable is read, the current
+/// component's nesting structure. Whenever a variable is read, the current
/// [TypePromotionFact] and [TypePromotionScope] are recorded for later use.
///
/// During type inference, the [TypeInferrer] calls back into this class to ask
@@ -473,7 +473,7 @@
}
/// A single fact which is known to the type promotion engine about the state of
-/// a variable (or about the flow control of the program).
+/// a variable (or about the flow control of the component).
///
/// The type argument V represents is the class which represents local variable
/// declarations.
@@ -481,14 +481,14 @@
/// Facts are linked together into linked lists via the [previous] pointer into
/// a data structure called a "fact chain" (or sometimes a "fact state"), which
/// represents all facts that are known to hold at a certain point in the
-/// program.
+/// component.
///
-/// The fact is said to "apply" to a given point in the execution of the program
+/// The fact is said to "apply" to a given point in the execution of the component
/// if the fact is part of the current fact state at the point the parser
-/// reaches that point in the program.
+/// reaches that point in the component.
///
/// Note: just because a fact "applies" to a given point in the execution of the
-/// program doesn't mean a type will be promoted--it simply means that the fact
+/// component doesn't mean a type will be promoted--it simply means that the fact
/// was deduced at a previous point in the straight line execution of the code.
/// It's possible that the fact will be overshadowed by a later fact, or its
/// effect will be cancelled by a later assignment. The final detemination of
diff --git a/pkg/front_end/lib/src/incremental/kernel_driver.dart b/pkg/front_end/lib/src/incremental/kernel_driver.dart
index 3bbb34f..9038870 100644
--- a/pkg/front_end/lib/src/incremental/kernel_driver.dart
+++ b/pkg/front_end/lib/src/incremental/kernel_driver.dart
@@ -64,7 +64,7 @@
/// Options used by the kernel compiler.
final ProcessedOptions _options;
- /// The optional SDK outline as a serialized program.
+ /// The optional SDK outline as a serialized component.
/// If provided, the driver will not attempt to read SDK files.
final List<int> _sdkOutlineBytes;
@@ -93,7 +93,7 @@
/// The optional SDK outline loaded from [_sdkOutlineBytes].
/// Might be `null` if the bytes are not provided, or if not loaded yet.
- Program _sdkOutline;
+ Component _sdkOutline;
/// The salt to mix into all hashes used as keys for serialized data.
List<int> _salt;
@@ -368,9 +368,9 @@
CanonicalName nameRoot, List<LibraryCycleResult> results) {
var coreLibraries =
results.first.libraryResults.map((l) => l.library).toList();
- var program = new Program(nameRoot: nameRoot, libraries: coreLibraries);
+ var component = new Component(nameRoot: nameRoot, libraries: coreLibraries);
return new TypeEnvironment(
- new CoreTypes(program), new ClassHierarchy(program));
+ new CoreTypes(component), new ClassHierarchy(component));
}
/// Ensure that [dillTarget] includes the [cycle] libraries. It already
@@ -405,9 +405,9 @@
}
}
- Future<Null> appendNewDillLibraries(Program program) async {
+ Future<Null> appendNewDillLibraries(Component component) async {
dillTarget.loader
- .appendLibraries(program, filter: libraryUris.contains);
+ .appendLibraries(component, filter: libraryUris.contains);
await dillTarget.buildOutlines();
}
@@ -417,15 +417,15 @@
List<int> bytes = _byteStore.get(kernelKey);
if (bytes != null) {
return _logger.runAsync('Read serialized libraries', () async {
- var program = new Program(nameRoot: nameRoot);
- _readProgram(program, bytes);
- await appendNewDillLibraries(program);
+ var component = new Component(nameRoot: nameRoot);
+ _readProgram(component, bytes);
+ await appendNewDillLibraries(component);
return new LibraryCycleResult(
cycle,
signature,
- program.uriToSource,
- program.libraries
+ component.uriToSource,
+ component.libraries
// TODO report errors here
.map((l) => new LibraryResult(l, []))
.toList());
@@ -441,19 +441,19 @@
kernelTarget.read(library.uri);
}
- // Compile the cycle libraries into a new full program.
- Program program = await _logger
+ // Compile the cycle libraries into a new full component.
+ Component component = await _logger
.runAsync('Compile ${cycle.libraries.length} libraries', () async {
await kernelTarget.buildOutlines(nameRoot: nameRoot);
- return await kernelTarget.buildProgram();
+ return await kernelTarget.buildComponent();
});
_testView.compiledCycles.add(cycle);
// Add newly compiled libraries into DILL.
- await appendNewDillLibraries(program);
+ await appendNewDillLibraries(component);
- List<Library> kernelLibraries = program.libraries
+ List<Library> kernelLibraries = component.libraries
.where((library) => libraryUris.contains(library.importUri))
.toList();
@@ -469,23 +469,23 @@
// Remove source for libraries outside of the cycle.
{
var urisToRemoveSources = <Uri>[];
- for (var uri in program.uriToSource.keys) {
+ for (var uri in component.uriToSource.keys) {
if (!cycleFileUris.contains(uri)) {
urisToRemoveSources.add(uri);
}
}
- urisToRemoveSources.forEach(program.uriToSource.remove);
+ urisToRemoveSources.forEach(component.uriToSource.remove);
}
_logger.run('Serialize ${kernelLibraries.length} libraries', () {
List<int> bytes =
- serializeProgram(program, filter: kernelLibraries.contains);
+ serializeComponent(component, filter: kernelLibraries.contains);
_byteStore.put(kernelKey, bytes);
_logger.writeln('Stored ${bytes.length} bytes.');
});
return new LibraryCycleResult(
- cycle, signature, program.uriToSource, kernelLibrariesResults);
+ cycle, signature, component.uriToSource, kernelLibrariesResults);
});
}
@@ -544,7 +544,7 @@
Future<Null> _loadSdkOutline() async {
if (_sdkOutlineBytes != null && _sdkOutline == null) {
await _logger.runAsync('Load SDK outline from bytes', () async {
- _sdkOutline = loadProgramFromBytes(_sdkOutlineBytes);
+ _sdkOutline = loadComponentFromBytes(_sdkOutlineBytes);
// Configure the file system state to skip the outline libraries.
for (var outlineLibrary in _sdkOutline.libraries) {
_fsState.skipSdkLibraries.add(outlineLibrary.importUri);
@@ -553,17 +553,17 @@
}
}
- /// Read libraries from the given [bytes] into the [program], using the
- /// configured metadata factory. The [program] must be ready to read these
- /// libraries, i.e. either the [bytes] represent a full program with all
- /// dependencies, or the [program] already has all required dependencies.
- void _readProgram(Program program, List<int> bytes) {
+ /// Read libraries from the given [bytes] into the [component], using the
+ /// configured metadata factory. The [component] must be ready to read these
+ /// libraries, i.e. either the [bytes] represent a full component with all
+ /// dependencies, or the [component] already has all required dependencies.
+ void _readProgram(Component component, List<int> bytes) {
if (_metadataFactory != null) {
var repository = _metadataFactory.newRepositoryForReading();
- program.addMetadataRepository(repository);
- new BinaryBuilderWithMetadata(bytes).readSingleFileProgram(program);
+ component.addMetadataRepository(repository);
+ new BinaryBuilderWithMetadata(bytes).readSingleFileComponent(component);
} else {
- new BinaryBuilder(bytes).readProgram(program);
+ new BinaryBuilder(bytes).readComponent(component);
}
}
@@ -662,7 +662,7 @@
MetadataCollector newCollector();
/// Return a new [MetadataRepository] instance to read metadata while
- /// reading a [Program] for a library cycle.
+ /// reading a [Component] for a library cycle.
MetadataRepository newRepositoryForReading();
}
diff --git a/pkg/front_end/lib/src/kernel_generator_impl.dart b/pkg/front_end/lib/src/kernel_generator_impl.dart
index a41e93a..4761b9a 100644
--- a/pkg/front_end/lib/src/kernel_generator_impl.dart
+++ b/pkg/front_end/lib/src/kernel_generator_impl.dart
@@ -8,7 +8,7 @@
import 'dart:async' show Future;
import 'dart:async';
-import 'package:kernel/kernel.dart' show Program, CanonicalName;
+import 'package:kernel/kernel.dart' show Component, CanonicalName;
import 'base/processed_options.dart';
import 'fasta/severity.dart' show Severity;
@@ -25,19 +25,19 @@
/// `package:front_end/src/api_prototype/summary_generator.dart` APIs.
Future<CompilerResult> generateKernel(ProcessedOptions options,
{bool buildSummary: false,
- bool buildProgram: true,
+ bool buildComponent: true,
bool truncateSummary: false}) async {
return await CompilerContext.runWithOptions(options, (_) async {
return await generateKernelInternal(
buildSummary: buildSummary,
- buildProgram: buildProgram,
+ buildComponent: buildComponent,
truncateSummary: truncateSummary);
});
}
Future<CompilerResult> generateKernelInternal(
{bool buildSummary: false,
- bool buildProgram: true,
+ bool buildComponent: true,
bool truncateSummary: false}) async {
var options = CompilerContext.current.options;
var fs = options.fileSystem;
@@ -50,8 +50,8 @@
var dillTarget =
new DillTarget(options.ticker, uriTranslator, options.target);
- Set<Uri> externalLibs(Program program) {
- return program.libraries
+ Set<Uri> externalLibs(Component component) {
+ return component.libraries
.where((lib) => lib.isExternal)
.map((lib) => lib.importUri)
.toSet();
@@ -82,7 +82,7 @@
lib.isExternal = true;
});
- // Linked dependencies are meant to be part of the program so they are not
+ // Linked dependencies are meant to be part of the component so they are not
// marked external.
for (var dependency in await options.loadLinkDependencies(nameRoot)) {
var excluded = externalLibs(dependency);
@@ -94,54 +94,55 @@
var kernelTarget = new KernelTarget(fs, false, dillTarget, uriTranslator);
options.inputs.forEach(kernelTarget.read);
- Program summaryProgram =
+ Component summaryProgram =
await kernelTarget.buildOutlines(nameRoot: nameRoot);
List<int> summary = null;
if (buildSummary) {
if (options.verify) {
- for (var error in verifyProgram(summaryProgram)) {
+ for (var error in verifyComponent(summaryProgram)) {
options.report(error, Severity.error);
}
}
if (options.debugDump) {
- printProgramText(summaryProgram,
+ printComponentText(summaryProgram,
libraryFilter: kernelTarget.isSourceLibrary);
}
- // Copy the program to exclude the uriToSource map from the summary.
+ // Copy the component to exclude the uriToSource map from the summary.
//
// Note: we don't pass the library argument to the constructor to
// preserve the the libraries parent pointer (it should continue to point
- // to the program within KernelTarget).
- var trimmedSummaryProgram = new Program(nameRoot: summaryProgram.root)
+ // to the component within KernelTarget).
+ var trimmedSummaryProgram = new Component(nameRoot: summaryProgram.root)
..libraries.addAll(truncateSummary
? kernelTarget.loader.libraries
: summaryProgram.libraries);
trimmedSummaryProgram.metadata.addAll(summaryProgram.metadata);
// As documented, we only run outline transformations when we are building
- // summaries without building a full program (at this time, that's
+ // summaries without building a full component (at this time, that's
// the only need we have for these transformations).
- if (!buildProgram) {
+ if (!buildComponent) {
options.target.performOutlineTransformations(trimmedSummaryProgram);
options.ticker.logMs("Transformed outline");
}
- summary = serializeProgram(trimmedSummaryProgram);
+ summary = serializeComponent(trimmedSummaryProgram);
options.ticker.logMs("Generated outline");
}
- Program program;
- if (buildProgram && kernelTarget.errors.isEmpty) {
- program = await kernelTarget.buildProgram(verify: options.verify);
+ Component component;
+ if (buildComponent && kernelTarget.errors.isEmpty) {
+ component = await kernelTarget.buildComponent(verify: options.verify);
if (options.debugDump) {
- printProgramText(program, libraryFilter: kernelTarget.isSourceLibrary);
+ printComponentText(component,
+ libraryFilter: kernelTarget.isSourceLibrary);
}
- options.ticker.logMs("Generated program");
+ options.ticker.logMs("Generated component");
}
return new CompilerResult(
summary: summary,
- program: program,
+ component: component,
deps: kernelTarget.loader.getDependencies());
} on deprecated_InputError catch (e) {
options.report(
@@ -157,8 +158,8 @@
/// The generated summary bytes, if it was requested.
final List<int> summary;
- /// The generated program, if it was requested.
- final Program program;
+ /// The generated component, if it was requested.
+ final Component component;
/// Dependencies traversed by the compiler. Used only for generating
/// dependency .GN files in the dart-sdk build system.
@@ -166,5 +167,5 @@
/// using the compiler itself.
final List<Uri> deps;
- CompilerResult({this.summary, this.program, this.deps});
+ CompilerResult({this.summary, this.component, this.deps});
}
diff --git a/pkg/front_end/lib/src/testing/compiler_common.dart b/pkg/front_end/lib/src/testing/compiler_common.dart
index 8e6a904..0193e73 100644
--- a/pkg/front_end/lib/src/testing/compiler_common.dart
+++ b/pkg/front_end/lib/src/testing/compiler_common.dart
@@ -7,10 +7,10 @@
import 'dart:async' show Future;
-import 'package:kernel/ast.dart' show Library, Program;
+import 'package:kernel/ast.dart' show Library, Component;
import '../api_prototype/front_end.dart'
- show CompilerOptions, kernelForBuildUnit, kernelForProgram, summaryFor;
+ show CompilerOptions, kernelForComponent, kernelForProgram, summaryFor;
import '../api_prototype/memory_file_system.dart' show MemoryFileSystem;
@@ -26,7 +26,7 @@
/// compiles the entry whose name is [fileName].
///
/// Wraps [kernelForProgram] with some default testing options (see [setup]).
-Future<Program> compileScript(dynamic scriptOrSources,
+Future<Component> compileScript(dynamic scriptOrSources,
{fileName: 'main.dart',
List<String> inputSummaries: const [],
List<String> linkedDependencies: const [],
@@ -44,17 +44,17 @@
return await kernelForProgram(toTestUri(fileName), options);
}
-/// Generate a program for a modular complation unit.
+/// Generate a component for a modular complation unit.
///
-/// Wraps [kernelForBuildUnit] with some default testing options (see [setup]).
-Future<Program> compileUnit(List<String> inputs, Map<String, dynamic> sources,
+/// Wraps [kernelForComponent] with some default testing options (see [setup]).
+Future<Component> compileUnit(List<String> inputs, Map<String, dynamic> sources,
{List<String> inputSummaries: const [],
List<String> linkedDependencies: const [],
CompilerOptions options}) async {
options ??= new CompilerOptions();
await setup(options, sources,
inputSummaries: inputSummaries, linkedDependencies: linkedDependencies);
- return await kernelForBuildUnit(inputs.map(toTestUri).toList(), options);
+ return await kernelForComponent(inputs.map(toTestUri).toList(), options);
}
/// Generate a summary for a modular complation unit.
@@ -136,8 +136,8 @@
bool isDartCoreLibrary(Library lib) => isDartCore(lib.importUri);
bool isDartCore(Uri uri) => uri.scheme == 'dart' && uri.path == 'core';
-/// Find a library in [program] whose Uri ends with the given [suffix]
-Library findLibrary(Program program, String suffix) {
- return program.libraries
+/// Find a library in [component] whose Uri ends with the given [suffix]
+Library findLibrary(Component component, String suffix) {
+ return component.libraries
.firstWhere((lib) => lib.importUri.path.endsWith(suffix));
}
diff --git a/pkg/front_end/test/fasta/ambiguous_export_test.dart b/pkg/front_end/test/fasta/ambiguous_export_test.dart
index 0189766..8123c39 100644
--- a/pkg/front_end/test/fasta/ambiguous_export_test.dart
+++ b/pkg/front_end/test/fasta/ambiguous_export_test.dart
@@ -17,7 +17,7 @@
import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
import 'package:kernel/ast.dart'
- show Field, Library, Name, Program, StringLiteral;
+ show Field, Library, Name, Component, StringLiteral;
main() async {
await asyncTest(() async {
@@ -25,11 +25,11 @@
Field field = new Field(new Name("_exports#", library),
initializer: new StringLiteral('{"main":"Problem with main"}'));
library.addMember(field);
- Program program = new Program(libraries: <Library>[library]);
+ Component component = new Component(libraries: <Library>[library]);
await CompilerContext.runWithDefaultOptions((CompilerContext c) async {
DillTarget target =
new DillTarget(c.options.ticker, null, c.options.target);
- target.loader.appendLibraries(program);
+ target.loader.appendLibraries(component);
DillLibraryBuilder builder = target.loader.read(library.importUri, -1);
await target.loader.buildOutline(builder);
builder.finalizeExports();
diff --git a/pkg/front_end/test/fasta/assert_locations_test.dart b/pkg/front_end/test/fasta/assert_locations_test.dart
index b8bcf7e..a2e7355 100644
--- a/pkg/front_end/test/fasta/assert_locations_test.dart
+++ b/pkg/front_end/test/fasta/assert_locations_test.dart
@@ -9,7 +9,7 @@
import 'package:expect/expect.dart' show Expect;
import 'package:kernel/ast.dart'
- show Program, RecursiveVisitor, Procedure, AssertStatement;
+ show Component, RecursiveVisitor, Procedure, AssertStatement;
import "package:front_end/src/api_prototype/compiler_options.dart"
show CompilerOptions;
@@ -142,7 +142,7 @@
Expect.fail("Unexpected error: $formatted");
}
..strongMode = true;
- Program p = await compileScript(test.source,
+ Component p = await compileScript(test.source,
options: options, fileName: 'synthetic-test.dart');
Expect.isNotNull(p);
VerifyingVisitor visitor = new VerifyingVisitor(test);
diff --git a/pkg/front_end/test/fasta/bootstrap_test.dart b/pkg/front_end/test/fasta/bootstrap_test.dart
index 524ec46..77e7cab 100644
--- a/pkg/front_end/test/fasta/bootstrap_test.dart
+++ b/pkg/front_end/test/fasta/bootstrap_test.dart
@@ -12,9 +12,9 @@
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
-import 'package:kernel/text/ast_to_text.dart' show programToString;
+import 'package:kernel/text/ast_to_text.dart' show componentToString;
Future main() async {
asyncStart();
@@ -31,8 +31,8 @@
await compare(compiledOnceOutput, compiledTwiceOutput);
await runCompiler(compiledTwiceOutput, outline, outlineOutput);
try {
- // Test that compare actually works by comparing the compile program to
- // the outline program (which are different, but similar).
+ // Test that compare actually works by comparing the compiled component
+ // to the outline component (which are different, but similar).
await compare(compiledOnceOutput, outlineOutput, silent: true);
throw "Expected an error.";
} on ComparisonFailed {
@@ -78,13 +78,13 @@
if (!silent) {
print("$a is different from $b");
}
- Program programA = new Program();
- Program programB = new Program();
- new BinaryBuilder(bytesA, filename: a.toFilePath()).readProgram(programA);
- new BinaryBuilder(bytesB, filename: b.toFilePath()).readProgram(programB);
+ Component programA = new Component();
+ Component programB = new Component();
+ new BinaryBuilder(bytesA, filename: a.toFilePath()).readComponent(programA);
+ new BinaryBuilder(bytesB, filename: b.toFilePath()).readComponent(programB);
RegExp splitLines = new RegExp('^', multiLine: true);
- List<String> linesA = programToString(programA).split(splitLines);
- List<String> linesB = programToString(programB).split(splitLines);
+ List<String> linesA = componentToString(programA).split(splitLines);
+ List<String> linesB = componentToString(programB).split(splitLines);
for (int i = 0; i < linesA.length && i < linesB.length; i++) {
String lineA = linesA[i].trimRight();
String lineB = linesB[i].trimRight();
diff --git a/pkg/front_end/test/fasta/incremental_hello_test.dart b/pkg/front_end/test/fasta/incremental_hello_test.dart
index 1b13610..7976f2d 100644
--- a/pkg/front_end/test/fasta/incremental_hello_test.dart
+++ b/pkg/front_end/test/fasta/incremental_hello_test.dart
@@ -8,7 +8,7 @@
import 'package:expect/expect.dart' show Expect;
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
import "package:front_end/src/api_prototype/compiler_options.dart"
show CompilerOptions;
@@ -55,28 +55,28 @@
IncrementalCompiler compiler =
new IncrementalCompiler(new CompilerContext(options));
- Program program = await compiler.computeDelta();
+ Component component = await compiler.computeDelta();
if (sdkFromSource) {
- // Expect that the new program contains at least the following libraries:
+ // Expect that the new component contains at least the following libraries:
// dart:core, dart:async, and hello.dart.
Expect.isTrue(
- program.libraries.length > 2, "${program.libraries.length} <= 2");
+ component.libraries.length > 2, "${component.libraries.length} <= 2");
} else {
- // Expect that the new program contains exactly hello.dart.
+ // Expect that the new component contains exactly hello.dart.
Expect.isTrue(
- program.libraries.length == 1, "${program.libraries.length} != 1");
+ component.libraries.length == 1, "${component.libraries.length} != 1");
}
compiler.invalidate(helloDart);
- program = await compiler.computeDelta(entryPoint: helloDart);
- // Expect that the new program contains exactly hello.dart
+ component = await compiler.computeDelta(entryPoint: helloDart);
+ // Expect that the new component contains exactly hello.dart
Expect.isTrue(
- program.libraries.length == 1, "${program.libraries.length} != 1");
+ component.libraries.length == 1, "${component.libraries.length} != 1");
- program = await compiler.computeDelta(entryPoint: helloDart);
- Expect.isTrue(program.libraries.isEmpty);
+ component = await compiler.computeDelta(entryPoint: helloDart);
+ Expect.isTrue(component.libraries.isEmpty);
}
void main() {
diff --git a/pkg/front_end/test/fasta/incremental_test.dart b/pkg/front_end/test/fasta/incremental_test.dart
index d89f3a32..3d2fb2a 100644
--- a/pkg/front_end/test/fasta/incremental_test.dart
+++ b/pkg/front_end/test/fasta/incremental_test.dart
@@ -10,7 +10,7 @@
import "dart:io" show File;
-import "package:kernel/ast.dart" show Program;
+import "package:kernel/ast.dart" show Component;
import "package:testing/testing.dart"
show Chain, ChainContext, Result, Step, TestDescription, runMe;
@@ -146,7 +146,7 @@
return edits == 0 ? fail(test, "No sources found") : pass(test);
}
var compiler = context.compiler;
- Program program = await compiler.computeDelta(entryPoint: entryPoint);
+ Component component = await compiler.computeDelta(entryPoint: entryPoint);
List<CompilationMessage> errors = context.takeErrors();
if (test.expectations[edits].hasCompileTimeError) {
if (errors.isEmpty) {
@@ -155,7 +155,7 @@
} else if (errors.isNotEmpty) {
return fail(
test, "Unexpected compile-time errors:\n ${errors.join('\n ')}");
- } else if (program.libraries.length < 1) {
+ } else if (component.libraries.length < 1) {
return fail(test, "The compiler detected no changes");
}
}
diff --git a/pkg/front_end/test/fasta/shaker_test.dart b/pkg/front_end/test/fasta/shaker_test.dart
index 757e778..d86e4d9 100644
--- a/pkg/front_end/test/fasta/shaker_test.dart
+++ b/pkg/front_end/test/fasta/shaker_test.dart
@@ -30,13 +30,13 @@
import 'package:front_end/src/fasta/kernel/kernel_outline_shaker.dart';
import 'package:front_end/src/fasta/kernel/kernel_target.dart'
show KernelTarget;
-import 'package:front_end/src/fasta/kernel/verifier.dart' show verifyProgram;
+import 'package:front_end/src/fasta/kernel/verifier.dart' show verifyComponent;
import 'package:front_end/src/fasta/testing/kernel_chain.dart'
show BytesCollector, runDiff;
import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
import 'package:kernel/binary/ast_from_binary.dart';
-import 'package:kernel/kernel.dart' show loadProgramFromBytes;
+import 'package:kernel/kernel.dart' show loadComponentFromBytes;
import 'package:kernel/target/targets.dart' show TargetFlags;
import 'package:kernel/target/vm.dart' show VmTarget;
import 'package:kernel/text/ast_to_text.dart';
@@ -70,11 +70,11 @@
new CheckOutline(updateExpectations: updateExpectations),
];
- Program loadPlatformOutline() {
+ Component loadPlatformOutline() {
// Note: we rebuild the platform outline on every test because the
- // tree-shaker mutates the in-memory representation of the program without
+ // tree-shaker mutates the in-memory representation of the component without
// cloning it.
- return loadProgramFromBytes(outlineBytes);
+ return loadComponentFromBytes(outlineBytes);
}
static create(Map<String, String> environment) async {
@@ -134,23 +134,23 @@
var showCoreLibraries = contents.contains("@@SHOW_CORE_LIBRARIES@@");
await sourceTarget.buildOutlines();
- var program = await sourceTarget.buildProgram();
+ var component = await sourceTarget.buildComponent();
bool isIncluded(Uri uri) => uri == inputUri;
- Program outline;
+ Component outline;
{
var bytesCollector = new BytesCollector();
- serializeTrimmedOutline(bytesCollector, program, isIncluded);
+ serializeTrimmedOutline(bytesCollector, component, isIncluded);
var bytes = bytesCollector.collect();
- outline = new Program();
- new BinaryBuilder(bytes).readProgram(outline);
+ outline = new Component();
+ new BinaryBuilder(bytes).readComponent(outline);
}
- trimProgram(program, isIncluded);
+ trimProgram(component, isIncluded);
return pass(new _IntermediateData(
- inputUri, program, outline, showCoreLibraries));
+ inputUri, component, outline, showCoreLibraries));
} on deprecated_InputError catch (e, s) {
return fail(null, e.error, s);
}
@@ -163,11 +163,11 @@
/// The input URI provided to the test.
final Uri uri;
- /// Program built by [BuildProgram].
- final Program program;
+ /// Component built by [BuildProgram].
+ final Component component;
- /// Shaken outline of [program].
- final Program outline;
+ /// Shaken outline of [component].
+ final Component outline;
/// Whether the output should include tree-shaking information about the core
/// libraries. This is specified in a comment on individual test files where
@@ -175,7 +175,7 @@
final bool showCoreLibraries;
_IntermediateData(
- this.uri, this.program, this.outline, this.showCoreLibraries);
+ this.uri, this.component, this.outline, this.showCoreLibraries);
}
/// A step that runs the tree-shaker and checks against an expectation file for
@@ -191,9 +191,9 @@
_IntermediateData data, ChainContext context) async {
String actualResult;
var entryUri = data.uri;
- var program = data.program;
+ var component = data.component;
- var errors = verifyProgram(program, isOutline: false);
+ var errors = verifyComponent(component, isOutline: false);
if (!errors.isEmpty) {
return new Result<_IntermediateData>(
data, context.expectationSet["VerificationError"], errors, null);
@@ -207,7 +207,7 @@
To update this file, either copy the output from a failing test or run
pkg/front_end/tool/fasta testing shaker -DupdateExpectations=true''');
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
var importUri = library.importUri;
if (importUri == entryUri) continue;
if (importUri.isScheme('dart') && !data.showCoreLibraries) continue;
@@ -272,7 +272,7 @@
var entryUri = data.uri;
var outline = data.outline;
- var errors = verifyProgram(outline, isOutline: true);
+ var errors = verifyComponent(outline, isOutline: true);
if (!errors.isEmpty) {
return new Result<String>(
null, context.expectationSet["VerificationError"], errors, null);
diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart
index 9635d9c..3337a9e 100644
--- a/pkg/front_end/test/fasta/testing/suite.dart
+++ b/pkg/front_end/test/fasta/testing/suite.dart
@@ -21,7 +21,7 @@
import 'package:front_end/src/fasta/uri_translator_impl.dart';
-import 'package:kernel/ast.dart' show Library, Program;
+import 'package:kernel/ast.dart' show Library, Component;
import 'package:testing/testing.dart'
show
@@ -60,7 +60,7 @@
import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
-import 'package:kernel/kernel.dart' show loadProgramFromBytes;
+import 'package:kernel/kernel.dart' show loadComponentFromBytes;
import 'package:kernel/target/targets.dart' show TargetFlags;
@@ -108,10 +108,11 @@
final Uri vm;
final bool strongMode;
final bool onlyCrashes;
- final Map<Program, KernelTarget> programToTarget = <Program, KernelTarget>{};
+ final Map<Component, KernelTarget> programToTarget =
+ <Component, KernelTarget>{};
final Uri platformBinaries;
Uri platformUri;
- Program platform;
+ Component platform;
final ExpectationSet expectationSet =
new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS));
@@ -169,11 +170,11 @@
}
}
- Future<Program> loadPlatform() async {
+ Future<Component> loadPlatform() async {
if (platform == null) {
await ensurePlatformUris();
- platform =
- loadProgramFromBytes(new File.fromUri(platformUri).readAsBytesSync());
+ platform = loadComponentFromBytes(
+ new File.fromUri(platformUri).readAsBytesSync());
}
return platform;
}
@@ -261,7 +262,7 @@
}
}
-class Outline extends Step<TestDescription, Program, FastaContext> {
+class Outline extends Step<TestDescription, Component, FastaContext> {
final bool fullCompile;
final AstKind astKind;
@@ -279,14 +280,14 @@
bool get isCompiler => fullCompile;
- Future<Result<Program>> run(
+ Future<Result<Component>> run(
TestDescription description, FastaContext context) async {
var options = new ProcessedOptions(new CompilerOptions());
return await CompilerContext.runWithOptions(options, (_) async {
// Disable colors to ensure that expectation files are the same across
// platforms and independent of stdin/stderr.
CompilerContext.current.disableColors();
- Program platform = await context.loadPlatform();
+ Component platform = await context.loadPlatform();
Ticker ticker = new Ticker();
DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator,
new TestVmTarget(new TargetFlags(strongMode: strongMode)));
@@ -301,7 +302,7 @@
: new KernelTarget(
StandardFileSystem.instance, false, dillTarget, uriTranslator);
- Program p;
+ Component p;
try {
sourceTarget.read(description.uri);
await dillTarget.buildOutlines();
@@ -313,7 +314,7 @@
}
p = await sourceTarget.buildOutlines();
if (fullCompile) {
- p = await sourceTarget.buildProgram();
+ p = await sourceTarget.buildComponent();
instrumentation?.finish();
if (instrumentation != null && instrumentation.hasProblems) {
if (updateComments) {
@@ -333,14 +334,15 @@
}
}
-class Transform extends Step<Program, Program, FastaContext> {
+class Transform extends Step<Component, Component, FastaContext> {
const Transform();
- String get name => "transform program";
+ String get name => "transform component";
- Future<Result<Program>> run(Program program, FastaContext context) async {
- KernelTarget sourceTarget = context.programToTarget[program];
- context.programToTarget.remove(program);
+ Future<Result<Component>> run(
+ Component component, FastaContext context) async {
+ KernelTarget sourceTarget = context.programToTarget[component];
+ context.programToTarget.remove(component);
TestVmTarget backendTarget = sourceTarget.backendTarget;
backendTarget.enabled = true;
try {
@@ -350,7 +352,7 @@
} finally {
backendTarget.enabled = false;
}
- return pass(program);
+ return pass(component);
}
}
@@ -371,10 +373,10 @@
}
}
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {
if (enabled) {
- super.performGlobalTransformations(coreTypes, program, logger: logger);
+ super.performGlobalTransformations(coreTypes, component, logger: logger);
}
}
}
diff --git a/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart b/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart
index 269c4c6..7aca4b1 100644
--- a/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart
@@ -8,7 +8,7 @@
import 'package:kernel/ast.dart';
import 'package:kernel/class_hierarchy.dart';
import 'package:kernel/core_types.dart';
-import 'package:kernel/testing/mock_sdk_program.dart';
+import 'package:kernel/testing/mock_sdk_component.dart';
import 'package:kernel/type_algebra.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -23,7 +23,7 @@
class InterfaceResolverTest {
final Library testLib;
- final Program program;
+ final Component component;
final CoreTypes coreTypes;
@@ -35,14 +35,14 @@
InterfaceResolverTest()
: this._(new Library(Uri.parse('org-dartlang:///test.dart'), name: 'lib'),
- createMockSdkProgram());
+ createMockSdkComponent());
- InterfaceResolverTest._(this.testLib, Program program)
- : program = program..libraries.add(testLib..parent = program),
- coreTypes = new CoreTypes(program);
+ InterfaceResolverTest._(this.testLib, Component component)
+ : component = component..libraries.add(testLib..parent = component),
+ coreTypes = new CoreTypes(component);
ClassHierarchy get classHierarchy {
- return cachedClassHierarchy ??= new ClassHierarchy(program);
+ return cachedClassHierarchy ??= new ClassHierarchy(component);
}
TypeSchemaEnvironment get typeEnvironment {
@@ -84,7 +84,7 @@
expect(interfaceMember, same(member));
}
- check(new ClassHierarchy(program));
+ check(new ClassHierarchy(component));
}
Procedure getCandidate(Class class_, bool setter) {
diff --git a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
index d51d345..dddce21 100644
--- a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
@@ -8,7 +8,7 @@
import 'package:kernel/ast.dart';
import 'package:kernel/core_types.dart';
import 'package:kernel/class_hierarchy.dart';
-import 'package:kernel/testing/mock_sdk_program.dart';
+import 'package:kernel/testing/mock_sdk_component.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -29,7 +29,7 @@
final testLib =
new Library(Uri.parse('org-dartlang:///test.dart'), name: 'lib');
- Program program;
+ Component component;
CoreTypes coreTypes;
@@ -42,9 +42,9 @@
Class classQ;
TypeConstraintGathererTest() {
- program = createMockSdkProgram();
- program.libraries.add(testLib..parent = program);
- coreTypes = new CoreTypes(program);
+ component = createMockSdkComponent();
+ component.libraries.add(testLib..parent = component);
+ coreTypes = new CoreTypes(component);
T1 = new TypeParameterType(new TypeParameter('T1', objectType));
T2 = new TypeParameterType(new TypeParameter('T2', objectType));
classP = _addClass(_class('P'));
@@ -209,8 +209,8 @@
void _checkConstraints(
DartType a, DartType b, List<String> expectedConstraints) {
- var typeSchemaEnvironment =
- new TypeSchemaEnvironment(coreTypes, new ClassHierarchy(program), true);
+ var typeSchemaEnvironment = new TypeSchemaEnvironment(
+ coreTypes, new ClassHierarchy(component), true);
var typeConstraintGatherer = new TypeConstraintGatherer(
typeSchemaEnvironment, [T1.parameter, T2.parameter]);
var constraints = typeConstraintGatherer.trySubtypeMatch(a, b)
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
index a8335b2..4621b9a 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
@@ -7,7 +7,7 @@
import 'package:kernel/ast.dart';
import 'package:kernel/core_types.dart';
import 'package:kernel/class_hierarchy.dart';
-import 'package:kernel/testing/mock_sdk_program.dart';
+import 'package:kernel/testing/mock_sdk_component.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -29,14 +29,14 @@
final testLib = new Library(Uri.parse('org-dartlang:///test.dart'));
- Program program;
+ Component component;
CoreTypes coreTypes;
TypeSchemaEnvironmentTest() {
- program = createMockSdkProgram();
- program.libraries.add(testLib..parent = program);
- coreTypes = new CoreTypes(program);
+ component = createMockSdkComponent();
+ component.libraries.add(testLib..parent = component);
+ coreTypes = new CoreTypes(component);
}
InterfaceType get doubleType => coreTypes.doubleClass.rawType;
@@ -714,7 +714,7 @@
TypeSchemaEnvironment _makeEnv() {
return new TypeSchemaEnvironment(
- coreTypes, new ClassHierarchy(program), true);
+ coreTypes, new ClassHierarchy(component), true);
}
DartType _map(DartType key, DartType value) =>
diff --git a/pkg/front_end/test/incremental_load_from_dill_test.dart b/pkg/front_end/test/incremental_load_from_dill_test.dart
index 686cda7..13ab958 100644
--- a/pkg/front_end/test/incremental_load_from_dill_test.dart
+++ b/pkg/front_end/test/incremental_load_from_dill_test.dart
@@ -15,11 +15,11 @@
import 'package:front_end/src/fasta/incremental_compiler.dart'
show IncrementalCompiler;
import 'package:front_end/src/fasta/kernel/utils.dart'
- show writeProgramToFile, serializeProgram;
+ show writeComponentToFile, serializeComponent;
import "package:front_end/src/api_prototype/memory_file_system.dart"
show MemoryFileSystem;
import 'package:kernel/kernel.dart'
- show Class, EmptyStatement, Library, Procedure, Program;
+ show Class, EmptyStatement, Library, Procedure, Component;
import 'package:front_end/src/fasta/fasta_codes.dart' show LocatedMessage;
@@ -366,16 +366,16 @@
IncrementalCompiler compiler =
new IncrementalKernelGenerator(options, main);
Stopwatch stopwatch = new Stopwatch()..start();
- var program = await compiler.computeDelta();
- throwOnEmptyMixinBodies(program);
+ var component = await compiler.computeDelta();
+ throwOnEmptyMixinBodies(component);
print("Normal compile took ${stopwatch.elapsedMilliseconds} ms");
- libCount2 = serializeProgram(program);
- if (program.libraries.length != 2) {
- throw "Expected 2 libraries, got ${program.libraries.length}";
+ libCount2 = serializeComponent(component);
+ if (component.libraries.length != 2) {
+ throw "Expected 2 libraries, got ${component.libraries.length}";
}
- if (program.libraries[0].fileUri != main) {
+ if (component.libraries[0].fileUri != main) {
throw "Expected the first library to have uri $main but was "
- "${program.libraries[0].fileUri}";
+ "${component.libraries[0].fileUri}";
}
}
@@ -399,11 +399,11 @@
compiler.invalidate(main);
compiler.invalidate(b);
Stopwatch stopwatch = new Stopwatch()..start();
- var program = await compiler.computeDelta();
- throwOnEmptyMixinBodies(program);
+ var component = await compiler.computeDelta();
+ throwOnEmptyMixinBodies(component);
print("Bootstrapped compile took ${stopwatch.elapsedMilliseconds} ms");
- if (program.libraries.length != 1) {
- throw "Expected 1 library, got ${program.libraries.length}";
+ if (component.libraries.length != 1) {
+ throw "Expected 1 library, got ${component.libraries.length}";
}
}
}
@@ -434,22 +434,22 @@
{CompilerOptions options}) async {
options ??= getOptions(false);
IncrementalCompiler compiler = new IncrementalKernelGenerator(options, input);
- var program = await compiler.computeDelta();
- throwOnEmptyMixinBodies(program);
- await writeProgramToFile(program, output);
+ var component = await compiler.computeDelta();
+ throwOnEmptyMixinBodies(component);
+ await writeComponentToFile(component, output);
return compiler.initializedFromDill;
}
-void throwOnEmptyMixinBodies(Program program) {
- int empty = countEmptyMixinBodies(program);
+void throwOnEmptyMixinBodies(Component component) {
+ int empty = countEmptyMixinBodies(component);
if (empty != 0) {
throw "Expected 0 empty bodies in mixins, but found $empty";
}
}
-int countEmptyMixinBodies(Program program) {
+int countEmptyMixinBodies(Component component) {
int empty = 0;
- for (Library lib in program.libraries) {
+ for (Library lib in component.libraries) {
for (Class c in lib.classes) {
if (c.isSyntheticMixinImplementation) {
// Assume mixin
@@ -476,7 +476,7 @@
var bootstrappedProgram = await compiler.computeDelta();
throwOnEmptyMixinBodies(bootstrappedProgram);
bool result = compiler.initializedFromDill;
- await writeProgramToFile(bootstrappedProgram, output);
+ await writeComponentToFile(bootstrappedProgram, output);
for (Uri invalidateUri in invalidateUris) {
compiler.invalidate(invalidateUri);
}
diff --git a/pkg/front_end/test/kernel_generator_test.dart b/pkg/front_end/test/kernel_generator_test.dart
index f84b832..6a2c923 100644
--- a/pkg/front_end/test/kernel_generator_test.dart
+++ b/pkg/front_end/test/kernel_generator_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:kernel/ast.dart'
- show EmptyStatement, Program, ReturnStatement, StaticInvocation;
+ show EmptyStatement, Component, ReturnStatement, StaticInvocation;
import 'package:test/test.dart'
show
@@ -28,7 +28,7 @@
import 'package:front_end/src/fasta/fasta_codes.dart' show messageMissingMain;
-import 'package:front_end/src/fasta/kernel/utils.dart' show serializeProgram;
+import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
import 'package:front_end/src/testing/compiler_common.dart'
show
@@ -48,9 +48,9 @@
..compileSdk = true // To prevent FE from loading an sdk-summary.
..onError = (e) => errors.add(e);
- var program =
+ var component =
await compileScript('main() => print("hi");', options: options);
- expect(program, isNull);
+ expect(component, isNull);
expect(errors, isNotEmpty);
});
@@ -61,22 +61,22 @@
Uri.parse('org-dartlang-test:///not_existing_summary_file')
..onError = (e) => errors.add(e);
- var program =
+ var component =
await compileScript('main() => print("hi");', options: options);
- expect(program, isNull);
+ expect(component, isNull);
expect(errors, isNotEmpty);
});
- test('by default program is compiled using the full platform file',
+ test('by default component is compiled using the full platform file',
() async {
var options = new CompilerOptions()
// Note: we define [librariesSpecificationUri] with a specification that
// contains broken URIs to ensure we do not attempt to lookup for
// sources of the sdk directly.
..librariesSpecificationUri = invalidCoreLibsSpecUri;
- var program =
+ var component =
await compileScript('main() => print("hi");', options: options);
- var core = program.libraries.firstWhere(isDartCoreLibrary);
+ var core = component.libraries.firstWhere(isDartCoreLibrary);
var printMember = core.members.firstWhere((m) => m.name.name == 'print');
// Note: summaries created by the SDK today contain empty statements as
@@ -107,29 +107,29 @@
expect(exceptionThrown, isTrue);
}, skip: true /* Issue 30194 */);
- test('generated program contains source-info', () async {
- var program = await compileScript('a() => print("hi"); main() {}',
+ test('generated component contains source-info', () async {
+ var component = await compileScript('a() => print("hi"); main() {}',
fileName: 'a.dart');
// Kernel always store an empty '' key in the map, so there is always at
// least one. Having more means that source-info is added.
- expect(program.uriToSource.keys.length, greaterThan(1));
+ expect(component.uriToSource.keys.length, greaterThan(1));
expect(
- program.uriToSource[Uri.parse('org-dartlang-test:///a/b/c/a.dart')],
+ component.uriToSource[Uri.parse('org-dartlang-test:///a/b/c/a.dart')],
isNotNull);
});
test('code from summary dependencies are marked external', () async {
- var program = await compileScript('a() => print("hi"); main() {}',
+ var component = await compileScript('a() => print("hi"); main() {}',
fileName: 'a.dart');
- for (var lib in program.libraries) {
+ for (var lib in component.libraries) {
if (lib.importUri.scheme == 'dart') {
expect(lib.isExternal, isTrue);
}
}
// Pretend that the compiled code is a summary
- var bytes = serializeProgram(program);
- program = await compileScript(
+ var bytes = serializeComponent(component);
+ component = await compileScript(
{
'b.dart': 'import "a.dart" as m; b() => m.a(); main() {}',
'summary.dill': bytes
@@ -137,22 +137,22 @@
fileName: 'b.dart',
inputSummaries: ['summary.dill']);
- var aLib = program.libraries
+ var aLib = component.libraries
.firstWhere((lib) => lib.importUri.path == '/a/b/c/a.dart');
expect(aLib.isExternal, isTrue);
});
test('code from linked dependencies are not marked external', () async {
- var program = await compileScript('a() => print("hi"); main() {}',
+ var component = await compileScript('a() => print("hi"); main() {}',
fileName: 'a.dart');
- for (var lib in program.libraries) {
+ for (var lib in component.libraries) {
if (lib.importUri.scheme == 'dart') {
expect(lib.isExternal, isTrue);
}
}
- var bytes = serializeProgram(program);
- program = await compileScript(
+ var bytes = serializeComponent(component);
+ component = await compileScript(
{
'b.dart': 'import "a.dart" as m; b() => m.a(); main() {}',
'link.dill': bytes
@@ -160,7 +160,7 @@
fileName: 'b.dart',
linkedDependencies: ['link.dill']);
- var aLib = program.libraries
+ var aLib = component.libraries
.firstWhere((lib) => lib.importUri.path == '/a/b/c/a.dart');
expect(aLib.isExternal, isFalse);
});
@@ -168,7 +168,7 @@
// TODO(sigmund): add tests discovering libraries.json
});
- group('kernelForBuildUnit', () {
+ group('kernelForComponent', () {
test('compiler does not require a main method', () async {
var errors = [];
var options = new CompilerOptions()..onError = (e) => errors.add(e);
@@ -216,17 +216,17 @@
var unitA = await compileUnit(['a.dart'], sources);
// Pretend that the compiled code is a summary
- sources['a.dill'] = serializeProgram(unitA);
+ sources['a.dill'] = serializeComponent(unitA);
var unitBC = await compileUnit(['b.dart', 'c.dart'], sources,
inputSummaries: ['a.dill']);
// Pretend that the compiled code is a summary
- sources['bc.dill'] = serializeProgram(unitBC);
+ sources['bc.dill'] = serializeComponent(unitBC);
- void checkDCallsC(Program program) {
- var dLib = findLibrary(program, 'd.dart');
- var cLib = findLibrary(program, 'c.dart');
+ void checkDCallsC(Component component) {
+ var dLib = findLibrary(component, 'd.dart');
+ var cLib = findLibrary(component, 'c.dart');
var dMethod = dLib.procedures.first;
var dBody = dMethod.function.body;
var dCall = (dBody as ReturnStatement).expression;
diff --git a/pkg/front_end/test/src/base/processed_options_test.dart b/pkg/front_end/test/src/base/processed_options_test.dart
index 359acab..2ce4498 100644
--- a/pkg/front_end/test/src/base/processed_options_test.dart
+++ b/pkg/front_end/test/src/base/processed_options_test.dart
@@ -12,7 +12,7 @@
import 'package:front_end/src/fasta/fasta_codes.dart';
import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
import 'package:kernel/kernel.dart'
- show CanonicalName, Library, Program, loadProgramFromBytes;
+ show CanonicalName, Library, Component, loadComponentFromBytes;
import 'package:package_config/packages.dart' show Packages;
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -30,9 +30,9 @@
MemoryFileSystem fileSystem =
new MemoryFileSystem(Uri.parse('org-dartlang-test:///'));
- Program _mockOutline;
+ Component _mockOutline;
- Program get mockSummary => _mockOutline ??= new Program(
+ Component get mockSummary => _mockOutline ??= new Component(
libraries: [new Library(Uri.parse('org-dartlang-test:///a/b.dart'))]);
test_compileSdk_false() {
@@ -80,7 +80,7 @@
var bytes = await processed.loadSdkSummaryBytes();
expect(bytes, isNotEmpty);
- var sdkSummary = loadProgramFromBytes(bytes);
+ var sdkSummary = loadComponentFromBytes(bytes);
expect(sdkSummary.libraries.single.importUri,
mockSummary.libraries.single.importUri);
}
@@ -95,7 +95,7 @@
void writeMockSummaryTo(Uri uri) {
var sink = new BytesSink();
- new BinaryPrinter(sink).writeProgramFile(mockSummary);
+ new BinaryPrinter(sink).writeComponentFile(mockSummary);
fileSystem.entityForUri(uri).writeAsBytesSync(sink.builder.takeBytes());
}
diff --git a/pkg/front_end/test/src/incremental/hot_reload_e2e_test.dart b/pkg/front_end/test/src/incremental/hot_reload_e2e_test.dart
index 23e91a3..56728d6 100644
--- a/pkg/front_end/test/src/incremental/hot_reload_e2e_test.dart
+++ b/pkg/front_end/test/src/incremental/hot_reload_e2e_test.dart
@@ -17,7 +17,7 @@
import 'package:expect/expect.dart' show Expect;
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
import 'package:kernel/binary/limited_ast_to_binary.dart'
show LimitedBinaryPrinter;
@@ -308,21 +308,21 @@
compiler.invalidate(Uri.parse("org-dartlang-test:///a.dart"));
compiler.invalidate(Uri.parse("org-dartlang-test:///b.dart"));
compiler.invalidate(Uri.parse("org-dartlang-test:///c.dart"));
- var program = await compiler.computeDelta();
- if (program != null && !program.libraries.isEmpty) {
- await writeProgram(program, outputUri);
+ var component = await compiler.computeDelta();
+ if (component != null && !component.libraries.isEmpty) {
+ await writeProgram(component, outputUri);
return true;
}
return false;
}
-Future<Null> writeProgram(Program program, Uri outputUri) async {
+Future<Null> writeProgram(Component component, Uri outputUri) async {
var sink = new File.fromUri(outputUri).openWrite();
// TODO(sigmund): the incremental generator should always filter these
// libraries instead.
new LimitedBinaryPrinter(
sink, (library) => library.importUri.scheme != 'dart', false)
- .writeProgramFile(program);
+ .writeComponentFile(component);
await sink.close();
}
diff --git a/pkg/front_end/test/src/incremental/kernel_driver_test.dart b/pkg/front_end/test/src/incremental/kernel_driver_test.dart
index 28554bd..febded4 100644
--- a/pkg/front_end/test/src/incremental/kernel_driver_test.dart
+++ b/pkg/front_end/test/src/incremental/kernel_driver_test.dart
@@ -567,9 +567,9 @@
'dart.async::Future<dart.core::String>');
// We should be able to serialize the libraries without SDK.
- var program =
- new Program(nameRoot: kernelResult.nameRoot, libraries: allLibraries);
- serializeProgram(program,
+ var component = new Component(
+ nameRoot: kernelResult.nameRoot, libraries: allLibraries);
+ serializeComponent(component,
filter: (library) => !library.importUri.isScheme('dart'));
}
@@ -710,43 +710,43 @@
KernelSequenceResult result = await driver.getKernelSequence(bUri);
- Program program = new Program(
+ Component component = new Component(
nameRoot: result.nameRoot, libraries: _allLibraries(result));
String initialKernelText;
List<int> bytes;
{
- Library initialLibrary = _getLibraryFromProgram(program, bUri);
+ Library initialLibrary = _getLibraryFromProgram(component, bUri);
initialKernelText = _getLibraryText(initialLibrary);
- bytes = serializeProgram(program,
+ bytes = serializeComponent(component,
filter: (library) => library.importUri == bUri);
- // Remove b.dart from the program.
- // So, the program is now ready for re-adding the library.
- program.mainMethod = null;
- program.libraries.remove(initialLibrary);
- program.root.removeChild(initialLibrary.importUri.toString());
+ // Remove b.dart from the component.
+ // So, the component is now ready for re-adding the library.
+ component.mainMethod = null;
+ component.libraries.remove(initialLibrary);
+ component.root.removeChild(initialLibrary.importUri.toString());
}
// Load b.dart from bytes using the initial name root, so that
// serialized canonical names can be linked to corresponding nodes.
Library loadedLibrary;
{
- var programForLoading = new Program(nameRoot: program.root);
+ var programForLoading = new Component(nameRoot: component.root);
var reader = new BinaryBuilder(bytes);
- reader.readProgram(programForLoading);
+ reader.readComponent(programForLoading);
loadedLibrary = _getLibraryFromProgram(programForLoading, bUri);
}
- // Add the library into the program.
- program.libraries.add(loadedLibrary);
- loadedLibrary.parent = program;
- program.mainMethod = loadedLibrary.procedures
+ // Add the library into the component.
+ component.libraries.add(loadedLibrary);
+ loadedLibrary.parent = component;
+ component.mainMethod = loadedLibrary.procedures
.firstWhere((procedure) => procedure.name.name == 'main');
expect(_getLibraryText(loadedLibrary), initialKernelText);
- verifyProgram(program);
+ verifyComponent(component);
}
test_updatePackageSourceUsingFileUri() async {
@@ -1023,8 +1023,8 @@
fail('No library found with URI "$uri"');
}
- Library _getLibraryFromProgram(Program program, Uri uri) {
- for (var library in program.libraries) {
+ Library _getLibraryFromProgram(Component component, Uri uri) {
+ for (var library in component.libraries) {
if (library.importUri == uri) return library;
}
fail('No library found with URI "$uri"');
diff --git a/pkg/front_end/test/summary_generator_test.dart b/pkg/front_end/test/summary_generator_test.dart
index 36306a2..05d582c 100644
--- a/pkg/front_end/test/summary_generator_test.dart
+++ b/pkg/front_end/test/summary_generator_test.dart
@@ -12,17 +12,17 @@
main() {
test('summary has no source-info by default', () async {
var summary = await summarize(['a.dart'], allSources);
- var program = loadProgramFromBytes(summary);
+ var component = loadComponentFromBytes(summary);
// Note: the kernel representation always has an empty '' key in the map,
// but otherwise no other data is included here.
- expect(program.uriToSource.keys.single, Uri.parse(""));
+ expect(component.uriToSource.keys.single, Uri.parse(""));
});
test('summary includes declarations, but no method bodies', () async {
var summary = await summarize(['a.dart'], allSources);
- var program = loadProgramFromBytes(summary);
- var aLib = findLibrary(program, 'a.dart');
+ var component = loadComponentFromBytes(summary);
+ var aLib = findLibrary(component, 'a.dart');
expect(aLib.importUri.path, '/a/b/c/a.dart');
var classA = aLib.classes.first;
expect(classA.name, 'A');
@@ -33,8 +33,8 @@
test('summarized libraries are not marked external', () async {
var summary = await summarize(['a.dart'], allSources);
- var program = loadProgramFromBytes(summary);
- var aLib = findLibrary(program, 'a.dart');
+ var component = loadComponentFromBytes(summary);
+ var aLib = findLibrary(component, 'a.dart');
expect(aLib.importUri.path, '/a/b/c/a.dart');
expect(aLib.isExternal, isFalse);
});
@@ -42,8 +42,8 @@
test('sdk dependencies are marked external', () async {
// Note: by default this test is loading the SDK from summaries.
var summary = await summarize(['a.dart'], allSources);
- var program = loadProgramFromBytes(summary);
- var coreLib = findLibrary(program, 'core');
+ var component = loadComponentFromBytes(summary);
+ var coreLib = findLibrary(component, 'core');
expect(coreLib.isExternal, isTrue);
});
@@ -54,9 +54,9 @@
var summaryB =
await summarize(['b.dart'], sourcesWithA, inputSummaries: ['a.dill']);
- var program = loadProgramFromBytes(summaryB);
- var aLib = findLibrary(program, 'a.dart');
- var bLib = findLibrary(program, 'b.dart');
+ var component = loadComponentFromBytes(summaryB);
+ var aLib = findLibrary(component, 'a.dart');
+ var bLib = findLibrary(component, 'b.dart');
expect(aLib.isExternal, isTrue);
expect(bLib.isExternal, isFalse);
});
@@ -103,17 +103,19 @@
test('dependencies not included in truncated summaries', () async {
// Note: by default this test is loading the SDK from summaries.
var summaryA = await summarize(['a.dart'], allSources, truncate: true);
- var program = loadProgramFromBytes(summaryA);
- expect(program.libraries.length, 1);
- expect(program.libraries.single.importUri.path.endsWith('a.dart'), isTrue);
+ var component = loadComponentFromBytes(summaryA);
+ expect(component.libraries.length, 1);
+ expect(
+ component.libraries.single.importUri.path.endsWith('a.dart'), isTrue);
var sourcesWithA = new Map.from(allSources);
sourcesWithA['a.dill'] = summaryA;
var summaryB = await summarize(['b.dart'], sourcesWithA,
inputSummaries: ['a.dill'], truncate: true);
- program = loadProgramFromBytes(summaryB);
- expect(program.libraries.length, 1);
- expect(program.libraries.single.importUri.path.endsWith('b.dart'), isTrue);
+ component = loadComponentFromBytes(summaryB);
+ expect(component.libraries.length, 1);
+ expect(
+ component.libraries.single.importUri.path.endsWith('b.dart'), isTrue);
});
test('summarization by default is hermetic', () async {
@@ -143,11 +145,11 @@
/// Helper function to check that some expectations from the summary of D.
checkDSummary(List<int> summary) {
- var program = loadProgramFromBytes(summary);
- var aLib = findLibrary(program, 'a.dart');
- var bLib = findLibrary(program, 'b.dart');
- var cLib = findLibrary(program, 'c.dart');
- var dLib = findLibrary(program, 'd.dart');
+ var component = loadComponentFromBytes(summary);
+ var aLib = findLibrary(component, 'a.dart');
+ var bLib = findLibrary(component, 'b.dart');
+ var cLib = findLibrary(component, 'c.dart');
+ var dLib = findLibrary(component, 'd.dart');
// All libraries but `d.dart` are marked external.
expect(aLib.isExternal, isTrue);
diff --git a/pkg/front_end/tool/_fasta/bulk_compile.dart b/pkg/front_end/tool/_fasta/bulk_compile.dart
index 6a8c52a..7101a1a 100644
--- a/pkg/front_end/tool/_fasta/bulk_compile.dart
+++ b/pkg/front_end/tool/_fasta/bulk_compile.dart
@@ -52,7 +52,7 @@
(CompilerContext context) async {
(await context.options.loadSdkSummary(null))?.computeCanonicalNames();
CompilerResult result = await generateKernelInternal();
- result?.program?.unbindCanonicalNames();
+ result?.component?.unbindCanonicalNames();
return null;
});
}
diff --git a/pkg/front_end/tool/_fasta/compile_platform.dart b/pkg/front_end/tool/_fasta/compile_platform.dart
index 738a0f1..5629776 100644
--- a/pkg/front_end/tool/_fasta/compile_platform.dart
+++ b/pkg/front_end/tool/_fasta/compile_platform.dart
@@ -18,7 +18,8 @@
import 'package:front_end/src/fasta/deprecated_problems.dart'
show deprecated_InputError;
-import 'package:front_end/src/fasta/kernel/utils.dart' show writeProgramToFile;
+import 'package:front_end/src/fasta/kernel/utils.dart'
+ show writeComponentToFile;
import 'package:front_end/src/fasta/severity.dart' show Severity;
@@ -67,7 +68,7 @@
}
var result =
- await generateKernelInternal(buildSummary: true, buildProgram: true);
+ await generateKernelInternal(buildSummary: true, buildComponent: true);
if (result == null) {
exitCode = 1;
// Note: an error should have been reported by now.
@@ -76,10 +77,10 @@
}
new File.fromUri(outlineOutput).writeAsBytesSync(result.summary);
c.options.ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}");
- await writeProgramToFile(result.program, fullOutput,
+ await writeComponentToFile(result.component, fullOutput,
filter: (lib) => !lib.isExternal);
- c.options.ticker.logMs("Wrote program to ${fullOutput.toFilePath()}");
+ c.options.ticker.logMs("Wrote component to ${fullOutput.toFilePath()}");
List<Uri> deps = result.deps.toList();
deps.addAll(await getDependencies(Platform.script,
diff --git a/pkg/front_end/tool/_fasta/dump_partial.dart b/pkg/front_end/tool/_fasta/dump_partial.dart
index b97ba45..610fdb7 100644
--- a/pkg/front_end/tool/_fasta/dump_partial.dart
+++ b/pkg/front_end/tool/_fasta/dump_partial.dart
@@ -16,18 +16,18 @@
return;
}
- var program = _loadProgram(args);
- writeProgramToText(program);
+ var component = _loadComponent(args);
+ writeComponentToText(component);
}
-/// Creates a program that contains all of the context code marked as external,
+/// Creates a component that contains all of the context code marked as external,
/// and all libraries defined in partial.dill as they are written in that file.
-Program _loadProgram(List<String> args) {
+Component _loadComponent(List<String> args) {
List<int> partialInput = new File(args[0]).readAsBytesSync();
- var context = new Program();
+ var context = new Component();
for (var i = 1; i < args.length; i++) {
- loadProgramFromBinary(args[i], context);
+ loadComponentFromBinary(args[i], context);
}
Set<Uri> libraries = _definedLibraries(partialInput, context);
@@ -36,30 +36,30 @@
// of libraries that are mentioned in more than one .dill file. In order to
// keep the contents of partial.dill intact, we build a new context that
// excludes those libraries defined in partial.dill.
- List<int> contextBytes = serializeProgram(context,
+ List<int> contextBytes = serializeComponent(context,
filter: (l) => !libraries.contains(l.importUri));
- var program = new Program();
- loadProgramFromBytes(contextBytes, program);
- _updateIsExternal(program, true);
- loadProgramFromBytes(partialInput, program);
- return program;
+ var component = new Component();
+ loadComponentFromBytes(contextBytes, component);
+ _updateIsExternal(component, true);
+ loadComponentFromBytes(partialInput, component);
+ return component;
}
/// Compute the set of libraries defined in [partialDill].
///
-/// The [context] program contains all other libraries that may be needed to
+/// The [context] component contains all other libraries that may be needed to
/// properly deserialize partialDill.
///
/// Note: This function will mutate [context] in place.
// TODO(sigmund): simplify and get rid of [context]. We could do that with a
// custom deserialization, but it will be easier to do once .dill has
// random-access support.
-Set<Uri> _definedLibraries(List<int> partialDill, Program context) {
+Set<Uri> _definedLibraries(List<int> partialDill, Component context) {
_updateIsExternal(context, true);
// This implicitly sets `isExternal = false` on all libraries defined in the
// partial.dill file.
- loadProgramFromBytes(partialDill, context);
+ loadComponentFromBytes(partialDill, context);
var result = context.libraries
.where((l) => !l.isExternal)
.map((l) => l.importUri)
@@ -68,6 +68,6 @@
return result;
}
-void _updateIsExternal(Program program, bool toValue) {
- program.libraries.forEach((lib) => lib.isExternal = toValue);
+void _updateIsExternal(Component component, bool toValue) {
+ component.libraries.forEach((lib) => lib.isExternal = toValue);
}
diff --git a/pkg/front_end/tool/_fasta/entry_points.dart b/pkg/front_end/tool/_fasta/entry_points.dart
index 8411f0e..78d1163 100644
--- a/pkg/front_end/tool/_fasta/entry_points.dart
+++ b/pkg/front_end/tool/_fasta/entry_points.dart
@@ -13,7 +13,7 @@
import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget;
import 'package:kernel/kernel.dart'
- show CanonicalName, Library, Program, Source, loadProgramFromBytes;
+ show CanonicalName, Library, Component, Source, loadComponentFromBytes;
import 'package:kernel/target/targets.dart' show TargetFlags, targets;
@@ -34,7 +34,7 @@
show KernelTarget;
import 'package:front_end/src/fasta/kernel/utils.dart'
- show printProgramText, writeProgramToFile;
+ show printComponentText, writeComponentToFile;
import 'package:front_end/src/fasta/severity.dart' show Severity;
@@ -91,7 +91,7 @@
Uri platformUri;
- Program platformComponent;
+ Component platformComponent;
BatchCompiler(this.lines);
@@ -233,10 +233,10 @@
await dillTarget.buildOutlines();
var outline = await kernelTarget.buildOutlines();
if (c.options.debugDump && output != null) {
- printProgramText(outline, libraryFilter: kernelTarget.isSourceLibrary);
+ printComponentText(outline, libraryFilter: kernelTarget.isSourceLibrary);
}
if (output != null) {
- await writeProgramToFile(outline, output);
+ await writeComponentToFile(outline, output);
ticker.logMs("Wrote outline to ${output.toFilePath()}");
}
return kernelTarget;
@@ -245,35 +245,37 @@
Future<Uri> compile({bool sansPlatform: false}) async {
KernelTarget kernelTarget = await buildOutline();
Uri uri = c.options.output;
- Program program = await kernelTarget.buildProgram(verify: c.options.verify);
+ Component component =
+ await kernelTarget.buildComponent(verify: c.options.verify);
if (c.options.debugDump) {
- printProgramText(program, libraryFilter: kernelTarget.isSourceLibrary);
+ printComponentText(component,
+ libraryFilter: kernelTarget.isSourceLibrary);
}
if (sansPlatform) {
- program.computeCanonicalNames();
- Program userCode = new Program(
- nameRoot: program.root,
- uriToSource: new Map<Uri, Source>.from(program.uriToSource));
- userCode.mainMethodName = program.mainMethodName;
- for (Library library in program.libraries) {
+ component.computeCanonicalNames();
+ Component userCode = new Component(
+ nameRoot: component.root,
+ uriToSource: new Map<Uri, Source>.from(component.uriToSource));
+ userCode.mainMethodName = component.mainMethodName;
+ for (Library library in component.libraries) {
if (library.importUri.scheme != "dart") {
userCode.libraries.add(library);
}
}
- program = userCode;
+ component = userCode;
}
if (uri.scheme == "file") {
- await writeProgramToFile(program, uri);
- ticker.logMs("Wrote program to ${uri.toFilePath()}");
+ await writeComponentToFile(component, uri);
+ ticker.logMs("Wrote component to ${uri.toFilePath()}");
}
return uri;
}
}
-/// Load the [Program] from the given [uri] and append its libraries
+/// Load the [Component] from the given [uri] and append its libraries
/// to the [dillTarget].
void _appendDillForUri(DillTarget dillTarget, Uri uri) {
var bytes = new File.fromUri(uri).readAsBytesSync();
- var platformProgram = loadProgramFromBytes(bytes);
+ var platformProgram = loadComponentFromBytes(bytes);
dillTarget.loader.appendLibraries(platformProgram, byteCount: bytes.length);
}
diff --git a/pkg/front_end/tool/example.dart b/pkg/front_end/tool/example.dart
index a826fe8..56966d1 100644
--- a/pkg/front_end/tool/example.dart
+++ b/pkg/front_end/tool/example.dart
@@ -7,22 +7,22 @@
import 'package:front_end/src/api_prototype/kernel_generator.dart';
import 'package:front_end/src/api_prototype/compiler_options.dart';
import 'package:kernel/binary/ast_to_binary.dart';
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
-Future dumpToSink(Program program, StreamSink<List<int>> sink) {
- new BinaryPrinter(sink).writeProgramFile(program);
+Future dumpToSink(Component component, StreamSink<List<int>> sink) {
+ new BinaryPrinter(sink).writeComponentFile(component);
return sink.close();
}
Future kernelToSink(Uri entry, StreamSink<List<int>> sink) async {
- var program = await kernelForProgram(
+ var component = await kernelForProgram(
entry,
new CompilerOptions()
..sdkRoot = new Uri.file('sdk')
..packagesFileUri = new Uri.file('.packages')
..onError = (e) => print(e.message));
- await dumpToSink(program, sink);
+ await dumpToSink(component, sink);
}
main(args) async {
diff --git a/pkg/front_end/tool/fasta_perf.dart b/pkg/front_end/tool/fasta_perf.dart
index eb0b2b5..de09e9a 100644
--- a/pkg/front_end/tool/fasta_perf.dart
+++ b/pkg/front_end/tool/fasta_perf.dart
@@ -259,7 +259,7 @@
Uri.parse('dart:mirrors'),
Uri.parse('dart:typed_data'),
];
- var program = await kernelForBuildUnit(entrypoints, options);
+ var program = await kernelForComponent(entrypoints, options);
timer.stop();
var name = 'kernel_gen_e2e${compileSdk ? "" : "_sum"}';
diff --git a/pkg/kernel/bin/count_breakdown.dart b/pkg/kernel/bin/count_breakdown.dart
index 7517816..b3dbc17 100755
--- a/pkg/kernel/bin/count_breakdown.dart
+++ b/pkg/kernel/bin/count_breakdown.dart
@@ -19,9 +19,9 @@
main(List<String> args) {
CommandLineHelper.requireExactlyOneArgument(true, args, usage);
- Program program = CommandLineHelper.tryLoadDill(args[0], usage);
+ Component component = CommandLineHelper.tryLoadDill(args[0], usage);
TypeCounter counter = new TypeCounter();
- program.accept(counter);
+ component.accept(counter);
counter.printStats();
}
diff --git a/pkg/kernel/bin/dump.dart b/pkg/kernel/bin/dump.dart
index 32a9058..fc69f95 100755
--- a/pkg/kernel/bin/dump.dart
+++ b/pkg/kernel/bin/dump.dart
@@ -27,7 +27,7 @@
CommandLineHelper.requireVariableArgumentCount([1, 2], args, usage);
CommandLineHelper.requireFileExists(args[0], usage);
var binary = CommandLineHelper.tryLoadDill(args[0], usage);
- writeProgramToText(binary,
+ writeComponentToText(binary,
path: args.length > 1 ? args[1] : null,
showOffsets: const bool.fromEnvironment("showOffsets"));
}
diff --git a/pkg/kernel/bin/eval.dart b/pkg/kernel/bin/eval.dart
index bdd3dda..491f726 100755
--- a/pkg/kernel/bin/eval.dart
+++ b/pkg/kernel/bin/eval.dart
@@ -21,6 +21,6 @@
main(List<String> args) {
CommandLineHelper.requireExactlyOneArgument(true, args, usage);
- Program program = CommandLineHelper.tryLoadDill(args[0], usage);
- new Interpreter(program).run();
+ Component component = CommandLineHelper.tryLoadDill(args[0], usage);
+ new Interpreter(component).run();
}
diff --git a/pkg/kernel/bin/size_breakdown.dart b/pkg/kernel/bin/size_breakdown.dart
index 90634e8..c2608ed 100755
--- a/pkg/kernel/bin/size_breakdown.dart
+++ b/pkg/kernel/bin/size_breakdown.dart
@@ -24,8 +24,8 @@
CommandLineHelper.requireExactlyOneArgument(true, args, usage);
List<int> bytes = new File(args[0]).readAsBytesSync();
try {
- Program p = new Program();
- new WrappedBinaryBuilder(bytes).readProgram(p);
+ Component p = new Component();
+ new WrappedBinaryBuilder(bytes).readComponent(p);
} catch (e) {
print("Argument given isn't a dill file that can be loaded.");
usage();
@@ -64,9 +64,9 @@
print("Constant table: ${_bytesToReadable(size)}.");
}
- Library readLibrary(Program program, int endOffset) {
+ Library readLibrary(Component component, int endOffset) {
int size = -byteOffset;
- var result = super.readLibrary(program, endOffset);
+ var result = super.readLibrary(component, endOffset);
size += super.byteOffset;
print("Library '${result.importUri}': ${_bytesToReadable(size)}.");
return result;
diff --git a/pkg/kernel/bin/split.dart b/pkg/kernel/bin/split.dart
index f6de5e4..8a4df58 100755
--- a/pkg/kernel/bin/split.dart
+++ b/pkg/kernel/bin/split.dart
@@ -25,7 +25,7 @@
main(args) async {
CommandLineHelper.requireExactlyOneArgument(true, args, usage);
- Program binary = CommandLineHelper.tryLoadDill(args[0], usage);
+ Component binary = CommandLineHelper.tryLoadDill(args[0], usage);
int part = 1;
binary.libraries.forEach((lib) => lib.isExternal = true);
@@ -36,19 +36,19 @@
lib.name == "nativewrappers") continue;
lib.isExternal = false;
String path = args[0] + ".part${part++}.dill";
- await writeProgramToFile(binary, path);
+ await writeComponentToFile(binary, path);
print("Wrote $path");
lib.isExternal = true;
}
}
-Future<Null> writeProgramToFile(Program program, String path) async {
+Future<Null> writeComponentToFile(Component component, String path) async {
File output = new File(path);
IOSink sink = output.openWrite();
try {
BinaryPrinter printer =
new LimitedBinaryPrinter(sink, (lib) => !lib.isExternal, false);
- printer.writeProgramFile(program);
+ printer.writeComponentFile(component);
} finally {
await sink.close();
}
diff --git a/pkg/kernel/bin/transform.dart b/pkg/kernel/bin/transform.dart
index 1e0e668..1898ede 100755
--- a/pkg/kernel/bin/transform.dart
+++ b/pkg/kernel/bin/transform.dart
@@ -82,23 +82,23 @@
List<treeshaker.ProgramRoot> programRoots =
parseProgramRoots(embedderEntryPointManifests);
- var program = loadProgramFromBinary(input);
+ var component = loadComponentFromBinary(input);
- final coreTypes = new CoreTypes(program);
- final hierarchy = new ClassHierarchy(program);
+ final coreTypes = new CoreTypes(component);
+ final hierarchy = new ClassHierarchy(component);
switch (options['transformation']) {
case 'continuation':
- program = cont.transformProgram(coreTypes, program, syncAsync);
+ component = cont.transformComponent(coreTypes, component, syncAsync);
break;
case 'resolve-mixins':
mix.transformLibraries(
- new NoneTarget(null), coreTypes, hierarchy, program.libraries);
+ new NoneTarget(null), coreTypes, hierarchy, component.libraries);
break;
case 'closures':
- program = closures.transformProgram(coreTypes, program);
+ component = closures.transformComponent(coreTypes, component);
break;
case 'coq':
- program = coq.transformProgram(coreTypes, program);
+ component = coq.transformComponent(coreTypes, component);
break;
case 'constants':
// We use the -D defines supplied to this VM instead of explicitly using a
@@ -106,17 +106,18 @@
final Map<String, String> defines = null;
final VmConstantsBackend backend =
new VmConstantsBackend(defines, coreTypes);
- program = constants.transformProgram(program, backend);
+ component = constants.transformComponent(component, backend);
break;
case 'treeshake':
- program = treeshaker.transformProgram(coreTypes, hierarchy, program,
+ component = treeshaker.transformComponent(coreTypes, hierarchy, component,
programRoots: programRoots);
break;
case 'methodcall':
- program = method_call.transformProgram(coreTypes, hierarchy, program);
+ component =
+ method_call.transformComponent(coreTypes, hierarchy, component);
break;
case 'empty':
- program = empty.transformProgram(program);
+ component = empty.transformComponent(component);
break;
default:
throw 'Unknown transformation';
@@ -125,17 +126,17 @@
// TODO(30631): Fix the verifier so we can check that the transform produced
// valid output.
//
- // verifyProgram(program);
+ // verifyComponent(component);
if (format == 'text') {
- writeProgramToText(program, path: output);
+ writeComponentToText(component, path: output);
} else {
assert(format == 'bin');
- await writeProgramToBinary(program, output);
+ await writeComponentToBinary(component, output);
}
if (verbose) {
- writeLibraryToText(program.mainMethod.parent as Library);
+ writeLibraryToText(component.mainMethod.parent as Library);
}
return CompilerOutcome.Ok;
diff --git a/pkg/kernel/bin/type_check.dart b/pkg/kernel/bin/type_check.dart
index 2c062de..e732ab6 100755
--- a/pkg/kernel/bin/type_check.dart
+++ b/pkg/kernel/bin/type_check.dart
@@ -24,7 +24,7 @@
CommandLineHelper.requireExactlyOneArgument(true, args, usage);
final binary = CommandLineHelper.tryLoadDill(args[0], usage);
ErrorFormatter errorFormatter = new ErrorFormatter();
- new StrongModeTypeChecker(errorFormatter, binary)..checkProgram(binary);
+ new StrongModeTypeChecker(errorFormatter, binary)..checkComponent(binary);
if (errorFormatter.numberOfFailures > 0) {
errorFormatter.failures.forEach(print);
print('------- Found ${errorFormatter.numberOfFailures} errors -------');
diff --git a/pkg/kernel/bin/util.dart b/pkg/kernel/bin/util.dart
index 315869b..35988b5 100644
--- a/pkg/kernel/bin/util.dart
+++ b/pkg/kernel/bin/util.dart
@@ -93,9 +93,9 @@
}
}
- static Program tryLoadDill(String file, void Function() usage) {
+ static Component tryLoadDill(String file, void Function() usage) {
try {
- return loadProgramFromBinary(file);
+ return loadComponentFromBinary(file);
} catch (e) {
print("Argument '$file' isn't a dill file that can be loaded.");
usage();
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index f2e05f7..9305d16 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -75,11 +75,11 @@
}
type StringReference {
- UInt index; // Index into the Program's strings.
+ UInt index; // Index into the Component's strings.
}
type ConstantReference {
- UInt index; // Index into the Program's constants.
+ UInt index; // Index into the Component's constants.
}
type SourceInfo {
@@ -127,7 +127,7 @@
StringReference name;
}
-type ProgramFile {
+type ComponentFile {
UInt32 magic = 0x90ABCDEF;
UInt32 formatVersion;
MetadataPayload[] metadataPayloads;
@@ -137,7 +137,7 @@
RList<MetadataMapping> metadataMappings;
StringTable strings;
List<Constant> constants;
- ProgramIndex programIndex;
+ ComponentIndex componentIndex;
}
// Backend specific metadata section.
@@ -152,12 +152,12 @@
// they are encoded as indices in this array.
}
-// Program index with all fixed-size-32-bit integers.
+// Component index with all fixed-size-32-bit integers.
// This gives "semi-random-access" to certain parts of the binary.
// By reading the last 4 bytes one knows the number of libaries,
-// which allows to skip to any other field in this program index,
+// which allows to skip to any other field in this component index,
// which again allows to skip to what it points to.
-type ProgramIndex {
+type ComponentIndex {
UInt32 binaryOffsetForSourceTable;
UInt32 binaryOffsetForCanonicalNames;
UInt32 binaryOffsetForStringTable;
@@ -165,7 +165,7 @@
UInt32 mainMethodReference; // This is a ProcedureReference with a fixed-size integer.
UInt32[libraryCount + 1] libraryOffsets;
UInt32 libraryCount;
- UInt32 programFileSizeInBytes;
+ UInt32 componentFileSizeInBytes;
}
type LibraryReference {
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 2fea0a0..2152cd9 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -153,7 +153,7 @@
parent = null;
}
- Program get enclosingProgram => parent?.enclosingProgram;
+ Component get enclosingComponent => parent?.enclosingComponent;
/// Returns the best known source location of the given AST node, or `null` if
/// the node is orphaned.
@@ -436,7 +436,7 @@
String toString() => debugLibraryName(this);
Location _getLocationInEnclosingFile(int offset) {
- return _getLocationInProgram(enclosingProgram, fileUri, offset);
+ return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -929,7 +929,7 @@
}
Location _getLocationInEnclosingFile(int offset) {
- return _getLocationInProgram(enclosingProgram, fileUri, offset);
+ return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -1210,7 +1210,7 @@
DartType get setterType => isMutable ? type : const BottomType();
Location _getLocationInEnclosingFile(int offset) {
- return _getLocationInProgram(enclosingProgram, fileUri, offset);
+ return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -1298,7 +1298,7 @@
DartType get setterType => const BottomType();
Location _getLocationInEnclosingFile(int offset) {
- return _getLocationInProgram(enclosingProgram, fileUri, offset);
+ return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -1428,7 +1428,7 @@
DartType get setterType => const BottomType();
Location _getLocationInEnclosingFile(int offset) {
- return _getLocationInProgram(enclosingProgram, fileUri, offset);
+ return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -1671,7 +1671,7 @@
}
Location _getLocationInEnclosingFile(int offset) {
- return _getLocationInProgram(enclosingProgram, fileUri, offset);
+ return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -4923,7 +4923,7 @@
///
/// * Access to Vectors is untyped.
///
-/// * Vectors can be used by various transformations of Kernel programs.
+/// * Vectors can be used by various transformations of Kernel components.
/// Currently they are used by Closure Conversion to represent closure contexts.
class VectorType extends DartType {
const VectorType();
@@ -5583,11 +5583,11 @@
}
// ------------------------------------------------------------------------
-// PROGRAM
+// COMPONENT
// ------------------------------------------------------------------------
-/// A way to bundle up all the libraries in a program.
-class Program extends TreeNode {
+/// A way to bundle up libraries in a component.
+class Component extends TreeNode {
final CanonicalName root;
final List<Library> libraries;
@@ -5605,7 +5605,7 @@
/// Reference to the main method in one of the libraries.
Reference mainMethodName;
- Program(
+ Component(
{CanonicalName nameRoot,
List<Library> libraries,
Map<Uri, Source> uriToSource})
@@ -5614,7 +5614,7 @@
uriToSource = uriToSource ?? <Uri, Source>{} {
if (libraries != null) {
for (int i = 0; i < libraries.length; ++i) {
- // The libraries are owned by this program, and so are their canonical
+ // The libraries are owned by this component, and so are their canonical
// names if they exist.
Library library = libraries[i];
library.parent = this;
@@ -5643,7 +5643,7 @@
mainMethodName = getMemberReference(main);
}
- accept(TreeVisitor v) => v.visitProgram(this);
+ accept(TreeVisitor v) => v.visitComponent(this);
visitChildren(Visitor v) {
visitList(libraries, v);
@@ -5654,7 +5654,7 @@
transformList(libraries, v, this);
}
- Program get enclosingProgram => this;
+ Component get enclosingComponent => this;
/// Translates an offset to line and column numbers in the given file.
Location getLocation(Uri file, int offset) {
@@ -5977,9 +5977,9 @@
/// static analysis and runtime behavior of the library are unaffected.
const informative = null;
-Location _getLocationInProgram(Program program, Uri fileUri, int offset) {
- if (program != null) {
- return program.getLocation(fileUri, offset);
+Location _getLocationInComponent(Component component, Uri fileUri, int offset) {
+ if (component != null) {
+ return component.getLocation(fileUri, offset);
} else {
return new Location(fileUri, TreeNode.noOffset, TreeNode.noOffset);
}
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 042744b..ce35260 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -22,7 +22,7 @@
String toString() => '$filename:$byteIndex: $message at $path';
}
-class _ProgramIndex {
+class _ComponentIndex {
int binaryOffsetForSourceTable;
int binaryOffsetForStringTable;
int binaryOffsetForCanonicalNames;
@@ -30,7 +30,7 @@
int mainMethodReference;
List<int> libraryOffsets;
int libraryCount;
- int programFileSizeInBytes;
+ int componentFileSizeInBytes;
}
class BinaryBuilder {
@@ -48,7 +48,7 @@
List<CanonicalName> _linkTable;
int _transformerFlags = 0;
Library _currentLibrary;
- int _programStartOffset = 0;
+ int _componentStartOffset = 0;
// If something goes wrong, this list should indicate what library,
// class, and member was being built.
@@ -128,15 +128,15 @@
/// Read metadataMappings section from the binary. Return [true] if
/// any metadata mapping contains metadata with node references.
/// In this case we need to disable lazy loading of the binary.
- bool _readMetadataSection(Program program) {
+ bool _readMetadataSection(Component component) {
// Default reader ignores metadata section entirely.
return false;
}
- /// Process any pending metadata associations. Called once the Program
+ /// Process any pending metadata associations. Called once the Component
/// is fully deserialized and metadata containing references to nodes can
/// be safely parsed.
- void _processPendingMetadataAssociations(Program program) {
+ void _processPendingMetadataAssociations(Component component) {
// Default reader ignores metadata section entirely.
}
@@ -342,14 +342,14 @@
}
}
- List<int> _indexPrograms() {
+ List<int> _indexComponents() {
int savedByteOffset = _byteOffset;
_byteOffset = _bytes.length - 4;
List<int> index = <int>[];
while (_byteOffset > 0) {
int size = readUint32();
int start = _byteOffset - size;
- if (start < 0) throw "Invalid program file: Indicated size is invalid.";
+ if (start < 0) throw "Invalid component file: Indicated size is invalid.";
index.add(size);
_byteOffset = start - 4;
}
@@ -357,65 +357,65 @@
return new List.from(index.reversed);
}
- /// Deserializes a kernel program and stores it in [program].
+ /// Deserializes a kernel component and stores it in [component].
///
- /// When linking with a non-empty program, canonical names must have been
+ /// When linking with a non-empty component, canonical names must have been
/// computed ahead of time.
///
/// The input bytes may contain multiple files concatenated.
- void readProgram(Program program) {
- List<int> programFileSizes = _indexPrograms();
- if (programFileSizes.length > 1) {
+ void readComponent(Component component) {
+ List<int> componentFileSizes = _indexComponents();
+ if (componentFileSizes.length > 1) {
_disableLazyReading = true;
}
- int programFileIndex = 0;
+ int componentFileIndex = 0;
while (_byteOffset < _bytes.length) {
- _readOneProgram(program, programFileSizes[programFileIndex]);
- ++programFileIndex;
+ _readOneComponent(component, componentFileSizes[componentFileIndex]);
+ ++componentFileIndex;
}
}
- /// Reads a single program file from the input and loads it into [program],
- /// overwriting and reusing any existing data in the program.
+ /// Reads a single component file from the input and loads it into [component],
+ /// overwriting and reusing any existing data in the component.
///
- /// When linking with a non-empty program, canonical names must have been
+ /// When linking with a non-empty component, canonical names must have been
/// computed ahead of time.
///
/// This should *only* be used when there is a reason to not allow
/// concatenated files.
- void readSingleFileProgram(Program program) {
- List<int> programFileSizes = _indexPrograms();
- if (programFileSizes.isEmpty) throw "Invalid program data.";
- _readOneProgram(program, programFileSizes[0]);
+ void readSingleFileComponent(Component component) {
+ List<int> componentFileSizes = _indexComponents();
+ if (componentFileSizes.isEmpty) throw "Invalid component data.";
+ _readOneComponent(component, componentFileSizes[0]);
if (_byteOffset < _bytes.length) {
if (_byteOffset + 3 < _bytes.length) {
int magic = readUint32();
- if (magic == Tag.ProgramFile) {
- throw 'Concatenated program file given when a single program '
+ if (magic == Tag.ComponentFile) {
+ throw 'Concatenated component file given when a single component '
'was expected.';
}
}
- throw 'Unrecognized bytes following program data';
+ throw 'Unrecognized bytes following component data';
}
}
- _ProgramIndex _readProgramIndex(int programFileSize) {
+ _ComponentIndex _readComponentIndex(int componentFileSize) {
int savedByteIndex = _byteOffset;
- _ProgramIndex result = new _ProgramIndex();
+ _ComponentIndex result = new _ComponentIndex();
// There are two fields: file size and library count.
- _byteOffset = _programStartOffset + programFileSize - (2) * 4;
+ _byteOffset = _componentStartOffset + componentFileSize - (2) * 4;
result.libraryCount = readUint32();
// Library offsets are used for start and end offsets, so there is one extra
// element that this the end offset of the last library
result.libraryOffsets = new List<int>(result.libraryCount + 1);
- result.programFileSizeInBytes = readUint32();
- if (result.programFileSizeInBytes != programFileSize) {
- throw 'Malformed binary: This program files program index indicates that'
- ' the filesize should be $programFileSize but other program indexes'
+ result.componentFileSizeInBytes = readUint32();
+ if (result.componentFileSizeInBytes != componentFileSize) {
+ throw 'Malformed binary: This component file\'s component index indicates that'
+ ' the filesize should be $componentFileSize but other component indexes'
' has indicated that the size should be '
- '${result.programFileSizeInBytes}.';
+ '${result.componentFileSizeInBytes}.';
}
// Skip to the start of the index.
@@ -424,14 +424,14 @@
// source table offset. That's 6 fields + number of libraries.
_byteOffset -= (result.libraryCount + 8) * 4;
- // Now read the program index.
- result.binaryOffsetForSourceTable = _programStartOffset + readUint32();
- result.binaryOffsetForCanonicalNames = _programStartOffset + readUint32();
- result.binaryOffsetForStringTable = _programStartOffset + readUint32();
- result.binaryOffsetForConstantTable = _programStartOffset + readUint32();
+ // Now read the component index.
+ result.binaryOffsetForSourceTable = _componentStartOffset + readUint32();
+ result.binaryOffsetForCanonicalNames = _componentStartOffset + readUint32();
+ result.binaryOffsetForStringTable = _componentStartOffset + readUint32();
+ result.binaryOffsetForConstantTable = _componentStartOffset + readUint32();
result.mainMethodReference = readUint32();
for (int i = 0; i < result.libraryCount + 1; ++i) {
- result.libraryOffsets[i] = _programStartOffset + readUint32();
+ result.libraryOffsets[i] = _componentStartOffset + readUint32();
}
_byteOffset = savedByteIndex;
@@ -439,11 +439,11 @@
return result;
}
- void _readOneProgram(Program program, int programFileSize) {
- _programStartOffset = _byteOffset;
+ void _readOneComponent(Component component, int componentFileSize) {
+ _componentStartOffset = _byteOffset;
final int magic = readUint32();
- if (magic != Tag.ProgramFile) {
+ if (magic != Tag.ComponentFile) {
throw fail('This is not a binary dart file. '
'Magic number was: ${magic.toRadixString(16)}');
}
@@ -454,21 +454,22 @@
'(found ${formatVersion}, expected ${Tag.BinaryFormatVersion})');
}
- // Read program index from the end of this ProgramFiles serialized data.
- _ProgramIndex index = _readProgramIndex(programFileSize);
+ // Read component index from the end of this ComponentFiles serialized data.
+ _ComponentIndex index = _readComponentIndex(componentFileSize);
_byteOffset = index.binaryOffsetForStringTable;
readStringTable(_stringTable);
_byteOffset = index.binaryOffsetForCanonicalNames;
- readLinkTable(program.root);
+ readLinkTable(component.root);
_byteOffset = index.binaryOffsetForStringTable;
- _disableLazyReading = _readMetadataSection(program) || _disableLazyReading;
+ _disableLazyReading =
+ _readMetadataSection(component) || _disableLazyReading;
_byteOffset = index.binaryOffsetForSourceTable;
Map<Uri, Source> uriToSource = readUriToSource();
- program.uriToSource.addAll(uriToSource);
+ component.uriToSource.addAll(uriToSource);
_byteOffset = index.binaryOffsetForConstantTable;
readConstantTable();
@@ -476,16 +477,16 @@
int numberOfLibraries = index.libraryCount;
for (int i = 0; i < numberOfLibraries; ++i) {
_byteOffset = index.libraryOffsets[i];
- readLibrary(program, index.libraryOffsets[i + 1]);
+ readLibrary(component, index.libraryOffsets[i + 1]);
}
var mainMethod =
getMemberReferenceFromInt(index.mainMethodReference, allowNull: true);
- program.mainMethodName ??= mainMethod;
+ component.mainMethodName ??= mainMethod;
- _processPendingMetadataAssociations(program);
+ _processPendingMetadataAssociations(component);
- _byteOffset = _programStartOffset + programFileSize;
+ _byteOffset = _componentStartOffset + componentFileSize;
}
Map<Uri, Source> readUriToSource() {
@@ -574,7 +575,7 @@
}
}
- Library readLibrary(Program program, int endOffset) {
+ Library readLibrary(Component component, int endOffset) {
// Read index.
int savedByteOffset = _byteOffset;
@@ -588,7 +589,7 @@
_byteOffset = endOffset - (procedureCount + 3) * 4;
int classCount = readUint32();
for (int i = 0; i < procedureCount + 1; i++) {
- procedureOffsets[i] = _programStartOffset + readUint32();
+ procedureOffsets[i] = _componentStartOffset + readUint32();
}
List<int> classOffsets = new List<int>(classCount + 1);
@@ -597,7 +598,7 @@
// (i.e. procedure count + class count + 4 fields).
_byteOffset = endOffset - (procedureCount + classCount + 4) * 4;
for (int i = 0; i < classCount + 1; i++) {
- classOffsets[i] = _programStartOffset + readUint32();
+ classOffsets[i] = _componentStartOffset + readUint32();
}
_byteOffset = savedByteOffset;
@@ -611,7 +612,7 @@
if (library == null) {
library =
new Library(Uri.parse(canonicalName.name), reference: reference);
- program.libraries.add(library..parent = program);
+ component.libraries.add(library..parent = component);
}
_currentLibrary = library;
String name = readStringOrNullIfEmpty();
@@ -757,7 +758,7 @@
// offsets (i.e. procedure count + 2 fields).
_byteOffset = endOffset - (procedureCount + 2) * 4;
for (int i = 0; i < procedureCount + 1; i++) {
- procedureOffsets[i] = _programStartOffset + readUint32();
+ procedureOffsets[i] = _componentStartOffset + readUint32();
}
_byteOffset = savedByteOffset;
@@ -1107,7 +1108,7 @@
void _setLazyLoadFunction(FunctionNode result, int oldLabelStackBase,
int variableStackHeight, int typeParameterStackHeight) {
final int savedByteOffset = _byteOffset;
- final int programStartOffset = _programStartOffset;
+ final int componentStartOffset = _componentStartOffset;
final List<TypeParameter> typeParameters = typeParameterStack.toList();
final List<VariableDeclaration> variables = variableStack.toList();
final Library currentLibrary = _currentLibrary;
@@ -1118,7 +1119,7 @@
typeParameterStack.addAll(typeParameters);
variableStack.clear();
variableStack.addAll(variables);
- _programStartOffset = programStartOffset;
+ _componentStartOffset = componentStartOffset;
result.body = readStatementOption();
result.body?.parent = result;
@@ -1830,7 +1831,7 @@
: super(bytes, filename: filename);
@override
- bool _readMetadataSection(Program program) {
+ bool _readMetadataSection(Component component) {
bool containsNodeReferences = false;
// At the beginning of this function _byteOffset points right past
@@ -1856,7 +1857,7 @@
// UInt32 tag (fixed size StringReference)
final tag = _stringTable[readUint32()];
- final repository = program.metadata[tag];
+ final repository = component.metadata[tag];
if (repository != null) {
// Read nodeReferences (if any).
Map<int, int> offsetToReferenceId;
@@ -1894,12 +1895,12 @@
}
@override
- void _processPendingMetadataAssociations(Program program) {
+ void _processPendingMetadataAssociations(Component component) {
if (_subsections == null) {
return;
}
- _associateMetadata(program, _programStartOffset);
+ _associateMetadata(component, _componentStartOffset);
for (var subsection in _subsections) {
if (subsection.pending == null) {
@@ -1969,9 +1970,9 @@
}
@override
- Library readLibrary(Program program, int endOffset) {
+ Library readLibrary(Component component, int endOffset) {
final nodeOffset = _byteOffset;
- final result = super.readLibrary(program, endOffset);
+ final result = super.readLibrary(component, endOffset);
return _associateMetadata(result, nodeOffset);
}
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 96d4905..c829ca2 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -247,12 +247,12 @@
}
}
- void writeLinkTable(Program program) {
+ void writeLinkTable(Component component) {
_binaryOffsetForLinkTable = getBufferOffset();
writeList(_canonicalNameList, writeCanonicalNameEntry);
}
- void indexLinkTable(Program program) {
+ void indexLinkTable(Component component) {
_canonicalNameList = <CanonicalName>[];
void visitCanonicalName(CanonicalName node) {
node.index = _canonicalNameList.length;
@@ -260,20 +260,20 @@
node.children.forEach(visitCanonicalName);
}
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
if (!shouldWriteLibraryCanonicalNames(library)) continue;
visitCanonicalName(library.canonicalName);
_knownCanonicalNameNonRootTops.add(library.canonicalName);
}
}
- /// Compute canonical names for the whole program or parts of it.
- void computeCanonicalNames(Program program) {
- program.computeCanonicalNames();
+ /// Compute canonical names for the whole component or parts of it.
+ void computeCanonicalNames(Component component) {
+ component.computeCanonicalNames();
}
/// Return `true` if all canonical names of the [library] should be written
- /// into the link table. If some libraries of the program are skipped,
+ /// into the link table. If some libraries of the component are skipped,
/// then all the additional names referenced by the libraries that are written
/// by [writeLibraries] are automatically added.
bool shouldWriteLibraryCanonicalNames(Library library) => true;
@@ -288,31 +288,31 @@
writeStringReference(node.name);
}
- void writeProgramFile(Program program) {
- computeCanonicalNames(program);
- final programOffset = getBufferOffset();
- writeUInt32(Tag.ProgramFile);
+ void writeComponentFile(Component component) {
+ computeCanonicalNames(component);
+ final componentOffset = getBufferOffset();
+ writeUInt32(Tag.ComponentFile);
writeUInt32(Tag.BinaryFormatVersion);
- indexLinkTable(program);
- indexUris(program);
- // Note: must write metadata payloads before any other node in the program
+ indexLinkTable(component);
+ indexUris(component);
+ // Note: must write metadata payloads before any other node in the component
// to collect references to nodes contained within metadata payloads.
- _writeMetadataPayloads(program);
+ _writeMetadataPayloads(component);
if (_metadataSubsections != null) {
- _recordNodeOffsetForMetadataMappingImpl(program, programOffset);
+ _recordNodeOffsetForMetadataMappingImpl(component, componentOffset);
}
libraryOffsets = <int>[];
- CanonicalName main = getCanonicalNameOfMember(program.mainMethod);
+ CanonicalName main = getCanonicalNameOfMember(component.mainMethod);
if (main != null) {
checkCanonicalName(main);
}
- writeLibraries(program);
- writeUriToSource(program.uriToSource);
- writeLinkTable(program);
- _writeMetadataMappingSection(program);
+ writeLibraries(component);
+ writeUriToSource(component.uriToSource);
+ writeLinkTable(component);
+ _writeMetadataMappingSection(component);
writeStringTable(stringIndexer);
writeConstantTable(_constantIndexer);
- writeProgramIndex(program, program.libraries);
+ writeComponentIndex(component, component.libraries);
_flush();
}
@@ -333,16 +333,16 @@
}
/// Collect and write out all metadata contained in metadata repositories
- /// associated with the program.
+ /// associated with the component.
///
/// Non-empty metadata subsections will be collected in [_metadataSubsections]
- /// and used to generate metadata mappings after all nodes in the program
+ /// and used to generate metadata mappings after all nodes in the component
/// are written and all node offsets are known.
///
- /// Note: must write metadata payloads before any other node in the program
+ /// Note: must write metadata payloads before any other node in the component
/// to collect references to nodes contained within metadata payloads.
- void _writeMetadataPayloads(Program program) {
- program.metadata.forEach((tag, repository) {
+ void _writeMetadataPayloads(Component component) {
+ component.metadata.forEach((tag, repository) {
if (repository.mapping.isEmpty) {
return;
}
@@ -389,13 +389,13 @@
}
}
- void _writeMetadataMappingSection(Program program) {
+ void _writeMetadataMappingSection(Component component) {
if (_metadataSubsections == null) {
writeUInt32(0); // Empty section.
return;
}
- _recordNodeOffsetForMetadataMappingImpl(program, 0);
+ _recordNodeOffsetForMetadataMappingImpl(component, 0);
// RList<MetadataMapping> metadataMappings
for (var subsection in _metadataSubsections) {
@@ -423,12 +423,12 @@
writeUInt32(_metadataSubsections.length);
}
- /// Write all of some of the libraries of the [program].
- void writeLibraries(Program program) {
- program.libraries.forEach(writeNode);
+ /// Write all of some of the libraries of the [component].
+ void writeLibraries(Component component) {
+ component.libraries.forEach(writeNode);
}
- void writeProgramIndex(Program program, List<Library> libraries) {
+ void writeComponentIndex(Component component, List<Library> libraries) {
// Fixed-size ints at the end used as an index.
assert(_binaryOffsetForSourceTable >= 0);
writeUInt32(_binaryOffsetForSourceTable);
@@ -439,7 +439,7 @@
assert(_binaryOffsetForConstantTable >= 0);
writeUInt32(_binaryOffsetForConstantTable);
- CanonicalName main = getCanonicalNameOfMember(program.mainMethod);
+ CanonicalName main = getCanonicalNameOfMember(component.mainMethod);
if (main == null) {
writeUInt32(0);
} else {
@@ -456,8 +456,8 @@
writeUInt32(getBufferOffset() + 4); // total size.
}
- void indexUris(Program program) {
- _knownSourceUri.addAll(program.uriToSource.keys);
+ void indexUris(Component component) {
+ _knownSourceUri.addAll(component.uriToSource.keys);
}
void writeUriToSource(Map<Uri, Source> uriToSource) {
@@ -1824,7 +1824,7 @@
}
}
- visitProgram(Program node) {
+ visitComponent(Component node) {
buildIndexForList(node.libraries);
}
diff --git a/pkg/kernel/lib/binary/limited_ast_to_binary.dart b/pkg/kernel/lib/binary/limited_ast_to_binary.dart
index 110da9a..82fe07d 100644
--- a/pkg/kernel/lib/binary/limited_ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/limited_ast_to_binary.dart
@@ -8,7 +8,7 @@
/// Writes libraries that satisfy the [predicate].
///
/// Only the referenced subset of canonical names is indexed and written,
-/// so we don't waste time indexing all libraries of a program, when only
+/// so we don't waste time indexing all libraries of a component, when only
/// a tiny subset is used.
class LimitedBinaryPrinter extends BinaryPrinter {
final LibraryFilter predicate;
@@ -27,10 +27,10 @@
: super(sink);
@override
- void computeCanonicalNames(Program program) {
- for (var library in program.libraries) {
+ void computeCanonicalNames(Component component) {
+ for (var library in component.libraries) {
if (predicate(library)) {
- program.root
+ component.root
.getChildFromUri(library.importUri)
.bindTo(library.reference);
library.computeCanonicalNames();
@@ -44,8 +44,8 @@
}
@override
- void writeLibraries(Program program) {
- var librariesToWrite = program.libraries.where(predicate).toList();
+ void writeLibraries(Component component) {
+ var librariesToWrite = component.libraries.where(predicate).toList();
writeList(librariesToWrite, writeNode);
}
@@ -56,15 +56,15 @@
}
@override
- void writeProgramIndex(Program program, List<Library> libraries) {
+ void writeComponentIndex(Component component, List<Library> libraries) {
var librariesToWrite = libraries.where(predicate).toList();
- super.writeProgramIndex(program, librariesToWrite);
+ super.writeComponentIndex(component, librariesToWrite);
}
@override
- void indexUris(Program program) {
+ void indexUris(Component component) {
if (!excludeUriToSource) {
- super.indexUris(program);
+ super.indexUris(component);
} else {
// We pretend not to know any uris, thereby excluding all sources.
}
diff --git a/pkg/kernel/lib/binary/tag.dart b/pkg/kernel/lib/binary/tag.dart
index eb60abe..b58cda9 100644
--- a/pkg/kernel/lib/binary/tag.dart
+++ b/pkg/kernel/lib/binary/tag.dart
@@ -130,7 +130,7 @@
static const int SpecializedIntLiteralBias = 3;
- static const int ProgramFile = 0x90ABCDEF;
+ static const int ComponentFile = 0x90ABCDEF;
/// Internal version of kernel binary format.
/// Bump it when making incompatible changes in kernel binaries.
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index 05ba206..20eadbe 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -20,11 +20,11 @@
/// TODO(scheglov) Several methods are not used, or used only in tests.
/// Check if these methods are not useful and should be removed .
abstract class ClassHierarchy {
- factory ClassHierarchy(Program program,
+ factory ClassHierarchy(Component component,
{HandleAmbiguousSupertypes onAmbiguousSupertypes,
MixinInferrer mixinInferrer}) {
int numberOfClasses = 0;
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
numberOfClasses += library.classes.length;
}
onAmbiguousSupertypes ??= (Class cls, Supertype a, Supertype b) {
@@ -34,7 +34,7 @@
}
};
return new ClosedWorldClassHierarchy._internal(
- program, numberOfClasses, onAmbiguousSupertypes)
+ component, numberOfClasses, onAmbiguousSupertypes)
.._initialize(mixinInferrer);
}
@@ -46,7 +46,7 @@
/// Returns the unique index of the [class_].
int getClassIndex(Class class_);
- /// True if the program contains another class that is a subtype of given one.
+ /// True if the component contains another class that is a subtype of given one.
bool hasProperSubtypes(Class class_);
/// Returns the number of steps in the longest inheritance path from [class_]
@@ -332,10 +332,10 @@
class ClosedWorldClassHierarchy implements ClassHierarchy {
final HandleAmbiguousSupertypes _onAmbiguousSupertypes;
- /// The [Program] that this class hierarchy represents.
- final Program _program;
+ /// The [Component] that this class hierarchy represents.
+ final Component _component;
- /// All classes in the program.
+ /// All classes in the component.
///
/// The list is ordered so that classes occur after their super classes.
final List<Class> classes;
@@ -346,7 +346,7 @@
final List<Class> _classesByTopDownIndex;
ClosedWorldClassHierarchy._internal(
- this._program, int numberOfClasses, this._onAmbiguousSupertypes)
+ this._component, int numberOfClasses, this._onAmbiguousSupertypes)
: classes = new List<Class>(numberOfClasses),
_classesByTopDownIndex = new List<Class>(numberOfClasses);
@@ -680,7 +680,7 @@
@override
ClassHierarchy applyChanges(Iterable<Class> classes) {
if (classes.isEmpty) return this;
- return new ClassHierarchy(_program,
+ return new ClassHierarchy(_component,
onAmbiguousSupertypes: _onAmbiguousSupertypes);
}
@@ -700,7 +700,7 @@
void _initialize(MixinInferrer mixinInferrer) {
// Build the class ordering based on a topological sort.
- for (var library in _program.libraries) {
+ for (var library in _component.libraries) {
for (var classNode in library.classes) {
_topologicalSortVisit(classNode);
}
diff --git a/pkg/kernel/lib/clone.dart b/pkg/kernel/lib/clone.dart
index d6c7964..3eb51ac 100644
--- a/pkg/kernel/lib/clone.dart
+++ b/pkg/kernel/lib/clone.dart
@@ -572,7 +572,7 @@
return new LocalInitializer(clone(node.variable));
}
- visitProgram(Program node) {
+ visitComponent(Component node) {
return defaultTreeNode(node);
}
diff --git a/pkg/kernel/lib/core_types.dart b/pkg/kernel/lib/core_types.dart
index fe1cd4b..05f7f6f 100644
--- a/pkg/kernel/lib/core_types.dart
+++ b/pkg/kernel/lib/core_types.dart
@@ -94,10 +94,11 @@
Procedure _asyncErrorWrapperHelperProcedure;
Procedure _awaitHelperProcedure;
- /// The `dart:mirrors` library, or `null` if the program does not use it.
+ /// The `dart:mirrors` library, or `null` if the component does not use it.
Library _mirrorsLibrary;
- CoreTypes(Program program) : _index = new LibraryIndex.coreLibraries(program);
+ CoreTypes(Component component)
+ : _index = new LibraryIndex.coreLibraries(component);
Procedure get asyncErrorWrapperHelperProcedure {
return _asyncErrorWrapperHelperProcedure ??=
diff --git a/pkg/kernel/lib/error_formatter.dart b/pkg/kernel/lib/error_formatter.dart
index cdddaba..56f4a9f 100644
--- a/pkg/kernel/lib/error_formatter.dart
+++ b/pkg/kernel/lib/error_formatter.dart
@@ -41,9 +41,9 @@
if (fileOffset != TreeNode.noOffset) {
final fileUri = _fileUriOf(context);
- final program = context.enclosingProgram;
- final source = program.uriToSource[fileUri];
- final location = program.getLocation(fileUri, fileOffset);
+ final component = context.enclosingComponent;
+ final source = component.uriToSource[fileUri];
+ final location = component.getLocation(fileUri, fileOffset);
final lineStart = source.lineStarts[location.line - 1];
final lineEnd = (location.line < source.lineStarts.length)
? source.lineStarts[location.line]
diff --git a/pkg/kernel/lib/import_table.dart b/pkg/kernel/lib/import_table.dart
index baadca4..ae2829c 100644
--- a/pkg/kernel/lib/import_table.dart
+++ b/pkg/kernel/lib/import_table.dart
@@ -10,12 +10,12 @@
int getImportIndex(Library library);
}
-class ProgramImportTable implements ImportTable {
+class ComponentImportTable implements ImportTable {
final Map<Library, int> _libraryIndex = <Library, int>{};
- ProgramImportTable(Program program) {
- for (int i = 0; i < program.libraries.length; ++i) {
- _libraryIndex[program.libraries[i]] = i;
+ ComponentImportTable(Component component) {
+ for (int i = 0; i < component.libraries.length; ++i) {
+ _libraryIndex[component.libraries[i]] = i;
}
}
diff --git a/pkg/kernel/lib/interpreter/interpreter.dart b/pkg/kernel/lib/interpreter/interpreter.dart
index ef47e93..598d400 100644
--- a/pkg/kernel/lib/interpreter/interpreter.dart
+++ b/pkg/kernel/lib/interpreter/interpreter.dart
@@ -22,14 +22,14 @@
static MainEnvironment mainEnvironment =
new MainEnvironment(<Member, Location>{});
- final Program program;
+ final Component component;
final StatementExecuter visitor = new StatementExecuter();
- Interpreter(this.program);
+ Interpreter(this.component);
void run() {
- assert(program.libraries.isEmpty);
- Procedure mainMethod = program.mainMethod;
+ assert(component.libraries.isEmpty);
+ Procedure mainMethod = component.mainMethod;
if (mainMethod == null) return;
diff --git a/pkg/kernel/lib/kernel.dart b/pkg/kernel/lib/kernel.dart
index e3c04e1..5ffbd41 100644
--- a/pkg/kernel/lib/kernel.dart
+++ b/pkg/kernel/lib/kernel.dart
@@ -22,18 +22,18 @@
export 'ast.dart';
-Program loadProgramFromBinary(String path, [Program program]) {
+Component loadComponentFromBinary(String path, [Component component]) {
List<int> bytes = new File(path).readAsBytesSync();
- return loadProgramFromBytes(bytes, program);
+ return loadComponentFromBytes(bytes, component);
}
-Program loadProgramFromBytes(List<int> bytes, [Program program]) {
- program ??= new Program();
- new BinaryBuilder(bytes).readProgram(program);
- return program;
+Component loadComponentFromBytes(List<int> bytes, [Component component]) {
+ component ??= new Component();
+ new BinaryBuilder(bytes).readComponent(component);
+ return component;
}
-Future writeProgramToBinary(Program program, String path) {
+Future writeComponentToBinary(Component component, String path) {
var sink;
if (path == 'null' || path == 'stdout') {
sink = stdout.nonBlocking;
@@ -43,7 +43,7 @@
var future;
try {
- new BinaryPrinter(sink).writeProgramFile(program);
+ new BinaryPrinter(sink).writeComponentFile(component);
} finally {
if (sink == stdout.nonBlocking) {
future = sink.flush();
@@ -65,7 +65,7 @@
}
}
-void writeProgramToText(Program program,
+void writeComponentToText(Component component,
{String path,
bool showExternal: false,
bool showOffsets: false,
@@ -75,7 +75,7 @@
showExternal: showExternal,
showOffsets: showOffsets,
showMetadata: showMetadata)
- .writeProgramFile(program);
+ .writeComponentFile(component);
if (path == null) {
print(buffer);
} else {
diff --git a/pkg/kernel/lib/library_index.dart b/pkg/kernel/lib/library_index.dart
index 0708af3..0f5ab16 100644
--- a/pkg/kernel/lib/library_index.dart
+++ b/pkg/kernel/lib/library_index.dart
@@ -20,9 +20,9 @@
final Map<String, _ClassTable> _libraries = <String, _ClassTable>{};
/// Indexes the libraries with the URIs given in [libraryUris].
- LibraryIndex(Program program, Iterable<String> libraryUris) {
+ LibraryIndex(Component component, Iterable<String> libraryUris) {
var libraryUriSet = libraryUris.toSet();
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
var uri = '${library.importUri}';
if (libraryUriSet.contains(uri)) {
_libraries[uri] = new _ClassTable(library);
@@ -31,24 +31,24 @@
}
/// Indexes the libraries with the URIs given in [libraryUris].
- LibraryIndex.byUri(Program program, Iterable<Uri> libraryUris)
- : this(program, libraryUris.map((uri) => '$uri'));
+ LibraryIndex.byUri(Component component, Iterable<Uri> libraryUris)
+ : this(component, libraryUris.map((uri) => '$uri'));
/// Indexes `dart:` libraries.
- LibraryIndex.coreLibraries(Program program) {
- for (var library in program.libraries) {
+ LibraryIndex.coreLibraries(Component component) {
+ for (var library in component.libraries) {
if (library.importUri.scheme == 'dart') {
_libraries['${library.importUri}'] = new _ClassTable(library);
}
}
}
- /// Indexes the entire program.
+ /// Indexes the entire component.
///
/// Consider using another constructor to only index the libraries that
/// are needed.
- LibraryIndex.all(Program program) {
- for (var library in program.libraries) {
+ LibraryIndex.all(Component component) {
+ for (var library in component.libraries) {
_libraries['${library.importUri}'] = new _ClassTable(library);
}
}
diff --git a/pkg/kernel/lib/naive_type_checker.dart b/pkg/kernel/lib/naive_type_checker.dart
index 4450bc5f..548e434 100644
--- a/pkg/kernel/lib/naive_type_checker.dart
+++ b/pkg/kernel/lib/naive_type_checker.dart
@@ -17,12 +17,12 @@
class StrongModeTypeChecker extends type_checker.TypeChecker {
final FailureListener failures;
- StrongModeTypeChecker(FailureListener failures, Program program,
+ StrongModeTypeChecker(FailureListener failures, Component component,
{bool ignoreSdk: false})
: this._(
failures,
- new CoreTypes(program),
- new ClassHierarchy(program,
+ new CoreTypes(component),
+ new ClassHierarchy(component,
onAmbiguousSupertypes: (Class cls, Supertype s0, Supertype s1) {
failures.reportFailure(
cls, "$cls can't implement both $s1 and $s1");
diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart
index 9eecdb8..22672fd 100644
--- a/pkg/kernel/lib/target/targets.dart
+++ b/pkg/kernel/lib/target/targets.dart
@@ -93,41 +93,41 @@
bool get enableSuperMixins => false;
/// Perform target-specific transformations on the outlines stored in
- /// [Program] when generating summaries.
+ /// [Component] when generating summaries.
///
/// This transformation is used to add metadata on outlines and to filter
/// unnecessary information before generating program summaries. This
/// transformation is not applied when compiling full kernel programs to
/// prevent affecting the internal invariants of the compiler and accidentally
/// slowing down compilation.
- void performOutlineTransformations(Program program) {}
+ void performOutlineTransformations(Component component) {}
- /// Perform target-specific modular transformations on the given program.
+ /// Perform target-specific modular transformations on the given component.
///
- /// These transformations should not be whole-program transformations. They
- /// should expect that the program will contain external libraries.
- void performModularTransformationsOnProgram(
- CoreTypes coreTypes, ClassHierarchy hierarchy, Program program,
+ /// These transformations should not be whole-component transformations. They
+ /// should expect that the component will contain external libraries.
+ void performModularTransformationsOnComponent(
+ CoreTypes coreTypes, ClassHierarchy hierarchy, Component component,
{void logger(String msg)}) {
performModularTransformationsOnLibraries(
- coreTypes, hierarchy, program.libraries,
+ coreTypes, hierarchy, component.libraries,
logger: logger);
}
/// Perform target-specific modular transformations on the given libraries.
///
/// The intent of this method is to perform the transformations only on some
- /// subset of the program libraries and avoid packing them into a temporary
- /// [Program] instance to pass into [performModularTransformationsOnProgram].
+ /// subset of the component libraries and avoid packing them into a temporary
+ /// [Component] instance to pass into [performModularTransformationsOnComponent].
///
/// Note that the following should be equivalent:
///
- /// target.performModularTransformationsOnProgram(coreTypes, program);
+ /// target.performModularTransformationsOnComponent(coreTypes, component);
///
/// and
///
/// target.performModularTransformationsOnLibraries(
- /// coreTypes, program.libraries);
+ /// coreTypes, component.libraries);
void performModularTransformationsOnLibraries(
CoreTypes coreTypes, ClassHierarchy hierarchy, List<Library> libraries,
{void logger(String msg)});
@@ -138,10 +138,10 @@
/// correctness. Everything should work if a simple and fast linker chooses
/// not to apply these transformations.
///
- /// Note that [performGlobalTransformations] doesn't have -OnProgram and
+ /// Note that [performGlobalTransformations] doesn't have -OnComponent and
/// -OnLibraries alternatives, because the global knowledge required by the
- /// transformations is assumed to be retrieved from a [Program] instance.
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ /// transformations is assumed to be retrieved from a [Component] instance.
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)});
/// Whether a platform library may define a restricted type, such as `bool`,
@@ -223,7 +223,7 @@
void performModularTransformationsOnLibraries(
CoreTypes coreTypes, ClassHierarchy hierarchy, List<Library> libraries,
{void logger(String msg)}) {}
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {}
@override
diff --git a/pkg/kernel/lib/target/vm.dart b/pkg/kernel/lib/target/vm.dart
index 6090179..5fd891e 100644
--- a/pkg/kernel/lib/target/vm.dart
+++ b/pkg/kernel/lib/target/vm.dart
@@ -68,7 +68,7 @@
}
@override
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {}
@override
diff --git a/pkg/kernel/lib/target/vmcc.dart b/pkg/kernel/lib/target/vmcc.dart
index 3496882..a5f6a14 100644
--- a/pkg/kernel/lib/target/vmcc.dart
+++ b/pkg/kernel/lib/target/vmcc.dart
@@ -3,14 +3,15 @@
// BSD-style license that can be found in the LICENSE file.
library kernel.target.vmcc;
-import '../ast.dart' show Program, Library;
+import '../ast.dart' show Component, Library;
import '../core_types.dart' show CoreTypes;
import '../class_hierarchy.dart';
import '../transformations/continuation.dart' as cont;
import '../transformations/mixin_full_resolution.dart' as mix;
import '../transformations/sanitize_for_vm.dart';
import '../transformations/treeshaker.dart';
-import '../transformations/closure_conversion.dart' as cc show transformProgram;
+import '../transformations/closure_conversion.dart' as cc
+ show transformComponent;
import 'targets.dart' show TargetFlags;
import 'vm.dart' as vm_target;
@@ -38,23 +39,23 @@
}
@override
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {
if (flags.treeShake) {
- performTreeShaking(coreTypes, program);
+ performTreeShaking(coreTypes, component);
}
- cont.transformProgram(coreTypes, program, flags.syncAsync);
+ cont.transformComponent(coreTypes, component, flags.syncAsync);
- new SanitizeForVM().transform(program);
+ new SanitizeForVM().transform(component);
- cc.transformProgram(coreTypes, program);
+ cc.transformComponent(coreTypes, component);
}
- void performTreeShaking(CoreTypes coreTypes, Program program) {
- new TreeShaker(coreTypes, _hierarchy, program,
+ void performTreeShaking(CoreTypes coreTypes, Component component) {
+ new TreeShaker(coreTypes, _hierarchy, component,
strongMode: strongMode, programRoots: flags.programRoots)
- .transform(program);
+ .transform(component);
_hierarchy = null; // Hierarchy must be recomputed.
}
}
diff --git a/pkg/kernel/lib/target/vmreify.dart b/pkg/kernel/lib/target/vmreify.dart
index 65c1e66..681c760 100644
--- a/pkg/kernel/lib/target/vmreify.dart
+++ b/pkg/kernel/lib/target/vmreify.dart
@@ -3,10 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
library kernel.target.vmreify;
-import '../ast.dart' show Program;
+import '../ast.dart' show Component;
import '../core_types.dart' show CoreTypes;
import '../transformations/generic_types_reification.dart' as reify
- show transformProgram;
+ show transformComponent;
import 'targets.dart' show TargetFlags;
import 'vmcc.dart' as vmcc_target;
@@ -27,18 +27,18 @@
}
@override
- void performGlobalTransformations(CoreTypes coreTypes, Program program,
+ void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {
- super.performGlobalTransformations(coreTypes, program);
+ super.performGlobalTransformations(coreTypes, component);
// TODO(dmitryas) this transformation should be made modular
- reify.transformProgram(coreTypes, program);
+ reify.transformComponent(coreTypes, component);
}
// Disable tree shaking for Generic Types Reification. There are some runtime
// libraries that are required for the transformation and are shaken off,
- // because they aren't invoked from the program being transformed prior to
+ // because they aren't invoked from the component being transformed prior to
// the transformation.
// TODO(dmitryas): remove this when the libraries are in dart:_internal
@override
- void performTreeShaking(CoreTypes coreTypes, Program program) {}
+ void performTreeShaking(CoreTypes coreTypes, Component component) {}
}
diff --git a/pkg/kernel/lib/testing/mock_sdk_program.dart b/pkg/kernel/lib/testing/mock_sdk_component.dart
similarity index 92%
rename from pkg/kernel/lib/testing/mock_sdk_program.dart
rename to pkg/kernel/lib/testing/mock_sdk_component.dart
index 832114b..c85bdcf 100644
--- a/pkg/kernel/lib/testing/mock_sdk_program.dart
+++ b/pkg/kernel/lib/testing/mock_sdk_component.dart
@@ -4,8 +4,8 @@
import 'package:kernel/ast.dart';
-/// Returns a [Program] object containing empty definitions of core SDK classes.
-Program createMockSdkProgram() {
+/// Returns a [Component] object containing empty definitions of core SDK classes.
+Component createMockSdkComponent() {
var coreLib = new Library(Uri.parse('dart:core'), name: 'dart.core');
var asyncLib = new Library(Uri.parse('dart:async'), name: 'dart.async');
var internalLib =
@@ -64,5 +64,5 @@
addClass(asyncLib, class_('Stream', typeParameters: [typeParam('T')]));
addClass(internalLib, class_('Symbol'));
- return new Program(libraries: [coreLib, asyncLib, internalLib]);
+ return new Component(libraries: [coreLib, asyncLib, internalLib]);
}
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index 8113bbe..fcf52cf 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -131,9 +131,10 @@
return '$buffer';
}
-String programToString(Program node) {
+String componentToString(Component node) {
StringBuffer buffer = new StringBuffer();
- new Printer(buffer, syntheticNames: new NameSystem()).writeProgramFile(node);
+ new Printer(buffer, syntheticNames: new NameSystem())
+ .writeComponentFile(node);
return '$buffer';
}
@@ -395,21 +396,21 @@
endLine();
var inner =
- new Printer._inner(this, imports, library.enclosingProgram?.metadata);
+ new Printer._inner(this, imports, library.enclosingComponent?.metadata);
library.typedefs.forEach(inner.writeNode);
library.classes.forEach(inner.writeNode);
library.fields.forEach(inner.writeNode);
library.procedures.forEach(inner.writeNode);
}
- void writeProgramFile(Program program) {
- ImportTable imports = new ProgramImportTable(program);
- var inner = new Printer._inner(this, imports, program.metadata);
+ void writeComponentFile(Component component) {
+ ImportTable imports = new ComponentImportTable(component);
+ var inner = new Printer._inner(this, imports, component.metadata);
writeWord('main');
writeSpaced('=');
- inner.writeMemberReferenceFromReference(program.mainMethodName);
+ inner.writeMemberReferenceFromReference(component.mainMethodName);
endLine(';');
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
if (library.isExternal) {
if (!showExternal) {
continue;
diff --git a/pkg/kernel/lib/transformations/argument_extraction.dart b/pkg/kernel/lib/transformations/argument_extraction.dart
index 699f87e..98af6a5 100644
--- a/pkg/kernel/lib/transformations/argument_extraction.dart
+++ b/pkg/kernel/lib/transformations/argument_extraction.dart
@@ -11,15 +11,15 @@
Initializer,
Library,
LocalInitializer,
- Program,
+ Component,
VariableDeclaration,
VariableGet;
import '../core_types.dart' show CoreTypes;
import '../visitor.dart' show Transformer;
-Program transformProgram(CoreTypes coreTypes, Program program) {
- new ArgumentExtractionForTesting().visitProgram(program);
- return program;
+Component transformComponent(CoreTypes coreTypes, Component component) {
+ new ArgumentExtractionForTesting().visitComponent(component);
+ return component;
}
void transformLibraries(CoreTypes coreTypes, List<Library> libraries) {
diff --git a/pkg/kernel/lib/transformations/closure_conversion.dart b/pkg/kernel/lib/transformations/closure_conversion.dart
index 8080997..d1471aa 100644
--- a/pkg/kernel/lib/transformations/closure_conversion.dart
+++ b/pkg/kernel/lib/transformations/closure_conversion.dart
@@ -4,7 +4,7 @@
library kernel.transformations.closure_conversion;
-import '../ast.dart' show Program, Library;
+import '../ast.dart' show Component, Library;
import '../core_types.dart' show CoreTypes;
@@ -14,13 +14,13 @@
import 'closure/invalidate_closures.dart';
-Program transformProgram(CoreTypes coreTypes, Program program) {
+Component transformComponent(CoreTypes coreTypes, Component component) {
var info = new ClosureInfo();
- info.visitProgram(program);
+ info.visitComponent(component);
var convert = new ClosureConverter(coreTypes, info);
- program = convert.visitProgram(program);
- return new InvalidateClosures().visitProgram(program);
+ component = convert.visitComponent(component);
+ return new InvalidateClosures().visitComponent(component);
}
void transformLibraries(CoreTypes coreTypes, List<Library> libraries) {
diff --git a/pkg/kernel/lib/transformations/constants.dart b/pkg/kernel/lib/transformations/constants.dart
index 9cb7a4d..84ae345 100644
--- a/pkg/kernel/lib/transformations/constants.dart
+++ b/pkg/kernel/lib/transformations/constants.dart
@@ -26,23 +26,23 @@
import '../class_hierarchy.dart';
import 'treeshaker.dart' show findNativeName;
-Program transformProgram(Program program, ConstantsBackend backend,
+Component transformComponent(Component component, ConstantsBackend backend,
{bool keepFields: false,
bool strongMode: false,
bool enableAsserts: false,
CoreTypes coreTypes,
ClassHierarchy hierarchy}) {
- coreTypes ??= new CoreTypes(program);
- hierarchy ??= new ClassHierarchy(program);
+ coreTypes ??= new CoreTypes(component);
+ hierarchy ??= new ClassHierarchy(component);
final typeEnvironment =
new TypeEnvironment(coreTypes, hierarchy, strongMode: strongMode);
- transformLibraries(program.libraries, backend, coreTypes, typeEnvironment,
+ transformLibraries(component.libraries, backend, coreTypes, typeEnvironment,
keepFields: keepFields,
strongMode: strongMode,
enableAsserts: enableAsserts);
- return program;
+ return component;
}
void transformLibraries(List<Library> libraries, ConstantsBackend backend,
diff --git a/pkg/kernel/lib/transformations/continuation.dart b/pkg/kernel/lib/transformations/continuation.dart
index 93e9e51..ae9076f 100644
--- a/pkg/kernel/lib/transformations/continuation.dart
+++ b/pkg/kernel/lib/transformations/continuation.dart
@@ -21,10 +21,11 @@
}
}
-Program transformProgram(CoreTypes coreTypes, Program program, bool syncAsync) {
+Component transformComponent(
+ CoreTypes coreTypes, Component component, bool syncAsync) {
var helper = new HelperNodes.fromCoreTypes(coreTypes);
var rewriter = new RecursiveContinuationRewriter(helper, syncAsync);
- return rewriter.rewriteProgram(program);
+ return rewriter.rewriteComponent(component);
}
Procedure transformProcedure(
@@ -48,7 +49,7 @@
RecursiveContinuationRewriter(this.helper, this.syncAsync);
- Program rewriteProgram(Program node) {
+ Component rewriteComponent(Component node) {
return node.accept(this);
}
diff --git a/pkg/kernel/lib/transformations/coq.dart b/pkg/kernel/lib/transformations/coq.dart
index ae9cb72..f668737 100644
--- a/pkg/kernel/lib/transformations/coq.dart
+++ b/pkg/kernel/lib/transformations/coq.dart
@@ -512,8 +512,8 @@
"Definition ast_store_validity (ast : ast_store) : Prop := \n$clause\n.");
}
-Program transformProgram(CoreTypes coreTypes, Program program) {
- for (Library lib in program.libraries) {
+Component transformComponent(CoreTypes coreTypes, Component component) {
+ for (Library lib in component.libraries) {
// TODO(30610): Ideally we'd output to the file in the coq annotation on the
// library name, but currently fasta throws away annotations on libraries.
// Instead, we just special case "kernel.ast" and output to stdout.
@@ -524,5 +524,5 @@
outputCoqImports();
outputCoqSyntax(info);
}
- return program;
+ return component;
}
diff --git a/pkg/kernel/lib/transformations/empty.dart b/pkg/kernel/lib/transformations/empty.dart
index 263858f..5a264dd7 100644
--- a/pkg/kernel/lib/transformations/empty.dart
+++ b/pkg/kernel/lib/transformations/empty.dart
@@ -8,9 +8,9 @@
import '../kernel.dart';
import '../visitor.dart';
-Program transformProgram(Program program) {
- new EmptyTransformer().visitProgram(program);
- return program;
+Component transformComponent(Component component) {
+ new EmptyTransformer().visitComponent(component);
+ return component;
}
class EmptyTransformer extends Transformer {}
diff --git a/pkg/kernel/lib/transformations/generic_types_reification.dart b/pkg/kernel/lib/transformations/generic_types_reification.dart
index 8bdf691..d79ab68 100644
--- a/pkg/kernel/lib/transformations/generic_types_reification.dart
+++ b/pkg/kernel/lib/transformations/generic_types_reification.dart
@@ -4,11 +4,11 @@
library kernel.transformation.generic_types_reification;
-import '../ast.dart' show Program;
+import '../ast.dart' show Component;
import '../core_types.dart' show CoreTypes;
import '../transformations/reify/reify_transformer.dart' as reify
- show transformProgram;
+ show transformComponent;
-Program transformProgram(CoreTypes coreTypes, Program program) {
- return reify.transformProgram(coreTypes, program);
+Component transformComponent(CoreTypes coreTypes, Component component) {
+ return reify.transformComponent(coreTypes, component);
}
diff --git a/pkg/kernel/lib/transformations/method_call.dart b/pkg/kernel/lib/transformations/method_call.dart
index 9590539..b269aff 100644
--- a/pkg/kernel/lib/transformations/method_call.dart
+++ b/pkg/kernel/lib/transformations/method_call.dart
@@ -53,11 +53,12 @@
/// var b = new B();
/// b.foo(499, named1: 88);
/// }
-Program transformProgram(
- CoreTypes coreTypes, ClassHierarchy hierarchy, Program program,
+Component transformComponent(
+ CoreTypes coreTypes, ClassHierarchy hierarchy, Component component,
[debug = false]) {
- new MethodCallTransformer(coreTypes, hierarchy, debug).visitProgram(program);
- return program;
+ new MethodCallTransformer(coreTypes, hierarchy, debug)
+ .visitComponent(component);
+ return component;
}
class MethodCallTransformer extends Transformer {
@@ -115,7 +116,7 @@
MethodCallTransformer(this.coreTypes, this.hierarchy, this._debug);
@override
- TreeNode visitProgram(Program node) {
+ TreeNode visitComponent(Component node) {
// First move body of all procedures that takes optional positional or named
// parameters and record which non-static procedure names have optional
// positional arguments.
@@ -1256,9 +1257,9 @@
// Below methods used to add debug prints etc
- Library _getDartCoreLibrary(Program program) {
- if (program == null) return null;
- return program.libraries.firstWhere((lib) =>
+ Library _getDartCoreLibrary(Component component) {
+ if (component == null) return null;
+ return component.libraries.firstWhere((lib) =>
lib.importUri.scheme == 'dart' && lib.importUri.path == 'core');
}
@@ -1277,8 +1278,8 @@
}
Expression _getPrintExpression(String msg, TreeNode treeNode) {
- TreeNode program = treeNode;
- while (program is! Program) program = program.parent;
+ TreeNode component = treeNode;
+ while (component is! Component) component = component.parent;
var finalMsg = msg;
if (treeNode is Member) {
finalMsg += " [ ${treeNode.name.name} ]";
@@ -1291,9 +1292,9 @@
}
var stacktrace = new StaticGet(_getProcedureInClassInLib(
- _getDartCoreLibrary(program), 'StackTrace', 'current'));
+ _getDartCoreLibrary(component), 'StackTrace', 'current'));
var printStackTrace = new StaticInvocation(
- _getProcedureInLib(_getDartCoreLibrary(program), 'print'),
+ _getProcedureInLib(_getDartCoreLibrary(component), 'print'),
new Arguments([
new StringConcatenation([
new StringLiteral(finalMsg),
diff --git a/pkg/kernel/lib/transformations/reify/analysis/program_analysis.dart b/pkg/kernel/lib/transformations/reify/analysis/program_analysis.dart
index 12bf4ae..df259b6 100644
--- a/pkg/kernel/lib/transformations/reify/analysis/program_analysis.dart
+++ b/pkg/kernel/lib/transformations/reify/analysis/program_analysis.dart
@@ -98,9 +98,9 @@
bool _analyzeAll(Library library) => true;
-ProgramKnowledge analyze(Program program,
+ProgramKnowledge analyze(Component component,
{LibraryFilter analyzeLibrary: _analyzeAll}) {
ProgramKnowledge knowledge = new ProgramKnowledge();
- program.accept(new ProgramAnalysis(knowledge, analyzeLibrary));
+ component.accept(new ProgramAnalysis(knowledge, analyzeLibrary));
return knowledge;
}
diff --git a/pkg/kernel/lib/transformations/reify/reify_transformer.dart b/pkg/kernel/lib/transformations/reify/reify_transformer.dart
index 176709a..5a0f2a5 100644
--- a/pkg/kernel/lib/transformations/reify/reify_transformer.dart
+++ b/pkg/kernel/lib/transformations/reify/reify_transformer.dart
@@ -21,7 +21,7 @@
import '../../core_types.dart' show CoreTypes;
-RuntimeLibrary findRuntimeTypeLibrary(Program p) {
+RuntimeLibrary findRuntimeTypeLibrary(Component p) {
Library findLibraryEndingWith(String postfix) {
Iterable<Library> candidates = p.libraries.where((Library l) {
return l.importUri.toString().endsWith(postfix);
@@ -40,37 +40,37 @@
return new RuntimeLibrary(types, declarations, interceptors);
}
-Program transformProgramUsingLibraries(
- CoreTypes coreTypes, Program program, RuntimeLibrary runtimeLibrary,
+Component transformComponentUsingLibraries(
+ CoreTypes coreTypes, Component component, RuntimeLibrary runtimeLibrary,
[Library libraryToTransform]) {
LibraryFilter filter = libraryToTransform != null
? (Library library) => library == libraryToTransform
: (_) => true;
- ProgramKnowledge knowledge = analyze(program, analyzeLibrary: filter);
- Library mainLibrary = program.mainMethod.parent;
+ ProgramKnowledge knowledge = analyze(component, analyzeLibrary: filter);
+ Library mainLibrary = component.mainMethod.parent;
RuntimeTypeSupportBuilder builder =
new RuntimeTypeSupportBuilder(runtimeLibrary, coreTypes, mainLibrary);
ReifyVisitor transformer =
new ReifyVisitor(runtimeLibrary, builder, knowledge, libraryToTransform);
- // Transform the main program.
- program = program.accept(transformer);
+ // Transform the main component.
+ component = component.accept(transformer);
if (!filter(runtimeLibrary.interceptorsLibrary)) {
// We need to transform the interceptor function in any case to make sure
// that the type literals in the interceptor function are rewritten.
runtimeLibrary.interceptorFunction.accept(transformer);
}
builder.createDeclarations();
- program = program.accept(new Erasure(transformer));
+ component = component.accept(new Erasure(transformer));
// TODO(karlklose): skip checks in debug mode
- verifyProgram(program);
- return program;
+ verifyComponent(component);
+ return component;
}
-Program transformProgram(CoreTypes coreTypes, Program program) {
- RuntimeLibrary runtimeLibrary = findRuntimeTypeLibrary(program);
- Library mainLibrary = program.mainMethod.enclosingLibrary;
- return transformProgramUsingLibraries(
- coreTypes, program, runtimeLibrary, mainLibrary);
+Component transformComponent(CoreTypes coreTypes, Component component) {
+ RuntimeLibrary runtimeLibrary = findRuntimeTypeLibrary(component);
+ Library mainLibrary = component.mainMethod.enclosingLibrary;
+ return transformComponentUsingLibraries(
+ coreTypes, component, runtimeLibrary, mainLibrary);
}
main(List<String> arguments) async {
@@ -80,13 +80,13 @@
output = Uri.base.resolve(arguments[1]);
}
Uri uri = Uri.base.resolve(path);
- Program program = loadProgramFromBinary(uri.toFilePath());
- CoreTypes coreTypes = new CoreTypes(program);
+ Component component = loadComponentFromBinary(uri.toFilePath());
+ CoreTypes coreTypes = new CoreTypes(component);
- RuntimeLibrary runtimeLibrary = findRuntimeTypeLibrary(program);
- Library mainLibrary = program.mainMethod.enclosingLibrary;
- program = transformProgramUsingLibraries(
- coreTypes, program, runtimeLibrary, mainLibrary);
+ RuntimeLibrary runtimeLibrary = findRuntimeTypeLibrary(component);
+ Library mainLibrary = component.mainMethod.enclosingLibrary;
+ component = transformComponentUsingLibraries(
+ coreTypes, component, runtimeLibrary, mainLibrary);
if (output == null) {
// Print result
@@ -97,13 +97,13 @@
} else {
IOSink sink = new File.fromUri(output).openWrite();
try {
- new BinaryPrinter(sink).writeProgramFile(program);
+ new BinaryPrinter(sink).writeComponentFile(component);
} finally {
await sink.close();
}
try {
// Check that we can read the binary file.
- loadProgramFromBinary(output.toFilePath());
+ loadComponentFromBinary(output.toFilePath());
} catch (e) {
print("Error when attempting to read $output.");
rethrow;
diff --git a/pkg/kernel/lib/transformations/sanitize_for_vm.dart b/pkg/kernel/lib/transformations/sanitize_for_vm.dart
index 54d7e7d..afe812d 100644
--- a/pkg/kernel/lib/transformations/sanitize_for_vm.dart
+++ b/pkg/kernel/lib/transformations/sanitize_for_vm.dart
@@ -9,8 +9,8 @@
///
/// VM-specific constraints that don't fit in anywhere else can be put here.
class SanitizeForVM {
- void transform(Program program) {
- for (var library in program.libraries) {
+ void transform(Component component) {
+ for (var library in component.libraries) {
for (var class_ in library.classes) {
if (class_.constructors.isEmpty && class_.procedures.isEmpty) {
class_.addMember(new Constructor(
diff --git a/pkg/kernel/lib/transformations/setup_builtin_library.dart b/pkg/kernel/lib/transformations/setup_builtin_library.dart
index 3fe2f14..07adcb4 100644
--- a/pkg/kernel/lib/transformations/setup_builtin_library.dart
+++ b/pkg/kernel/lib/transformations/setup_builtin_library.dart
@@ -9,12 +9,12 @@
// The DartVM has a special `dart:_builtin` library which exposes a
// `_getMainClosure()` method. We need to change this method to return a
// closure of `main()`.
-Program transformProgram(Program program,
+Component transformComponent(Component component,
{String libraryUri: 'dart:_builtin'}) {
- Procedure mainMethod = program.mainMethod;
+ Procedure mainMethod = component.mainMethod;
Library builtinLibrary;
- for (Library library in program.libraries) {
+ for (Library library in component.libraries) {
if (library.importUri.toString() == libraryUri) {
builtinLibrary = library;
break;
@@ -46,5 +46,5 @@
getMainClosure.body = null;
}
- return program;
+ return component;
}
diff --git a/pkg/kernel/lib/transformations/treeshaker.dart b/pkg/kernel/lib/transformations/treeshaker.dart
index 6d482b0..3fd7046 100644
--- a/pkg/kernel/lib/transformations/treeshaker.dart
+++ b/pkg/kernel/lib/transformations/treeshaker.dart
@@ -10,13 +10,13 @@
import '../type_environment.dart';
import '../library_index.dart';
-Program transformProgram(
- CoreTypes coreTypes, ClassHierarchy hierarchy, Program program,
+Component transformComponent(
+ CoreTypes coreTypes, ClassHierarchy hierarchy, Component component,
{List<ProgramRoot> programRoots, bool strongMode: false}) {
- new TreeShaker(coreTypes, hierarchy, program,
+ new TreeShaker(coreTypes, hierarchy, component,
programRoots: programRoots, strongMode: strongMode)
- .transform(program);
- return program;
+ .transform(component);
+ return component;
}
enum ProgramRootKind {
@@ -94,7 +94,7 @@
class TreeShaker {
final CoreTypes coreTypes;
final ClosedWorldClassHierarchy hierarchy;
- final Program program;
+ final Component component;
final bool strongMode;
final List<ProgramRoot> programRoots;
@@ -175,9 +175,10 @@
/// the mirrors library.
bool get forceShaking => programRoots != null && programRoots.isNotEmpty;
- TreeShaker(CoreTypes coreTypes, ClassHierarchy hierarchy, Program program,
+ TreeShaker(CoreTypes coreTypes, ClassHierarchy hierarchy, Component component,
{bool strongMode: false, List<ProgramRoot> programRoots})
- : this._internal(coreTypes, hierarchy, program, strongMode, programRoots);
+ : this._internal(
+ coreTypes, hierarchy, component, strongMode, programRoots);
bool isMemberBodyUsed(Member member) {
return _usedMembers.containsKey(member);
@@ -216,15 +217,15 @@
return _classRetention[index];
}
- /// Applies the tree shaking results to the program.
+ /// Applies the tree shaking results to the component.
///
/// This removes unused classes, members, and hierarchy data.
- void transform(Program program) {
+ void transform(Component component) {
if (isUsingMirrors) return; // Give up if using mirrors.
- new _TreeShakingTransformer(this).transform(program);
+ new _TreeShakingTransformer(this).transform(component);
}
- TreeShaker._internal(this.coreTypes, this.hierarchy, this.program,
+ TreeShaker._internal(this.coreTypes, this.hierarchy, this.component,
this.strongMode, this.programRoots)
: this._dispatchedNames = new List<Set<Name>>(hierarchy.classes.length),
this._usedMembersWithHost =
@@ -246,19 +247,20 @@
}
void _build() {
- if (program.mainMethod == null) {
- throw 'Cannot perform tree shaking on a program without a main method';
+ if (component.mainMethod == null) {
+ throw 'Cannot perform tree shaking on a component without a main method';
}
- if (program.mainMethod.function.positionalParameters.length > 0) {
+ if (component.mainMethod.function.positionalParameters.length > 0) {
// The main method takes a List<String> as argument.
_addInstantiatedExternalSubclass(coreTypes.listClass);
_addInstantiatedExternalSubclass(coreTypes.stringClass);
}
_addDispatchedName(coreTypes.objectClass, new Name('noSuchMethod'));
_addPervasiveUses();
- _addUsedMember(null, program.mainMethod);
+ _addUsedMember(null, component.mainMethod);
if (programRoots != null) {
- var table = new LibraryIndex(program, programRoots.map((r) => r.library));
+ var table =
+ new LibraryIndex(component, programRoots.map((r) => r.library));
for (var root in programRoots) {
_addUsedRoot(root, table);
}
@@ -1030,7 +1032,7 @@
return isUsed ? target : null;
}
- void transform(Program program) {
+ void transform(Component component) {
for (Expression node in shaker._typedCalls) {
// We should not leave dangling references, so if the target of a typed
// call has been removed, we must remove the reference. The receiver of
@@ -1044,7 +1046,7 @@
node.interfaceTarget = _translateInterfaceTarget(node.interfaceTarget);
}
}
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
if (!shaker.forceShaking && library.importUri.scheme == 'dart') {
// The backend expects certain things to be present in the core
// libraries, so we currently don't shake off anything there.
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index ac82984..39412ae 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -25,8 +25,8 @@
new TypeEnvironment(coreTypes, hierarchy, strongMode: strongMode);
}
- void checkProgram(Program program) {
- for (var library in program.libraries) {
+ void checkComponent(Component component) {
+ for (var library in component.libraries) {
if (ignoreSdk && library.importUri.scheme == 'dart') continue;
for (var class_ in library.classes) {
hierarchy.forEachOverridePair(class_,
@@ -36,7 +36,7 @@
}
}
var visitor = new TypeCheckingVisitor(this, environment);
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
if (ignoreSdk && library.importUri.scheme == 'dart') continue;
for (var class_ in library.classes) {
environment.thisType = class_.thisType;
diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart
index fbbfb81..4239b87 100644
--- a/pkg/kernel/lib/verifier.dart
+++ b/pkg/kernel/lib/verifier.dart
@@ -6,8 +6,8 @@
import 'ast.dart';
import 'transformations/flags.dart';
-void verifyProgram(Program program) {
- VerifyingVisitor.check(program);
+void verifyComponent(Component component) {
+ VerifyingVisitor.check(component);
}
class VerificationError {
@@ -40,7 +40,7 @@
enum TypedefState { Done, BeingChecked }
-/// Checks that a kernel program is well-formed.
+/// Checks that a kernel component is well-formed.
///
/// This does not include any kind of type checking.
class VerifyingVisitor extends RecursiveVisitor {
@@ -67,8 +67,8 @@
TreeNode get context => currentMember ?? currentClass;
- static void check(Program program) {
- program.accept(new VerifyingVisitor());
+ static void check(Component component) {
+ component.accept(new VerifyingVisitor());
}
defaultTreeNode(TreeNode node) {
@@ -165,9 +165,9 @@
}
}
- visitProgram(Program program) {
+ visitComponent(Component component) {
try {
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
for (var class_ in library.classes) {
if (!classes.add(class_)) {
problem(class_, "Class '$class_' declared more than once.");
@@ -183,9 +183,9 @@
class_.members.forEach(declareMember);
}
}
- visitChildren(program);
+ visitChildren(component);
} finally {
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
library.members.forEach(undeclareMember);
for (var class_ in library.classes) {
class_.members.forEach(undeclareMember);
diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart
index 0928e0a..fa6337c 100644
--- a/pkg/kernel/lib/visitor.dart
+++ b/pkg/kernel/lib/visitor.dart
@@ -255,7 +255,7 @@
R visitSwitchCase(SwitchCase node) => defaultTreeNode(node);
R visitCatch(Catch node) => defaultTreeNode(node);
R visitMapEntry(MapEntry node) => defaultTreeNode(node);
- R visitProgram(Program node) => defaultTreeNode(node);
+ R visitComponent(Component node) => defaultTreeNode(node);
}
class DartTypeVisitor<R> {
diff --git a/pkg/kernel/test/ast_membench.dart b/pkg/kernel/test/ast_membench.dart
index 47eda46..dc50ccc 100644
--- a/pkg/kernel/test/ast_membench.dart
+++ b/pkg/kernel/test/ast_membench.dart
@@ -5,7 +5,7 @@
import 'package:kernel/kernel.dart';
import 'dart:io';
-/// Builds N copies of the AST for the given program.
+/// Builds N copies of the AST for the given component.
/// Pass --print-metrics to the Dart VM to measure the memory use.
main(List<String> args) {
if (args.length == 0) {
@@ -16,9 +16,9 @@
const int defaultCopyCount = 10;
int copyCount = args.length == 2 ? int.parse(args[1]) : defaultCopyCount;
- List<Program> keepAlive = <Program>[];
+ List<Component> keepAlive = <Component>[];
for (int i = 0; i < copyCount; ++i) {
- keepAlive.add(loadProgramFromBinary(filename));
+ keepAlive.add(loadComponentFromBinary(filename));
}
print('$copyCount copies built');
@@ -26,8 +26,8 @@
if (args.contains('-v')) {
// Use of the list for something to avoid premature GC.
int size = 0;
- for (var program in keepAlive) {
- size += program.libraries.length;
+ for (var component in keepAlive) {
+ size += component.libraries.length;
}
print(size);
}
diff --git a/pkg/kernel/test/binary_bench.dart b/pkg/kernel/test/binary_bench.dart
index 92ac93f..18c7610 100644
--- a/pkg/kernel/test/binary_bench.dart
+++ b/pkg/kernel/test/binary_bench.dart
@@ -160,11 +160,11 @@
return true;
}
-Program _fromBinary(List<int> bytes, {eager: true}) {
- var program = new Program();
+Component _fromBinary(List<int> bytes, {eager: true}) {
+ var component = new Component();
new BinaryBuilder(bytes, filename: 'filename', disableLazyReading: eager)
- .readSingleFileProgram(program);
- return program;
+ .readSingleFileComponent(component);
+ return component;
}
class SimpleSink implements Sink<List<int>> {
@@ -179,6 +179,6 @@
void close() {}
}
-void _toBinary(Program p) {
- new BinaryPrinter(new SimpleSink()).writeProgramFile(p);
+void _toBinary(Component p) {
+ new BinaryPrinter(new SimpleSink()).writeComponentFile(p);
}
diff --git a/pkg/kernel/test/class_hierarchy_basic.dart b/pkg/kernel/test/class_hierarchy_basic.dart
index 8120505..1f69a0e 100644
--- a/pkg/kernel/test/class_hierarchy_basic.dart
+++ b/pkg/kernel/test/class_hierarchy_basic.dart
@@ -25,8 +25,8 @@
final List<Class> classes = <Class>[];
final Map<Class, int> classIndex = <Class, int>{};
- BasicClassHierarchy(Program program) {
- for (var library in program.libraries) {
+ BasicClassHierarchy(Component component) {
+ for (var library in component.libraries) {
for (var classNode in library.classes) {
buildSuperTypeSets(classNode);
buildSuperTypeInstantiations(classNode);
diff --git a/pkg/kernel/test/class_hierarchy_bench.dart b/pkg/kernel/test/class_hierarchy_bench.dart
index 02d6b0c..37877d5 100644
--- a/pkg/kernel/test/class_hierarchy_bench.dart
+++ b/pkg/kernel/test/class_hierarchy_bench.dart
@@ -36,12 +36,12 @@
}
String filename = options.rest.single;
- Program program = loadProgramFromBinary(filename);
+ Component component = loadComponentFromBinary(filename);
ClassHierarchy buildHierarchy() {
return options['basic']
- ? new BasicClassHierarchy(program)
- : new ClassHierarchy(program);
+ ? new BasicClassHierarchy(component)
+ : new ClassHierarchy(component);
}
var watch = new Stopwatch()..start();
diff --git a/pkg/kernel/test/class_hierarchy_membench.dart b/pkg/kernel/test/class_hierarchy_membench.dart
index dcec19a..cb0d031 100644
--- a/pkg/kernel/test/class_hierarchy_membench.dart
+++ b/pkg/kernel/test/class_hierarchy_membench.dart
@@ -22,7 +22,7 @@
${argParser.usage}
""";
-/// Builds N copies of the class hierarchy for the given program.
+/// Builds N copies of the class hierarchy for the given component.
/// Pass --print-metrics to the Dart VM to measure the memory use.
main(List<String> args) {
if (args.length == 0) {
@@ -36,14 +36,14 @@
}
String filename = options.rest.single;
- Program program = loadProgramFromBinary(filename);
+ Component component = loadComponentFromBinary(filename);
int copyCount = int.parse(options['count']);
ClassHierarchy buildHierarchy() {
return options['basic']
- ? new BasicClassHierarchy(program)
- : new ClassHierarchy(program);
+ ? new BasicClassHierarchy(component)
+ : new ClassHierarchy(component);
}
List<ClosedWorldClassHierarchy> keepAlive = <ClosedWorldClassHierarchy>[];
diff --git a/pkg/kernel/test/class_hierarchy_self_check.dart b/pkg/kernel/test/class_hierarchy_self_check.dart
index 1c12454..486db45 100644
--- a/pkg/kernel/test/class_hierarchy_self_check.dart
+++ b/pkg/kernel/test/class_hierarchy_self_check.dart
@@ -12,13 +12,13 @@
main(List<String> args) {
runSelfCheck(args, (String filename) {
- testClassHierarchyOnProgram(loadProgramFromBinary(filename));
+ testClassHierarchyOnComponent(loadComponentFromBinary(filename));
});
}
-void testClassHierarchyOnProgram(Program program, {bool verbose: false}) {
- BasicClassHierarchy basic = new BasicClassHierarchy(program);
- ClosedWorldClassHierarchy classHierarchy = new ClassHierarchy(program);
+void testClassHierarchyOnComponent(Component component, {bool verbose: false}) {
+ BasicClassHierarchy basic = new BasicClassHierarchy(component);
+ ClosedWorldClassHierarchy classHierarchy = new ClassHierarchy(component);
int total = classHierarchy.classes.length;
int progress = 0;
for (var class1 in classHierarchy.classes) {
diff --git a/pkg/kernel/test/class_hierarchy_test.dart b/pkg/kernel/test/class_hierarchy_test.dart
index ac89f98..b9b1dc6 100644
--- a/pkg/kernel/test/class_hierarchy_test.dart
+++ b/pkg/kernel/test/class_hierarchy_test.dart
@@ -5,7 +5,7 @@
import 'package:kernel/ast.dart';
import 'package:kernel/class_hierarchy.dart';
import 'package:kernel/core_types.dart';
-import 'package:kernel/testing/mock_sdk_program.dart';
+import 'package:kernel/testing/mock_sdk_component.dart';
import 'package:kernel/text/ast_to_text.dart';
import 'package:kernel/type_algebra.dart';
import 'package:test/test.dart';
@@ -19,8 +19,8 @@
@reflectiveTest
class ClosedWorldClassHierarchyTest extends _ClassHierarchyTest {
- ClassHierarchy createClassHierarchy(Program program) {
- return new ClassHierarchy(program);
+ ClassHierarchy createClassHierarchy(Component component) {
+ return new ClassHierarchy(component);
}
void test_applyChanges() {
@@ -142,7 +142,7 @@
}
abstract class _ClassHierarchyTest {
- Program program;
+ Component component;
CoreTypes coreTypes;
/// The test library.
@@ -152,7 +152,7 @@
/// Return the new or existing instance of [ClassHierarchy].
ClassHierarchy get hierarchy {
- return _hierarchy ??= createClassHierarchy(program);
+ return _hierarchy ??= createClassHierarchy(component);
}
Class get objectClass => coreTypes.objectClass;
@@ -199,7 +199,7 @@
implementedTypes: implements_.map((c) => c.asThisSupertype).toList()));
}
- ClassHierarchy createClassHierarchy(Program program);
+ ClassHierarchy createClassHierarchy(Component component);
Procedure newEmptyGetter(String name,
{DartType returnType: const DynamicType(), bool isAbstract: false}) {
@@ -229,13 +229,13 @@
void setUp() {
// Start with mock SDK libraries.
- program = createMockSdkProgram();
- coreTypes = new CoreTypes(program);
+ component = createMockSdkComponent();
+ coreTypes = new CoreTypes(component);
// Add the test library.
library = new Library(Uri.parse('org-dartlang:///test.dart'), name: 'test');
- library.parent = program;
- program.libraries.add(library);
+ library.parent = component;
+ component.libraries.add(library);
}
/// 2. A non-abstract member is inherited from a superclass, and in the
diff --git a/pkg/kernel/test/class_hierarchy_test_disabled.dart b/pkg/kernel/test/class_hierarchy_test_disabled.dart
index 842f8a2..d1cd156 100644
--- a/pkg/kernel/test/class_hierarchy_test_disabled.dart
+++ b/pkg/kernel/test/class_hierarchy_test_disabled.dart
@@ -7,7 +7,7 @@
main() {
test('All-pairs class hierarchy tests on dart2js', () {
- testClassHierarchyOnProgram(
- loadProgramFromBinary('test/data/dart2js.dill'));
+ testClassHierarchyOnComponent(
+ loadComponentFromBinary('test/data/dart2js.dill'));
});
}
diff --git a/pkg/kernel/test/closures/suite.dart b/pkg/kernel/test/closures/suite.dart
index e29b394..a993f2e 100644
--- a/pkg/kernel/test/closures/suite.dart
+++ b/pkg/kernel/test/closures/suite.dart
@@ -13,7 +13,7 @@
import 'package:testing/testing.dart'
show Chain, ChainContext, Result, Step, runMe, StdioProcess;
-import 'package:kernel/ast.dart' show Program, Library;
+import 'package:kernel/ast.dart' show Component, Library;
import 'package:kernel/target/targets.dart' show Target;
@@ -38,7 +38,7 @@
final List<Step> steps;
- Program platform;
+ Component platform;
ClosureConversionContext(this.strongMode, bool updateExpectations)
: steps = <Step>[
@@ -71,19 +71,19 @@
}
class ClosureConversion
- extends Step<Program, Program, ClosureConversionContext> {
+ extends Step<Component, Component, ClosureConversionContext> {
const ClosureConversion();
String get name => "closure conversion";
- Future<Result<Program>> run(
- Program program, ClosureConversionContext testContext) async {
+ Future<Result<Component>> run(
+ Component component, ClosureConversionContext testContext) async {
try {
- CoreTypes coreTypes = new CoreTypes(program);
- Library library = program.libraries
+ CoreTypes coreTypes = new CoreTypes(component);
+ Library library = component.libraries
.firstWhere((Library library) => library.importUri.scheme != "dart");
closure_conversion.transformLibraries(coreTypes, <Library>[library]);
- return pass(program);
+ return pass(component);
} catch (e, s) {
return crash(e, s);
}
diff --git a/pkg/kernel/test/closures_initializers/suite.dart b/pkg/kernel/test/closures_initializers/suite.dart
index c406c6e..d7176d4 100644
--- a/pkg/kernel/test/closures_initializers/suite.dart
+++ b/pkg/kernel/test/closures_initializers/suite.dart
@@ -11,7 +11,7 @@
import 'package:testing/testing.dart'
show Chain, ChainContext, Result, Step, runMe;
-import 'package:kernel/ast.dart' show Program, Library;
+import 'package:kernel/ast.dart' show Component, Library;
import 'package:kernel/transformations/argument_extraction.dart'
as argument_extraction;
@@ -74,19 +74,19 @@
}
class ArgumentExtraction
- extends Step<Program, Program, ClosureConversionContext> {
+ extends Step<Component, Component, ClosureConversionContext> {
const ArgumentExtraction();
String get name => "argument extraction";
- Future<Result<Program>> run(
- Program program, ClosureConversionContext context) async {
+ Future<Result<Component>> run(
+ Component component, ClosureConversionContext context) async {
try {
- CoreTypes coreTypes = new CoreTypes(program);
- Library library = program.libraries
+ CoreTypes coreTypes = new CoreTypes(component);
+ Library library = component.libraries
.firstWhere((Library library) => library.importUri.scheme != "dart");
argument_extraction.transformLibraries(coreTypes, <Library>[library]);
- return pass(program);
+ return pass(component);
} catch (e, s) {
return crash(e, s);
}
@@ -94,19 +94,19 @@
}
class ClosureConversion
- extends Step<Program, Program, ClosureConversionContext> {
+ extends Step<Component, Component, ClosureConversionContext> {
const ClosureConversion();
String get name => "closure conversion";
- Future<Result<Program>> run(
- Program program, ClosureConversionContext testContext) async {
+ Future<Result<Component>> run(
+ Component component, ClosureConversionContext testContext) async {
try {
- CoreTypes coreTypes = new CoreTypes(program);
- Library library = program.libraries
+ CoreTypes coreTypes = new CoreTypes(component);
+ Library library = component.libraries
.firstWhere((Library library) => library.importUri.scheme != "dart");
closure_conversion.transformLibraries(coreTypes, <Library>[library]);
- return pass(program);
+ return pass(component);
} catch (e, s) {
return crash(e, s);
}
diff --git a/pkg/kernel/test/frontend_bench.dart b/pkg/kernel/test/frontend_bench.dart
index 4e9ea38..78d01c2 100644
--- a/pkg/kernel/test/frontend_bench.dart
+++ b/pkg/kernel/test/frontend_bench.dart
@@ -48,14 +48,14 @@
var uri = new Uri(scheme: 'file', path: new File(path).absolute.path);
var packages =
getPackagesDirectory(new Uri(scheme: 'file', path: packagePath));
- Program repository = new Program();
+ Component repository = new Component();
new DartLoader(
repository,
new DartOptions(
strongMode: strongMode, sdk: sdk, packagePath: packagePath),
packages)
- .loadProgram(uri);
+ .loadComponent(uri);
CacheEntry.recomputedCounts.forEach((key, value) {
print('Recomputed $key $value times');
diff --git a/pkg/kernel/test/interpreter/suite.dart b/pkg/kernel/test/interpreter/suite.dart
index 33e0f6b..00a8e03 100644
--- a/pkg/kernel/test/interpreter/suite.dart
+++ b/pkg/kernel/test/interpreter/suite.dart
@@ -11,7 +11,7 @@
import 'package:testing/testing.dart'
show Chain, ChainContext, Result, Step, runMe;
-import 'package:kernel/ast.dart' show Program, Library;
+import 'package:kernel/ast.dart' show Component, Library;
import 'package:kernel/target/targets.dart' show Target;
@@ -42,20 +42,20 @@
}
}
-class Interpret extends Step<Program, EvaluationLog, InterpreterContext> {
+class Interpret extends Step<Component, EvaluationLog, InterpreterContext> {
const Interpret();
String get name => "interpret";
- Future<Result<EvaluationLog>> run(Program program, _) async {
- Library library = program.libraries
+ Future<Result<EvaluationLog>> run(Component component, _) async {
+ Library library = component.libraries
.firstWhere((Library library) => library.importUri.scheme != "dart");
Uri uri = library.importUri;
StringBuffer buffer = new StringBuffer();
log.onRecord.listen((LogRecord rec) => buffer.write(rec.message));
try {
- new Interpreter(program).run();
+ new Interpreter(component).run();
} catch (e, s) {
return crash(e, s);
}
diff --git a/pkg/kernel/test/metadata_test.dart b/pkg/kernel/test/metadata_test.dart
index abb6d0c..1fb9777 100644
--- a/pkg/kernel/test/metadata_test.dart
+++ b/pkg/kernel/test/metadata_test.dart
@@ -58,12 +58,12 @@
}
/// Visitor that assigns [Metadata] object created with [Metadata.forNode] to
-/// each supported node in the program.
+/// each supported node in the component.
class Annotator extends RecursiveVisitor<Null> {
final TestMetadataRepository repository;
- Annotator(Program program)
- : repository = program.metadata[TestMetadataRepository.kTag];
+ Annotator(Component component)
+ : repository = component.metadata[TestMetadataRepository.kTag];
defaultTreeNode(TreeNode node) {
super.defaultTreeNode(node);
@@ -72,19 +72,19 @@
}
}
- static void annotate(Program p) {
+ static void annotate(Component p) {
globalDebuggingNames = new NameSystem();
p.accept(new Annotator(p));
}
}
-/// Visitor that checks that each supported node in the program has correct
+/// Visitor that checks that each supported node in the component has correct
/// metadata.
class Validator extends RecursiveVisitor<Null> {
final TestMetadataRepository repository;
- Validator(Program program)
- : repository = program.metadata[TestMetadataRepository.kTag];
+ Validator(Component component)
+ : repository = component.metadata[TestMetadataRepository.kTag];
defaultTreeNode(TreeNode node) {
super.defaultTreeNode(node);
@@ -97,22 +97,22 @@
}
}
- static void validate(Program p) {
+ static void validate(Component p) {
globalDebuggingNames = new NameSystem();
p.accept(new Validator(p));
}
}
-Program fromBinary(List<int> bytes) {
- var program = new Program();
- program.addMetadataRepository(new TestMetadataRepository());
- new BinaryBuilderWithMetadata(bytes).readSingleFileProgram(program);
- return program;
+Component fromBinary(List<int> bytes) {
+ var component = new Component();
+ component.addMetadataRepository(new TestMetadataRepository());
+ new BinaryBuilderWithMetadata(bytes).readSingleFileComponent(component);
+ return component;
}
-List<int> toBinary(Program p) {
+List<int> toBinary(Component p) {
final sink = new BytesBuilderSink();
- new BinaryPrinter(sink).writeProgramFile(p);
+ new BinaryPrinter(sink).writeComponentFile(p);
return sink.builder.takeBytes();
}
@@ -123,12 +123,12 @@
final List<int> platformBinary =
await new File(platform.toFilePath()).readAsBytes();
- final program = fromBinary(platformBinary);
- Annotator.annotate(program);
- Validator.validate(program);
+ final component = fromBinary(platformBinary);
+ Annotator.annotate(component);
+ Validator.validate(component);
- final annotatedProgramBinary = toBinary(program);
- final annotatedProgramFromBinary = fromBinary(annotatedProgramBinary);
- Validator.validate(annotatedProgramFromBinary);
+ final annotatedComponentBinary = toBinary(component);
+ final annotatedComponentFromBinary = fromBinary(annotatedComponentBinary);
+ Validator.validate(annotatedComponentFromBinary);
});
}
diff --git a/pkg/kernel/test/reify/suite.dart b/pkg/kernel/test/reify/suite.dart
index b9a70a8..768fbdc 100644
--- a/pkg/kernel/test/reify/suite.dart
+++ b/pkg/kernel/test/reify/suite.dart
@@ -30,7 +30,7 @@
import 'package:testing/testing.dart'
show Chain, ChainContext, Result, StdioProcess, Step, runMe;
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
import 'package:kernel/transformations/generic_types_reification.dart'
as generic_types_reification;
@@ -96,11 +96,11 @@
// Tree shaking needs to be disabled, because Generic Types Reification
// transformation relies on certain runtime libraries to be present in
- // the program that is being transformed. If the tree shaker is enabled,
+ // the component that is being transformed. If the tree shaker is enabled,
// it just deletes everything from those libraries, because they aren't
- // used in the program being transform prior to the transformation.
+ // used in the component being transformed prior to the transformation.
@override
- void performTreeShaking(CoreTypes coreTypes, Program program) {}
+ void performTreeShaking(CoreTypes coreTypes, Component component) {}
// Adds the necessary runtime libraries.
@override
@@ -111,16 +111,18 @@
}
}
-class GenericTypesReification extends Step<Program, Program, TestContext> {
+class GenericTypesReification extends Step<Component, Component, TestContext> {
const GenericTypesReification();
String get name => "generic types reification";
- Future<Result<Program>> run(Program program, TestContext testContext) async {
+ Future<Result<Component>> run(
+ Component component, TestContext testContext) async {
try {
- CoreTypes coreTypes = new CoreTypes(program);
- program = generic_types_reification.transformProgram(coreTypes, program);
- return pass(program);
+ CoreTypes coreTypes = new CoreTypes(component);
+ component =
+ generic_types_reification.transformComponent(coreTypes, component);
+ return pass(component);
} catch (e, s) {
return crash(e, s);
}
diff --git a/pkg/kernel/test/round_trip.dart b/pkg/kernel/test/round_trip.dart
index eb806ffd..8269b76 100644
--- a/pkg/kernel/test/round_trip.dart
+++ b/pkg/kernel/test/round_trip.dart
@@ -12,7 +12,7 @@
const String usage = '''
Usage: round_trip.dart FILE.dill
-Deserialize and serialize the given program and check that the resulting byte
+Deserialize and serialize the given component and check that the resulting byte
sequence is identical to the original.
''';
@@ -25,9 +25,9 @@
}
void testRoundTrip(List<int> bytes) {
- var program = new Program();
- new BinaryBuilder(bytes).readSingleFileProgram(program);
- new BinaryPrinterWithExpectedOutput(bytes).writeProgramFile(program);
+ var component = new Component();
+ new BinaryBuilder(bytes).readSingleFileComponent(component);
+ new BinaryPrinterWithExpectedOutput(bytes).writeComponentFile(component);
}
class DummyStreamConsumer extends StreamConsumer<List<int>> {
diff --git a/pkg/kernel/test/serialize_bench.dart b/pkg/kernel/test/serialize_bench.dart
index f19e1af..3957ddb 100644
--- a/pkg/kernel/test/serialize_bench.dart
+++ b/pkg/kernel/test/serialize_bench.dart
@@ -16,17 +16,17 @@
print(usage);
exit(1);
}
- Program program = loadProgramFromBinary(args[0]);
+ Component component = loadComponentFromBinary(args[0]);
String destination = args[1];
var watch = new Stopwatch()..start();
- await writeProgramToBinary(program, destination);
+ await writeComponentToBinary(component, destination);
int coldTime = watch.elapsedMilliseconds;
watch.reset();
int numTrials = 10;
for (int i = 0; i < numTrials; ++i) {
- await writeProgramToBinary(program, destination);
+ await writeComponentToBinary(component, destination);
}
double hotTime = watch.elapsedMilliseconds / numTrials;
diff --git a/pkg/kernel/test/treeshaker_bench.dart b/pkg/kernel/test/treeshaker_bench.dart
index 07f660e..5f6ef67 100644
--- a/pkg/kernel/test/treeshaker_bench.dart
+++ b/pkg/kernel/test/treeshaker_bench.dart
@@ -45,20 +45,20 @@
String filename = options.rest.single;
bool strongMode = options['strong'];
- Program program = loadProgramFromBinary(filename);
+ Component component = loadComponentFromBinary(filename);
ClassHierarchy buildClassHierarchy() {
return options['basic']
- ? new BasicClassHierarchy(program)
- : new ClassHierarchy(program);
+ ? new BasicClassHierarchy(component)
+ : new ClassHierarchy(component);
}
- CoreTypes coreTypes = new CoreTypes(program);
+ CoreTypes coreTypes = new CoreTypes(component);
var watch = new Stopwatch()..start();
ClassHierarchy sharedClassHierarchy = buildClassHierarchy();
int coldHierarchyTime = watch.elapsedMicroseconds;
- var shaker = new TreeShaker(coreTypes, sharedClassHierarchy, program,
+ var shaker = new TreeShaker(coreTypes, sharedClassHierarchy, component,
strongMode: strongMode);
if (options['diagnose']) {
print(shaker.getDiagnosticString());
@@ -80,7 +80,7 @@
watch.reset();
var hierarchy = getClassHierarchy();
hotHierarchyTime += watch.elapsedMicroseconds;
- new TreeShaker(coreTypes, hierarchy, program, strongMode: strongMode);
+ new TreeShaker(coreTypes, hierarchy, component, strongMode: strongMode);
hotTreeShakingTime += watch.elapsedMicroseconds;
}
hotHierarchyTime ~/= numberOfTrials;
diff --git a/pkg/kernel/test/treeshaker_check.dart b/pkg/kernel/test/treeshaker_check.dart
index 4d40d3d..9597141 100644
--- a/pkg/kernel/test/treeshaker_check.dart
+++ b/pkg/kernel/test/treeshaker_check.dart
@@ -21,12 +21,12 @@
print(usage);
exit(1);
}
- var program = loadProgramFromBinary(args[0]);
- var coreTypes = new CoreTypes(program);
- var hierarchy = new ClassHierarchy(program);
- var shaker = new TreeShaker(coreTypes, hierarchy, program);
- shaker.transform(program);
- new TreeShakingSanityCheck(shaker).visit(program);
+ var component = loadComponentFromBinary(args[0]);
+ var coreTypes = new CoreTypes(component);
+ var hierarchy = new ClassHierarchy(component);
+ var shaker = new TreeShaker(coreTypes, hierarchy, component);
+ shaker.transform(component);
+ new TreeShakingSanityCheck(shaker).visit(component);
}
class TreeShakingSanityCheck extends RecursiveVisitor {
diff --git a/pkg/kernel/test/treeshaker_dump.dart b/pkg/kernel/test/treeshaker_dump.dart
index b373fbf..8e56d71 100644
--- a/pkg/kernel/test/treeshaker_dump.dart
+++ b/pkg/kernel/test/treeshaker_dump.dart
@@ -32,7 +32,7 @@
String usage = '''
Usage: treeshaker_dump [options] FILE.dill
-Runs tree shaking on the given program and prints information about the results.
+Runs tree shaking on the given component and prints information about the results.
Example:
treeshaker_dump --instantiated foo.dill
@@ -65,11 +65,11 @@
bool strong = options['strong'];
- Program program = loadProgramFromBinary(filename);
- CoreTypes coreTypes = new CoreTypes(program);
- ClassHierarchy hierarchy = new ClassHierarchy(program);
+ Component component = loadComponentFromBinary(filename);
+ CoreTypes coreTypes = new CoreTypes(component);
+ ClassHierarchy hierarchy = new ClassHierarchy(component);
TreeShaker shaker =
- new TreeShaker(coreTypes, hierarchy, program, strongMode: strong);
+ new TreeShaker(coreTypes, hierarchy, component, strongMode: strong);
int totalClasses = 0;
int totalInstantiationCandidates = 0;
int totalMembers = 0;
@@ -92,7 +92,7 @@
}
}
- for (var library in program.libraries) {
+ for (var library in component.libraries) {
library.members.forEach(visitMember);
for (Class classNode in library.classes) {
++totalClasses;
@@ -130,12 +130,12 @@
String afterFile = pathlib.join(outputDir, '$name.after.txt');
NameSystem names = new NameSystem();
StringBuffer before = new StringBuffer();
- new Printer(before, syntheticNames: names).writeProgramFile(program);
+ new Printer(before, syntheticNames: names).writeComponentFile(component);
new File(beforeFile).writeAsStringSync('$before');
- new TreeShaker(coreTypes, hierarchy, program, strongMode: strong)
- .transform(program);
+ new TreeShaker(coreTypes, hierarchy, component, strongMode: strong)
+ .transform(component);
StringBuffer after = new StringBuffer();
- new Printer(after, syntheticNames: names).writeProgramFile(program);
+ new Printer(after, syntheticNames: names).writeComponentFile(component);
new File(afterFile).writeAsStringSync('$after');
print('Text written to $beforeFile and $afterFile');
}
diff --git a/pkg/kernel/test/treeshaker_membench.dart b/pkg/kernel/test/treeshaker_membench.dart
index 596ef87..b4f3dca 100644
--- a/pkg/kernel/test/treeshaker_membench.dart
+++ b/pkg/kernel/test/treeshaker_membench.dart
@@ -23,7 +23,7 @@
${argParser.usage}
""";
-/// Builds N copies of the tree shaker data structure for the given program.
+/// Builds N copies of the tree shaker data structure for the given component.
/// Pass --print-metrics to the Dart VM to measure the memory use.
main(List<String> args) {
if (args.length == 0) {
@@ -38,14 +38,14 @@
String filename = options.rest.single;
bool strongMode = options['strong'];
- Program program = loadProgramFromBinary(filename);
- ClassHierarchy hierarchy = new ClassHierarchy(program);
- CoreTypes coreTypes = new CoreTypes(program);
+ Component component = loadComponentFromBinary(filename);
+ ClassHierarchy hierarchy = new ClassHierarchy(component);
+ CoreTypes coreTypes = new CoreTypes(component);
int copyCount = int.parse(options['count']);
TreeShaker buildTreeShaker() {
- return new TreeShaker(coreTypes, hierarchy, program,
+ return new TreeShaker(coreTypes, hierarchy, component,
strongMode: strongMode);
}
diff --git a/pkg/kernel/test/type_hashcode_quality.dart b/pkg/kernel/test/type_hashcode_quality.dart
index 53a2b70..d90183a 100644
--- a/pkg/kernel/test/type_hashcode_quality.dart
+++ b/pkg/kernel/test/type_hashcode_quality.dart
@@ -15,9 +15,9 @@
print(usage);
exit(1);
}
- Program program = loadProgramFromBinary(args[0]);
+ Component component = loadComponentFromBinary(args[0]);
var visitor = new DartTypeCollector();
- program.accept(visitor);
+ component.accept(visitor);
print('''
Types: ${visitor.numberOfTypes}
Collisions: ${visitor.numberOfCollisions}''');
diff --git a/pkg/kernel/test/type_parser.dart b/pkg/kernel/test/type_parser.dart
index 2d3820b..8599091 100644
--- a/pkg/kernel/test/type_parser.dart
+++ b/pkg/kernel/test/type_parser.dart
@@ -288,11 +288,11 @@
final Map<String, Class> classes = <String, Class>{};
final Map<String, TypeParameter> typeParameters = <String, TypeParameter>{};
Library dummyLibrary;
- final Program program = new Program();
+ final Component component = new Component();
LazyTypeEnvironment() {
dummyLibrary = new Library(Uri.parse('file://dummy.dart'));
- program.libraries.add(dummyLibrary..parent = program);
+ component.libraries.add(dummyLibrary..parent = component);
dummyLibrary.name = 'lib';
}
diff --git a/pkg/kernel/test/type_subtype_test.dart b/pkg/kernel/test/type_subtype_test.dart
index 29e7bae..a1fb124 100644
--- a/pkg/kernel/test/type_subtype_test.dart
+++ b/pkg/kernel/test/type_subtype_test.dart
@@ -223,8 +223,8 @@
}
}
}
- var program = new Program(libraries: [environment.dummyLibrary]);
- var hierarchy = new ClassHierarchy(program);
+ var component = new Component(libraries: [environment.dummyLibrary]);
+ var hierarchy = new ClassHierarchy(component);
return new MockSubtypeTester(
hierarchy,
objectClass.rawType,
diff --git a/pkg/kernel/test/typecheck.dart b/pkg/kernel/test/typecheck.dart
index f8a054b..731378e 100644
--- a/pkg/kernel/test/typecheck.dart
+++ b/pkg/kernel/test/typecheck.dart
@@ -11,7 +11,7 @@
final String usage = '''
Usage: typecheck FILE.dill
-Runs the strong mode type checker on the given program.
+Runs the strong mode type checker on the given component.
''';
main(List<String> args) {
@@ -19,10 +19,10 @@
print(usage);
exit(1);
}
- var program = loadProgramFromBinary(args[0]);
- var coreTypes = new CoreTypes(program);
- var hierarchy = new ClassHierarchy(program);
- new TestTypeChecker(coreTypes, hierarchy).checkProgram(program);
+ var component = loadComponentFromBinary(args[0]);
+ var coreTypes = new CoreTypes(component);
+ var hierarchy = new ClassHierarchy(component);
+ new TestTypeChecker(coreTypes, hierarchy).checkComponent(component);
}
class TestTypeChecker extends TypeChecker {
diff --git a/pkg/kernel/test/verify_bench.dart b/pkg/kernel/test/verify_bench.dart
index 17fd65d..c5fc42e 100644
--- a/pkg/kernel/test/verify_bench.dart
+++ b/pkg/kernel/test/verify_bench.dart
@@ -10,7 +10,7 @@
final String usage = '''
Usage: verify_bench FILE.dill
-Measures the time it takes to run kernel verifier on the given program.
+Measures the time it takes to run kernel verifier on the given component.
''';
main(List<String> args) {
@@ -18,18 +18,18 @@
print(usage);
exit(1);
}
- var program = loadProgramFromBinary(args[0]);
+ var component = loadComponentFromBinary(args[0]);
var watch = new Stopwatch()..start();
- verifyProgram(program);
+ verifyComponent(component);
print('Cold: ${watch.elapsedMilliseconds} ms');
const int warmUpTrials = 20;
for (int i = 0; i < warmUpTrials; ++i) {
- verifyProgram(program);
+ verifyComponent(component);
}
watch.reset();
const int numberOfTrials = 100;
for (int i = 0; i < numberOfTrials; ++i) {
- verifyProgram(program);
+ verifyComponent(component);
}
double millisecondsPerRun = watch.elapsedMilliseconds / numberOfTrials;
print('Hot: $millisecondsPerRun ms');
diff --git a/pkg/kernel/test/verify_self_check.dart b/pkg/kernel/test/verify_self_check.dart
index a9ccbb8..bc9b184 100644
--- a/pkg/kernel/test/verify_self_check.dart
+++ b/pkg/kernel/test/verify_self_check.dart
@@ -9,6 +9,6 @@
main(List<String> args) {
runSelfCheck(args, (String filename) {
- verifyProgram(loadProgramFromBinary(filename));
+ verifyComponent(loadComponentFromBinary(filename));
});
}
diff --git a/pkg/kernel/test/verify_test.dart b/pkg/kernel/test/verify_test.dart
index 32b80f9..c08e7f7 100644
--- a/pkg/kernel/test/verify_test.dart
+++ b/pkg/kernel/test/verify_test.dart
@@ -11,9 +11,9 @@
const String tvarRegexp = "#T[0-9]+";
-/// Checks that the verifier correctly find errors in invalid programs.
+/// Checks that the verifier correctly find errors in invalid components.
///
-/// The frontend should never generate invalid programs, so we have to test
+/// The frontend should never generate invalid components, so we have to test
/// these by manually constructing invalid ASTs.
///
/// We mostly test negative cases here, as we get plenty of positive cases by
@@ -66,7 +66,7 @@
negativeTest('Class redeclared',
"Class 'test_lib::OtherClass' declared more than once.",
(TestHarness test) {
- return test.otherClass; // Test harness also adds otherClass to program.
+ return test.otherClass; // Test harness also adds otherClass to component.
});
negativeTest('Class type parameter redeclared',
matches("Type parameter 'test_lib::Test::$tvarRegexp' redeclared\\."),
@@ -478,18 +478,18 @@
});
}
-checkHasError(Program program, Matcher matcher) {
+checkHasError(Component component, Matcher matcher) {
try {
- verifyProgram(program);
+ verifyComponent(component);
} on VerificationError catch (e) {
expect(e.details, matcher);
return;
}
- fail('Failed to reject invalid program:\n${programToString(program)}');
+ fail('Failed to reject invalid component:\n${componentToString(component)}');
}
class TestHarness {
- Program program;
+ Component component;
Class objectClass;
Library stubLibrary;
@@ -541,18 +541,18 @@
}
TestHarness() {
- setupProgram();
+ setupComponent();
}
- void setupProgram() {
- program = new Program();
+ void setupComponent() {
+ component = new Component();
stubLibrary = new Library(Uri.parse('dart:core'));
- program.libraries.add(stubLibrary..parent = program);
+ component.libraries.add(stubLibrary..parent = component);
stubLibrary.name = 'dart.core';
objectClass = new Class(name: 'Object');
stubLibrary.addClass(objectClass);
enclosingLibrary = new Library(Uri.parse('file://test.dart'));
- program.libraries.add(enclosingLibrary..parent = program);
+ component.libraries.add(enclosingLibrary..parent = component);
enclosingLibrary.name = 'test_lib';
classTypeParameter = makeTypeParameter('T');
enclosingClass = new Class(
@@ -578,7 +578,7 @@
test(name, () {
var test = new TestHarness();
test.addNode(makeTestCase(test));
- checkHasError(test.program, matcher);
+ checkHasError(test.component, matcher);
});
}
@@ -586,6 +586,6 @@
test(name, () {
var test = new TestHarness();
test.addNode(makeTestCase(test));
- verifyProgram(test.program);
+ verifyComponent(test.component);
});
}
diff --git a/pkg/vm/bin/dump_kernel.dart b/pkg/vm/bin/dump_kernel.dart
index 1d0ea77..0f95c9ce 100644
--- a/pkg/vm/bin/dump_kernel.dart
+++ b/pkg/vm/bin/dump_kernel.dart
@@ -4,7 +4,7 @@
import 'dart:io';
-import 'package:kernel/kernel.dart' show Program, writeProgramToText;
+import 'package:kernel/kernel.dart' show Component, writeComponentToText;
import 'package:kernel/binary/ast_from_binary.dart'
show BinaryBuilderWithMetadata;
@@ -30,17 +30,17 @@
final input = arguments[0];
final output = arguments[1];
- final program = new Program();
+ final component = new Component();
// Register VM-specific metadata.
- program.addMetadataRepository(new DirectCallMetadataRepository());
- program.addMetadataRepository(new InferredTypeMetadataRepository());
- program.addMetadataRepository(new ProcedureAttributesMetadataRepository());
- program.addMetadataRepository(new UnreachableNodeMetadataRepository());
+ component.addMetadataRepository(new DirectCallMetadataRepository());
+ component.addMetadataRepository(new InferredTypeMetadataRepository());
+ component.addMetadataRepository(new ProcedureAttributesMetadataRepository());
+ component.addMetadataRepository(new UnreachableNodeMetadataRepository());
final List<int> bytes = new File(input).readAsBytesSync();
- new BinaryBuilderWithMetadata(bytes).readProgram(program);
+ new BinaryBuilderWithMetadata(bytes).readComponent(component);
- writeProgramToText(program,
+ writeComponentToText(component,
path: output, showExternal: true, showMetadata: true);
}
diff --git a/pkg/vm/bin/gen_kernel.dart b/pkg/vm/bin/gen_kernel.dart
index 4f0b943..5c17f8f 100644
--- a/pkg/vm/bin/gen_kernel.dart
+++ b/pkg/vm/bin/gen_kernel.dart
@@ -8,7 +8,7 @@
import 'package:args/args.dart' show ArgParser, ArgResults;
import 'package:front_end/src/api_prototype/front_end.dart';
import 'package:kernel/binary/ast_to_binary.dart';
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/src/tool/batch_util.dart' as batch_util;
import 'package:kernel/target/targets.dart' show TargetFlags;
import 'package:kernel/target/vm.dart' show VmTarget;
@@ -29,7 +29,7 @@
..addFlag('strong-mode', help: 'Enable strong mode', defaultsTo: true)
..addFlag('sync-async', help: 'Start `async` functions synchronously')
..addFlag('embed-sources',
- help: 'Embed source files in the generated kernel program',
+ help: 'Embed source files in the generated kernel component',
defaultsTo: true)
..addFlag('tfa',
help:
@@ -98,17 +98,17 @@
..onError = errorDetector
..embedSourceText = options['embed-sources'];
- Program program = await compileToKernel(
+ Component component = await compileToKernel(
Uri.base.resolveUri(new Uri.file(filename)), compilerOptions,
aot: aot, useGlobalTypeFlowAnalysis: tfa, entryPoints: entryPoints);
- if (errorDetector.hasCompilationErrors || (program == null)) {
+ if (errorDetector.hasCompilationErrors || (component == null)) {
return _compileTimeErrorExitCode;
}
final IOSink sink = new File(kernelBinaryFilename).openWrite();
final BinaryPrinter printer = new BinaryPrinter(sink);
- printer.writeProgramFile(program);
+ printer.writeComponentFile(component);
await sink.close();
return 0;
diff --git a/pkg/vm/bin/kernel_service.dart b/pkg/vm/bin/kernel_service.dart
index 7423661..a839ff4 100644
--- a/pkg/vm/bin/kernel_service.dart
+++ b/pkg/vm/bin/kernel_service.dart
@@ -33,7 +33,7 @@
show computePlatformBinariesLocation;
import 'package:front_end/src/fasta/kernel/utils.dart';
import 'package:front_end/src/testing/hybrid_file_system.dart';
-import 'package:kernel/kernel.dart' show Program;
+import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/target/targets.dart' show TargetFlags;
import 'package:kernel/target/vm.dart' show VmTarget;
import 'package:vm/incremental_compiler.dart';
@@ -109,11 +109,11 @@
};
}
- Future<Program> compile(Uri script) {
+ Future<Component> compile(Uri script) {
return runWithPrintToStderr(() => compileInternal(script));
}
- Future<Program> compileInternal(Uri script);
+ Future<Component> compileInternal(Uri script);
}
class IncrementalCompilerWrapper extends Compiler {
@@ -127,7 +127,7 @@
syncAsync: syncAsync);
@override
- Future<Program> compileInternal(Uri script) async {
+ Future<Component> compileInternal(Uri script) async {
if (generator == null) {
generator = new IncrementalCompiler(options, script);
}
@@ -153,10 +153,10 @@
syncAsync: syncAsync);
@override
- Future<Program> compileInternal(Uri script) async {
+ Future<Component> compileInternal(Uri script) async {
return requireMain
? kernelForProgram(script, options)
- : kernelForBuildUnit([script], options..chaseDependencies = true);
+ : kernelForComponent([script], options..chaseDependencies = true);
}
}
@@ -306,19 +306,19 @@
print("DFE: scriptUri: ${script}");
}
- Program program = await compiler.compile(script);
+ Component component = await compiler.compile(script);
if (compiler.errors.isNotEmpty) {
// TODO(sigmund): the compiler prints errors to the console, so we
// shouldn't print those messages again here.
result = new CompilationResult.errors(compiler.errors);
} else {
- // We serialize the program excluding vm_platform.dill because the VM has
+ // We serialize the component excluding vm_platform.dill because the VM has
// these sources built-in. Everything loaded as a summary in
// [kernelForProgram] is marked `external`, so we can use that bit to
// decide what to exclude.
result = new CompilationResult.ok(
- serializeProgram(program, filter: (lib) => !lib.isExternal));
+ serializeComponent(component, filter: (lib) => !lib.isExternal));
}
} catch (error, stack) {
result = new CompilationResult.crash(error, stack);
diff --git a/pkg/vm/lib/frontend_server.dart b/pkg/vm/lib/frontend_server.dart
index fe87b61..15ee47f 100644
--- a/pkg/vm/lib/frontend_server.dart
+++ b/pkg/vm/lib/frontend_server.dart
@@ -24,7 +24,7 @@
import 'package:kernel/ast.dart';
import 'package:kernel/binary/ast_to_binary.dart';
import 'package:kernel/binary/limited_ast_to_binary.dart';
-import 'package:kernel/kernel.dart' show Program, loadProgramFromBytes;
+import 'package:kernel/kernel.dart' show Component, loadComponentFromBytes;
import 'package:kernel/target/targets.dart';
import 'package:path/path.dart' as path;
import 'package:usage/uuid/uuid.dart';
@@ -142,7 +142,7 @@
}
abstract class ProgramTransformer {
- void transform(Program program);
+ void transform(Component component);
}
/// Class that for test mocking purposes encapsulates creation of [BinaryPrinter].
@@ -225,13 +225,13 @@
new TargetFlags(strongMode: options['strong']);
compilerOptions.target = getTarget(options['target'], targetFlags);
- Program program;
+ Component component;
if (options['incremental']) {
_compilerOptions = compilerOptions;
_generator = generator ??
_createGenerator(new Uri.file(_kernelBinaryFilenameFull));
await invalidateIfBootstrapping();
- program = await _runWithPrintRedirection(() => _generator.compile());
+ component = await _runWithPrintRedirection(() => _generator.compile());
} else {
if (options['link-platform']) {
// TODO(aam): Remove linkedDependencies once platform is directly embedded
@@ -240,26 +240,26 @@
sdkRoot.resolve(platformKernelDill)
];
}
- program = await _runWithPrintRedirection(() => compileToKernel(
+ component = await _runWithPrintRedirection(() => compileToKernel(
_mainSource, compilerOptions,
aot: options['aot'],
useGlobalTypeFlowAnalysis: options['tfa'],
entryPoints: options['entry-points']));
}
- if (program != null) {
+ if (component != null) {
if (transformer != null) {
- transformer.transform(program);
+ transformer.transform(component);
}
final IOSink sink = new File(_kernelBinaryFilename).openWrite();
final BinaryPrinter printer = printerFactory.newBinaryPrinter(sink);
- printer.writeProgramFile(program);
+ printer.writeComponentFile(component);
await sink.close();
_outputStream.writeln('$boundaryKey $_kernelBinaryFilename');
final String depfile = options['depfile'];
if (depfile != null) {
- await _writeDepfile(program, _kernelBinaryFilename, depfile);
+ await _writeDepfile(component, _kernelBinaryFilename, depfile);
}
_kernelBinaryFilename = _kernelBinaryFilenameIncremental;
@@ -275,11 +275,11 @@
final File f = new File(_kernelBinaryFilenameFull);
if (!f.existsSync()) return null;
- final Program program = loadProgramFromBytes(f.readAsBytesSync());
- for (Uri uri in program.uriToSource.keys) {
+ final Component component = loadComponentFromBytes(f.readAsBytesSync());
+ for (Uri uri in component.uriToSource.keys) {
if ('$uri' == '') continue;
- final List<int> oldBytes = program.uriToSource[uri].source;
+ final List<int> oldBytes = component.uriToSource[uri].source;
final FileSystemEntity entity =
_compilerOptions.fileSystem.entityForUri(uri);
if (!await entity.exists()) {
@@ -314,7 +314,7 @@
if (filename != null) {
setMainSourceFilename(filename);
}
- final Program deltaProgram =
+ final Component deltaProgram =
await _generator.compile(entryPoint: _mainSource);
if (deltaProgram != null && transformer != null) {
@@ -323,7 +323,7 @@
final IOSink sink = new File(_kernelBinaryFilename).openWrite();
final BinaryPrinter printer = printerFactory.newBinaryPrinter(sink);
- printer.writeProgramFile(deltaProgram);
+ printer.writeComponentFile(deltaProgram);
await sink.close();
_outputStream.writeln('$boundaryKey $_kernelBinaryFilename');
_kernelBinaryFilename = _kernelBinaryFilenameIncremental;
@@ -390,11 +390,11 @@
}
// https://ninja-build.org/manual.html#_depfile
-void _writeDepfile(Program program, String output, String depfile) async {
+void _writeDepfile(Component component, String output, String depfile) async {
final IOSink file = new File(depfile).openWrite();
file.write(_escapePath(output));
file.write(':');
- for (Uri dep in program.uriToSource.keys) {
+ for (Uri dep in component.uriToSource.keys) {
file.write(' ');
file.write(_escapePath(dep.toFilePath()));
}
diff --git a/pkg/vm/lib/incremental_compiler.dart b/pkg/vm/lib/incremental_compiler.dart
index ac51130..bfe5919 100644
--- a/pkg/vm/lib/incremental_compiler.dart
+++ b/pkg/vm/lib/incremental_compiler.dart
@@ -15,32 +15,32 @@
/// accepted.
class IncrementalCompiler {
IncrementalKernelGenerator _generator;
- List<Program> _pendingDeltas;
+ List<Component> _pendingDeltas;
CompilerOptions _compilerOptions;
IncrementalCompiler(this._compilerOptions, Uri entryPoint,
{Uri bootstrapDill}) {
_generator = new IncrementalKernelGenerator(
_compilerOptions, entryPoint, bootstrapDill);
- _pendingDeltas = <Program>[];
+ _pendingDeltas = <Component>[];
}
- /// Recompiles invalidated files, produces incremental program.
+ /// Recompiles invalidated files, produces incremental component.
///
/// If [entryPoint] is specified, that points to new entry point for the
/// compilation. Otherwise, previously set entryPoint is used.
- Future<Program> compile({Uri entryPoint}) async {
- Program program = await _generator.computeDelta(entryPoint: entryPoint);
+ Future<Component> compile({Uri entryPoint}) async {
+ Component component = await _generator.computeDelta(entryPoint: entryPoint);
final bool firstDelta = _pendingDeltas.isEmpty;
- _pendingDeltas.add(program);
+ _pendingDeltas.add(component);
if (firstDelta) {
- return program;
+ return component;
}
// If more than one delta is pending, we need to combine them.
Procedure mainMethod;
Map<Uri, Library> combined = <Uri, Library>{};
- for (Program delta in _pendingDeltas) {
+ for (Component delta in _pendingDeltas) {
if (delta.mainMethod != null) {
mainMethod = delta.mainMethod;
}
@@ -48,7 +48,7 @@
combined[library.importUri] = library;
}
}
- return new Program(libraries: combined.values.toList())
+ return new Component(libraries: combined.values.toList())
..mainMethod = mainMethod;
}
diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart
index e7c9030..aae78b5 100644
--- a/pkg/vm/lib/kernel_front_end.dart
+++ b/pkg/vm/lib/kernel_front_end.dart
@@ -14,22 +14,22 @@
import 'package:front_end/src/api_prototype/compilation_message.dart'
show CompilationMessage, Severity;
import 'package:front_end/src/fasta/severity.dart' show Severity;
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
import 'package:kernel/core_types.dart' show CoreTypes;
import 'transformations/devirtualization.dart' as devirtualization
- show transformProgram;
+ show transformComponent;
import 'transformations/no_dynamic_invocations_annotator.dart'
- as no_dynamic_invocations_annotator show transformProgram;
+ as no_dynamic_invocations_annotator show transformComponent;
import 'transformations/type_flow/transformer.dart' as globalTypeFlow
- show transformProgram;
+ show transformComponent;
/// Generates a kernel representation of the program whose main library is in
/// the given [source]. Intended for whole program (non-modular) compilation.
///
/// VM-specific replacement of [kernelForProgram].
///
-Future<Program> compileToKernel(Uri source, CompilerOptions options,
+Future<Component> compileToKernel(Uri source, CompilerOptions options,
{bool aot: false,
bool useGlobalTypeFlowAnalysis: false,
List<String> entryPoints}) async {
@@ -38,32 +38,32 @@
new ErrorDetector(previousErrorHandler: options.onError);
options.onError = errorDetector;
- final program = await kernelForProgram(source, options);
+ final component = await kernelForProgram(source, options);
// Restore error handler (in case 'options' are reused).
options.onError = errorDetector.previousErrorHandler;
- // Run global transformations only if program is correct.
- if (aot && (program != null) && !errorDetector.hasCompilationErrors) {
+ // Run global transformations only if component is correct.
+ if (aot && (component != null) && !errorDetector.hasCompilationErrors) {
_runGlobalTransformations(
- program, options.strongMode, useGlobalTypeFlowAnalysis, entryPoints);
+ component, options.strongMode, useGlobalTypeFlowAnalysis, entryPoints);
}
- return program;
+ return component;
}
-_runGlobalTransformations(Program program, bool strongMode,
+_runGlobalTransformations(Component component, bool strongMode,
bool useGlobalTypeFlowAnalysis, List<String> entryPoints) {
if (strongMode) {
- final coreTypes = new CoreTypes(program);
+ final coreTypes = new CoreTypes(component);
if (useGlobalTypeFlowAnalysis) {
- globalTypeFlow.transformProgram(coreTypes, program, entryPoints);
+ globalTypeFlow.transformComponent(coreTypes, component, entryPoints);
} else {
- devirtualization.transformProgram(coreTypes, program);
+ devirtualization.transformComponent(coreTypes, component);
}
- no_dynamic_invocations_annotator.transformProgram(program);
+ no_dynamic_invocations_annotator.transformComponent(component);
}
}
diff --git a/pkg/vm/lib/transformations/devirtualization.dart b/pkg/vm/lib/transformations/devirtualization.dart
index 0e03957..479755d 100644
--- a/pkg/vm/lib/transformations/devirtualization.dart
+++ b/pkg/vm/lib/transformations/devirtualization.dart
@@ -13,12 +13,13 @@
/// Devirtualization of method invocations based on the class hierarchy
/// analysis. Assumes strong mode and closed world.
-Program transformProgram(CoreTypes coreTypes, Program program) {
+Component transformComponent(CoreTypes coreTypes, Component component) {
void ignoreAmbiguousSupertypes(Class cls, Supertype a, Supertype b) {}
- final hierarchy = new ClassHierarchy(program,
+ final hierarchy = new ClassHierarchy(component,
onAmbiguousSupertypes: ignoreAmbiguousSupertypes);
- new CHADevirtualization(coreTypes, program, hierarchy).visitProgram(program);
- return program;
+ new CHADevirtualization(coreTypes, component, hierarchy)
+ .visitComponent(component);
+ return component;
}
/// Base class for implementing devirtualization of method invocations.
@@ -33,12 +34,12 @@
Set<Name> _objectMemberNames;
Devirtualization(
- CoreTypes coreTypes, Program program, ClassHierarchy hierarchy)
+ CoreTypes coreTypes, Component component, ClassHierarchy hierarchy)
: _metadata = new DirectCallMetadataRepository() {
_objectMemberNames = new Set<Name>.from(hierarchy
.getInterfaceMembers(coreTypes.objectClass)
.map((Member m) => m.name));
- program.addMetadataRepository(_metadata);
+ component.addMetadataRepository(_metadata);
}
bool isMethod(Member member) => (member is Procedure) && !member.isGetter;
@@ -141,8 +142,8 @@
class CHADevirtualization extends Devirtualization {
final ClosedWorldClassHierarchy _hierarchy;
- CHADevirtualization(CoreTypes coreTypes, Program program, this._hierarchy)
- : super(coreTypes, program, _hierarchy);
+ CHADevirtualization(CoreTypes coreTypes, Component component, this._hierarchy)
+ : super(coreTypes, component, _hierarchy);
@override
DirectCallMetadata getDirectCall(TreeNode node, Member target,
diff --git a/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart b/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart
index a176469..00e93ff 100644
--- a/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart
+++ b/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart
@@ -11,9 +11,9 @@
/// Assumes strong mode and closed world. If a procedure can not be riched
/// via dynamic invocation from anywhere then annotates it with appropriate
/// [ProcedureAttributeMetadata] annotation.
-Program transformProgram(Program program) {
- new NoDynamicUsesAnnotator(program).visitProgram(program);
- return program;
+Component transformComponent(Component component) {
+ new NoDynamicUsesAnnotator(component).visitComponent(component);
+ return component;
}
enum Action { get, set, invoke }
@@ -56,14 +56,14 @@
final DynamicSelectorsCollector _selectors;
final ProcedureAttributesMetadataRepository _metadata;
- NoDynamicUsesAnnotator(Program program)
- : _selectors = DynamicSelectorsCollector.collect(program),
+ NoDynamicUsesAnnotator(Component component)
+ : _selectors = DynamicSelectorsCollector.collect(component),
_metadata = new ProcedureAttributesMetadataRepository() {
- program.addMetadataRepository(_metadata);
+ component.addMetadataRepository(_metadata);
}
- visitProgram(Program program) {
- for (var library in program.libraries) {
+ visitComponent(Component component) {
+ for (var library in component.libraries) {
for (var klass in library.classes) {
visitClass(klass);
}
@@ -142,14 +142,14 @@
final Set<Selector> nonThisSelectors = new Set<Selector>();
final Set<Selector> tearOffSelectors = new Set<Selector>();
- static DynamicSelectorsCollector collect(Program program) {
+ static DynamicSelectorsCollector collect(Component component) {
final v = new DynamicSelectorsCollector();
- v.visitProgram(program);
+ v.visitComponent(component);
// We only populate [nonThisSelectors] and [tearOffSelectors] inside the
- // non-dynamic case (for efficiency reasons) while visiting the [Program].
+ // non-dynamic case (for efficiency reasons) while visiting the [Component].
//
- // After the recursive visit of [Program] we complete the sets here.
+ // After the recursive visit of [Component] we complete the sets here.
for (final Selector selector in v.dynamicSelectors) {
// All dynamic getters can be tearoffs.
if (selector.action == Action.get) {
diff --git a/pkg/vm/lib/transformations/type_flow/transformer.dart b/pkg/vm/lib/transformations/type_flow/transformer.dart
index 7d5480c..52f1055 100644
--- a/pkg/vm/lib/transformations/type_flow/transformer.dart
+++ b/pkg/vm/lib/transformations/type_flow/transformer.dart
@@ -30,21 +30,21 @@
/// Whole-program type flow analysis and transformation.
/// Assumes strong mode and closed world.
-Program transformProgram(
- CoreTypes coreTypes, Program program, List<String> entryPoints) {
+Component transformComponent(
+ CoreTypes coreTypes, Component component, List<String> entryPoints) {
if ((entryPoints == null) || entryPoints.isEmpty) {
throw 'Error: unable to perform global type flow analysis without entry points.';
}
void ignoreAmbiguousSupertypes(Class cls, Supertype a, Supertype b) {}
- final hierarchy = new ClassHierarchy(program,
+ final hierarchy = new ClassHierarchy(component,
onAmbiguousSupertypes: ignoreAmbiguousSupertypes);
final types = new TypeEnvironment(coreTypes, hierarchy, strongMode: true);
- final libraryIndex = new LibraryIndex.all(program);
+ final libraryIndex = new LibraryIndex.all(component);
if (kDumpAllSummaries) {
Statistics.reset();
- new CreateAllSummariesVisitor(types).visitProgram(program);
+ new CreateAllSummariesVisitor(types).visitComponent(component);
Statistics.print("All summaries statistics");
}
@@ -54,7 +54,7 @@
final typeFlowAnalysis = new TypeFlowAnalysis(hierarchy, types, libraryIndex,
entryPointsJSONFiles: entryPoints);
- Procedure main = program.mainMethod;
+ Procedure main = component.mainMethod;
final Selector mainSelector = new DirectSelector(main);
typeFlowAnalysis.addRawCall(mainSelector);
typeFlowAnalysis.process();
@@ -67,11 +67,12 @@
final transformsStopWatch = new Stopwatch()..start();
- new DropMethodBodiesVisitor(typeFlowAnalysis).visitProgram(program);
+ new DropMethodBodiesVisitor(typeFlowAnalysis).visitComponent(component);
- new TFADevirtualization(program, typeFlowAnalysis).visitProgram(program);
+ new TFADevirtualization(component, typeFlowAnalysis)
+ .visitComponent(component);
- new AnnotateKernel(program, typeFlowAnalysis).visitProgram(program);
+ new AnnotateKernel(component, typeFlowAnalysis).visitComponent(component);
transformsStopWatch.stop();
@@ -80,15 +81,15 @@
Statistics.print("TFA statistics");
- return program;
+ return component;
}
/// Devirtualization based on results of type flow analysis.
class TFADevirtualization extends Devirtualization {
final TypeFlowAnalysis _typeFlowAnalysis;
- TFADevirtualization(Program program, this._typeFlowAnalysis)
- : super(_typeFlowAnalysis.environment.coreTypes, program,
+ TFADevirtualization(Component component, this._typeFlowAnalysis)
+ : super(_typeFlowAnalysis.environment.coreTypes, component,
_typeFlowAnalysis.environment.hierarchy);
@override
@@ -138,11 +139,11 @@
final InferredTypeMetadataRepository _inferredTypeMetadata;
final UnreachableNodeMetadataRepository _unreachableNodeMetadata;
- AnnotateKernel(Program program, this._typeFlowAnalysis)
+ AnnotateKernel(Component component, this._typeFlowAnalysis)
: _inferredTypeMetadata = new InferredTypeMetadataRepository(),
_unreachableNodeMetadata = new UnreachableNodeMetadataRepository() {
- program.addMetadataRepository(_inferredTypeMetadata);
- program.addMetadataRepository(_unreachableNodeMetadata);
+ component.addMetadataRepository(_inferredTypeMetadata);
+ component.addMetadataRepository(_unreachableNodeMetadata);
}
InferredType _convertType(Type type) {
diff --git a/pkg/vm/test/frontend_server_test.dart b/pkg/vm/test/frontend_server_test.dart
index 0450f1d..3279881 100644
--- a/pkg/vm/test/frontend_server_test.dart
+++ b/pkg/vm/test/frontend_server_test.dart
@@ -5,7 +5,7 @@
import 'package:args/src/arg_results.dart';
import 'package:kernel/binary/ast_to_binary.dart';
-import 'package:kernel/ast.dart' show Program;
+import 'package:kernel/ast.dart' show Component;
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import 'package:vm/incremental_compiler.dart';
@@ -378,7 +378,7 @@
final _MockedIncrementalCompiler generator =
new _MockedIncrementalCompiler();
when(generator.compile())
- .thenAnswer((_) => new Future<Program>.value(new Program()));
+ .thenAnswer((_) => new Future<Component>.value(new Component()));
final _MockedBinaryPrinterFactory printerFactory =
new _MockedBinaryPrinterFactory();
when(printerFactory.newBinaryPrinter(any))
diff --git a/pkg/vm/test/incremental_compiler_test.dart b/pkg/vm/test/incremental_compiler_test.dart
index ee0e2ce..3736600 100644
--- a/pkg/vm/test/incremental_compiler_test.dart
+++ b/pkg/vm/test/incremental_compiler_test.dart
@@ -42,11 +42,11 @@
file.writeAsStringSync("main() {}\n");
IncrementalCompiler compiler = new IncrementalCompiler(options, file.uri);
- Program program = await compiler.compile();
+ Component component = await compiler.compile();
final StringBuffer buffer = new StringBuffer();
new Printer(buffer, showExternal: false, showMetadata: true)
- .writeLibraryFile(program.mainMethod.enclosingLibrary);
+ .writeLibraryFile(component.mainMethod.enclosingLibrary);
expect(
buffer.toString(),
equals('library;\n'
@@ -75,10 +75,10 @@
"openReceivePortSoWeWontDie() { new RawReceivePort(); }\n");
IncrementalCompiler compiler = new IncrementalCompiler(options, file.uri);
- Program program = await compiler.compile();
+ Component component = await compiler.compile();
File outputFile = new File('${systemTempDir.path}/foo.dart.dill');
- await _writeProgramToFile(program, outputFile);
+ await _writeProgramToFile(component, outputFile);
final List<String> vmArgs = [
'--trace_reload',
@@ -126,8 +126,8 @@
compiler.accept();
// Confirm that without changes VM reloads nothing.
- program = await compiler.compile();
- await _writeProgramToFile(program, outputFile);
+ component = await compiler.compile();
+ await _writeProgramToFile(component, outputFile);
var reloadResult = await remoteVm.reload(new Uri.file(outputFile.path));
expect(reloadResult['success'], isTrue);
expect(reloadResult['details']['loadedLibraryCount'], equals(0));
@@ -135,16 +135,16 @@
// Introduce a change that force VM to reject the change.
fileBar.writeAsStringSync("class A<T,U> { int _a; }\n");
compiler.invalidate(fileBar.uri);
- program = await compiler.compile();
- await _writeProgramToFile(program, outputFile);
+ component = await compiler.compile();
+ await _writeProgramToFile(component, outputFile);
reloadResult = await remoteVm.reload(new Uri.file(outputFile.path));
expect(reloadResult['success'], isFalse);
// Fix a change so VM is happy to accept the change.
fileBar.writeAsStringSync("class A<T> { int _a; hi() => _a; }\n");
compiler.invalidate(fileBar.uri);
- program = await compiler.compile();
- await _writeProgramToFile(program, outputFile);
+ component = await compiler.compile();
+ await _writeProgramToFile(component, outputFile);
reloadResult = await remoteVm.reload(new Uri.file(outputFile.path));
expect(reloadResult['success'], isTrue);
expect(reloadResult['details']['loadedLibraryCount'], equals(2));
@@ -155,11 +155,11 @@
});
}
-_writeProgramToFile(Program program, File outputFile) async {
+_writeProgramToFile(Component component, File outputFile) async {
final IOSink sink = outputFile.openWrite();
final BinaryPrinter printer = new LimitedBinaryPrinter(
sink, (_) => true /* predicate */, false /* excludeUriToSource */);
- printer.writeProgramFile(program);
+ printer.writeComponentFile(component);
await sink.close();
}
diff --git a/pkg/vm/test/transformations/type_flow/common_test_utils.dart b/pkg/vm/test/transformations/type_flow/common_test_utils.dart
index 01834d6..cdac3b9 100644
--- a/pkg/vm/test/transformations/type_flow/common_test_utils.dart
+++ b/pkg/vm/test/transformations/type_flow/common_test_utils.dart
@@ -15,7 +15,7 @@
const bool kDumpActualResult = const bool.fromEnvironment('dump.actual.result');
-Future<Program> compileTestCaseToKernelProgram(Uri sourceUri) async {
+Future<Component> compileTestCaseToKernelProgram(Uri sourceUri) async {
final platformKernel =
computePlatformBinariesLocation().resolve('vm_platform_strong.dill');
final options = new CompilerOptions()
diff --git a/pkg/vm/test/transformations/type_flow/summary_collector_test.dart b/pkg/vm/test/transformations/type_flow/summary_collector_test.dart
index bdd8af1..9d4499b 100644
--- a/pkg/vm/test/transformations/type_flow/summary_collector_test.dart
+++ b/pkg/vm/test/transformations/type_flow/summary_collector_test.dart
@@ -40,15 +40,15 @@
}
runTestCase(Uri source) async {
- final Program program = await compileTestCaseToKernelProgram(source);
- final Library library = program.mainMethod.enclosingLibrary;
+ final Component component = await compileTestCaseToKernelProgram(source);
+ final Library library = component.mainMethod.enclosingLibrary;
// Make sure the library name is the same and does not depend on the order
// of test cases.
library.name = '#lib';
- final typeEnvironment =
- new TypeEnvironment(new CoreTypes(program), new ClassHierarchy(program));
+ final typeEnvironment = new TypeEnvironment(
+ new CoreTypes(component), new ClassHierarchy(component));
final actual = new PrintSummaries(typeEnvironment).print(library);
diff --git a/pkg/vm/test/transformations/type_flow/transformer_test.dart b/pkg/vm/test/transformations/type_flow/transformer_test.dart
index 0aa23a6..45a1855 100644
--- a/pkg/vm/test/transformations/type_flow/transformer_test.dart
+++ b/pkg/vm/test/transformations/type_flow/transformer_test.dart
@@ -10,38 +10,38 @@
import 'package:kernel/text/ast_to_text.dart';
import 'package:test/test.dart';
import 'package:vm/transformations/type_flow/transformer.dart'
- show transformProgram;
+ show transformComponent;
import 'common_test_utils.dart';
final String pkgVmDir = Platform.script.resolve('../../..').toFilePath();
runTestCase(Uri source) async {
- Program program = await compileTestCaseToKernelProgram(source);
+ Component component = await compileTestCaseToKernelProgram(source);
// Make sure the library name is the same and does not depend on the order
// of test cases.
- program.mainMethod.enclosingLibrary.name = '#lib';
+ component.mainMethod.enclosingLibrary.name = '#lib';
- final coreTypes = new CoreTypes(program);
+ final coreTypes = new CoreTypes(component);
final entryPoints = [
pkgVmDir + '/lib/transformations/type_flow/entry_points.json',
pkgVmDir + '/lib/transformations/type_flow/entry_points_extra.json',
];
- program = transformProgram(coreTypes, program, entryPoints);
+ component = transformComponent(coreTypes, component, entryPoints);
final StringBuffer buffer = new StringBuffer();
new Printer(buffer, showExternal: false, showMetadata: true)
- .writeLibraryFile(program.mainMethod.enclosingLibrary);
+ .writeLibraryFile(component.mainMethod.enclosingLibrary);
final actual = buffer.toString();
compareResultWithExpectationsFile(source, actual);
}
main() {
- group('transform-program', () {
+ group('transform-component', () {
final testCasesDir = new Directory(
pkgVmDir + '/testcases/transformations/type_flow/transformer');
diff --git a/tests/compiler/dart2js/dill_loader_test.dart b/tests/compiler/dart2js/dill_loader_test.dart
index 56ac318..1963d3b 100644
--- a/tests/compiler/dart2js/dill_loader_test.dart
+++ b/tests/compiler/dart2js/dill_loader_test.dart
@@ -15,7 +15,7 @@
import 'package:compiler/src/apiimpl.dart' show CompilerImpl;
import "package:expect/expect.dart";
import 'package:front_end/src/api_prototype/front_end.dart';
-import 'package:front_end/src/fasta/kernel/utils.dart' show serializeProgram;
+import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
import 'package:compiler/src/kernel/dart2js_target.dart';
import 'package:kernel/target/targets.dart' show TargetFlags;
import 'package:front_end/src/compute_platform_binaries_location.dart'
@@ -52,7 +52,7 @@
..verify = true;
List<int> kernelBinary =
- serializeProgram(await kernelForProgram(uri, options));
+ serializeComponent(await kernelForProgram(uri, options));
CompilerImpl compiler = compilerFor(
entryPoint: entryPoint,
memorySourceFiles: {'main.dill': kernelBinary},
diff --git a/tests/compiler/dart2js/kernel/compiler_helper.dart b/tests/compiler/dart2js/kernel/compiler_helper.dart
index a11907e..e32bb06 100644
--- a/tests/compiler/dart2js/kernel/compiler_helper.dart
+++ b/tests/compiler/dart2js/kernel/compiler_helper.dart
@@ -61,15 +61,15 @@
}
class MemoryKernelLibraryLoaderTask extends KernelLibraryLoaderTask {
- final ir.Program program;
+ final ir.Component component;
MemoryKernelLibraryLoaderTask(KernelToElementMapForImpact elementMap,
- DiagnosticReporter reporter, Measurer measurer, this.program)
+ DiagnosticReporter reporter, Measurer measurer, this.component)
: super(null, null, elementMap, null, reporter, measurer);
Future<LoadedLibraries> loadLibrary(Uri resolvedUri,
{bool skipFileWithPartOfTag: false}) async {
- return createLoadedLibraries(program);
+ return createLoadedLibraries(component);
}
}
diff --git a/tools/patch_sdk.dart b/tools/patch_sdk.dart
index 8c06007..9dac1deb 100644
--- a/tools/patch_sdk.dart
+++ b/tools/patch_sdk.dart
@@ -23,7 +23,8 @@
import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
import 'package:front_end/src/fasta/get_dependencies.dart' show getDependencies;
-import 'package:front_end/src/fasta/kernel/utils.dart' show writeProgramToFile;
+import 'package:front_end/src/fasta/kernel/utils.dart'
+ show writeComponentToFile;
import 'package:kernel/target/targets.dart';
import 'package:kernel/target/vm.dart' show VmTarget;
@@ -216,8 +217,8 @@
false,
inputs),
buildSummary: true,
- buildProgram: true);
- await writeProgramToFile(result.program, output);
+ buildComponent: true);
+ await writeComponentToFile(result.component, output);
return result.deps;
}
diff --git a/utils/bazel/kernel_summary_worker.dart b/utils/bazel/kernel_summary_worker.dart
index 3cfe4d6..461e390 100644
--- a/utils/bazel/kernel_summary_worker.dart
+++ b/utils/bazel/kernel_summary_worker.dart
@@ -16,7 +16,7 @@
import 'package:bazel_worker/bazel_worker.dart';
import 'package:front_end/src/api_unstable/summary_worker.dart' as fe;
import 'package:front_end/src/multi_root_file_system.dart';
-import 'package:kernel/ast.dart' show Program, Library;
+import 'package:kernel/ast.dart' show Component, Library;
import 'package:kernel/target/targets.dart';
main(List<String> args) async {
@@ -175,21 +175,21 @@
: super(flags);
@override
- void performOutlineTransformations(Program program) {
+ void performOutlineTransformations(Component component) {
if (!excludeNonSources) return;
- List<Library> libraries = new List.from(program.libraries);
- program.libraries.clear();
+ List<Library> libraries = new List.from(component.libraries);
+ component.libraries.clear();
Set<Uri> include = sources.toSet();
for (var lib in libraries) {
if (include.contains(lib.importUri)) {
- program.libraries.add(lib);
+ component.libraries.add(lib);
} else {
// Excluding the library also means that their canonical names will not
// be computed as part of serialization, so we need to do that
// preemtively here to avoid errors when serializing references to
// elements of these libraries.
- program.root.getChildFromUri(lib.importUri).bindTo(lib.reference);
+ component.root.getChildFromUri(lib.importUri).bindTo(lib.reference);
lib.computeCanonicalNames();
}
}