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

Side by Side Diff: pkg/front_end/lib/incremental_kernel_generator.dart

Issue 2624193003: Work in progress: front end hot reload API (Closed)
Patch Set: First steel thread of functionality. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6
7 import 'package:front_end/src/base/processed_options.dart';
8 import 'package:front_end/src/incremental_kernel_generator_impl.dart';
9 import 'package:kernel/kernel.dart';
10
11 import 'compiler_options.dart';
12
13 /// Represents the difference between "old" and "new" states of a program.
14 ///
15 /// Not intended to be implemented or extended by clients.
16 class DeltaProgram {
17 /// The new state of the program.
18 ///
19 /// Libraries whose kernel representation is known to be unchanged since the
20 /// last [DeltaProgram] are not included.
21 final Map<Uri, Program> newState;
scheglov 2017/01/16 19:24:58 Program? I don't know about Kernel much, but if Pr
Paul Berry 2017/01/17 13:45:31 It's a little confusing because we are taking adva
22
23 DeltaProgram(this.newState);
24
25 /// TODO(paulberry): add information about libraries that were removed.
26 }
27
28 /// Interface for generating an initial kernel representation of a program and
29 /// keeping it up to date as incremental changes are made.
30 ///
31 /// This class maintains an internal "previous program state"; each
32 /// time [computeDelta] is called, it updates the previous program state and
33 /// produces a representation of what has changed. When there are few changes,
34 /// a call to [computeDelta] should be much faster than compiling the whole
35 /// program from scratch.
36 ///
37 /// This class also maintains a set of "valid sources", which is a (possibly
38 /// empty) subset of the sources constituting the previous program state. Files
39 /// in this set are assumed to be unchanged since the last call to
40 /// [computeDelta].
41 ///
42 /// Behavior is undefined if the client does not obey the following concurrency
43 /// restrictions:
44 /// - no two invocations of [computeDelta] may be outstanding at any given time.
45 /// - neither [invalidate] nor [invalidateAll] may be called while an invocation
46 /// of [computeDelta] is outstanding.
47 ///
48 /// Not intended to be implemented or extended by clients.
49 abstract class IncrementalKernelGenerator {
50 /// Creates an [IncrementalKernelGenerator] which is prepared to generate
51 /// kernel representations of the program whose main library is in the given
52 /// [source].
53 ///
54 /// No file system access is performed by this constructor; the initial
55 /// "previous program state" is an empty program containing no code, and the
56 /// initial set of valid sources is empty. To obtain a kernel representation
57 /// of the program, call [computeDelta].
58 factory IncrementalKernelGenerator(Uri source, CompilerOptions options) =>
59 new IncrementalKernelGeneratorImpl(source, new ProcessedOptions(options));
60
61 /// Generates a kernel representation of the changes to the program, assuming
62 /// that all valid sources are unchanged since the last call to
63 /// [computeDelta].
64 ///
65 /// Source files in the set of valid sources are guaranteed not to be re-read
66 /// from disk; they are assumed to be unchanged regardless of the state of the
67 /// filesystem.
68 ///
69 /// If the future completes successfully, the previous file state is updated
70 /// and the set of valid sources is set to the set of all sources in the
71 /// program.
72 ///
73 /// If the future completes with an error (due to errors in the compiled
74 /// source code), the caller may consider the previous file state and the set
75 /// of valid sources to be unchanged; this means that once the user fixes the
76 /// errors, it is safe to call [computeDelta] again.
77 Future<DeltaProgram> computeDelta();
78
79 /// Remove any source file(s) associated with the given file path from the set
80 /// of valid sources. This guarantees that those files will be re-read on the
81 /// next call to [computeDelta]).
82 void invalidate(String path);
83
84 /// Remove all source files from the set of valid sources. This guarantees
85 /// that all files will be re-read on the next call to [computeDelta].
86 ///
87 /// Note that this does not erase the previous program state; the next time
88 /// [computeDelta] is called, if parts of the program are discovered to be
89 /// unchanged, parts of the previous program state will still be re-used to
90 /// speed up compilation.
91 void invalidateAll();
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698