提交 74e58f66 编写于 作者: A Alexander Aprelev 提交者: GitHub

Add reset method to reset incremental compiler. (#4187)

* Add reset method to reset incremental compiler.

This is needed to support Flutter app restart request.

* Indent constructor calls
上级 a9390e6f
......@@ -82,6 +82,10 @@ abstract class CompilerInterface {
/// This let's compiler know that source file identifed by `uri` was changed.
void invalidate(Uri uri);
/// Resets incremental compiler accept/reject status so that next time
/// recompile is requested, complete kernel file is produced.
void resetIncrementalCompiler();
}
/// Class that for test mocking purposes encapsulates creation of [BinaryPrinter].
......@@ -191,6 +195,11 @@ class _FrontendCompiler implements CompilerInterface {
_generator.invalidate(uri);
}
@override
void resetIncrementalCompiler() {
_generator.reset();
}
Uri _ensureFolderPath(String path) {
// This is a URI, not a file path, so the forward slash is correct even
// on Windows.
......@@ -257,6 +266,8 @@ Future<int> starter(List<String> args, {
compiler.acceptLastDelta();
else if (string == 'reject')
compiler.rejectLastDelta();
else if (string == 'reset')
compiler.resetIncrementalCompiler();
else if (string == 'quit')
exit(0);
break;
......
......@@ -168,6 +168,22 @@ Future<int> main() async {
inputStreamController.close();
});
test('reset', () async {
final StreamController<List<int>> inputStreamController =
new StreamController<List<int>>();
final ReceivePort resetCalled = new ReceivePort();
when(compiler.resetIncrementalCompiler()).thenAnswer((Invocation invocation) {
resetCalled.sendPort.send(true);
});
final int exitcode = await starter(args, compiler: compiler,
input: inputStreamController.stream,
);
expect(exitcode, equals(0));
inputStreamController.add('reset\n'.codeUnits);
await resetCalled.first;
inputStreamController.close();
});
test('compile then recompile', () async {
final StreamController<List<int>> streamController =
new StreamController<List<int>>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册