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

Side by Side Diff: pkg/front_end/lib/src/incremental_kernel_generator_impl.dart

Issue 2928483005: Add an incremental reloader example and a utility tool to trigger a reload by (Closed)
Patch Set: CL comments Created 3 years, 6 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
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 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 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:front_end/file_system.dart'; 8 import 'package:front_end/file_system.dart';
9 import 'package:front_end/incremental_kernel_generator.dart'; 9 import 'package:front_end/incremental_kernel_generator.dart';
10 import 'package:front_end/src/base/api_signature.dart'; 10 import 'package:front_end/src/base/api_signature.dart';
11 import 'package:front_end/src/base/performace_logger.dart'; 11 import 'package:front_end/src/base/performace_logger.dart';
12 import 'package:front_end/src/base/processed_options.dart'; 12 import 'package:front_end/src/base/processed_options.dart';
13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; 13 import 'package:front_end/src/fasta/dill/dill_library_builder.dart';
14 import 'package:front_end/src/fasta/dill/dill_target.dart'; 14 import 'package:front_end/src/fasta/dill/dill_target.dart';
15 import 'package:front_end/src/fasta/kernel/kernel_target.dart'; 15 import 'package:front_end/src/fasta/kernel/kernel_target.dart';
16 import 'package:front_end/src/fasta/ticker.dart'; 16 import 'package:front_end/src/fasta/ticker.dart';
17 import 'package:front_end/src/fasta/translate_uri.dart'; 17 import 'package:front_end/src/fasta/translate_uri.dart';
18 import 'package:front_end/src/incremental/byte_store.dart'; 18 import 'package:front_end/src/incremental/byte_store.dart';
19 import 'package:front_end/src/incremental/file_state.dart'; 19 import 'package:front_end/src/incremental/file_state.dart';
20 import 'package:kernel/binary/ast_from_binary.dart'; 20 import 'package:kernel/binary/ast_from_binary.dart';
21 import 'package:kernel/binary/limited_ast_to_binary.dart'; 21 import 'package:kernel/binary/limited_ast_to_binary.dart';
22 import 'package:kernel/kernel.dart' hide Source; 22 import 'package:kernel/kernel.dart' hide Source;
23 import 'package:kernel/target/targets.dart' show TargetFlags; 23 import 'package:kernel/target/targets.dart' show TargetFlags;
24 import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget; 24 import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget;
25 25
26 dynamic unimplemented() {
27 // TODO(paulberry): get rid of this.
28 throw new UnimplementedError();
29 }
30
31 class ByteSink implements Sink<List<int>> { 26 class ByteSink implements Sink<List<int>> {
32 final BytesBuilder builder = new BytesBuilder(); 27 final BytesBuilder builder = new BytesBuilder();
33 28
34 void add(List<int> data) { 29 void add(List<int> data) {
35 builder.add(data); 30 builder.add(data);
36 } 31 }
37 32
38 void close() {} 33 void close() {}
39 } 34 }
40 35
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 for (Library library in result.kernelLibraries) { 121 for (Library library in result.kernelLibraries) {
127 Uri uri = library.importUri; 122 Uri uri = library.importUri;
128 if (_latestSignature[uri] != result.signature) { 123 if (_latestSignature[uri] != result.signature) {
129 _latestSignature[uri] = result.signature; 124 _latestSignature[uri] = result.signature;
130 program.libraries.add(library); 125 program.libraries.add(library);
131 library.parent = program; 126 library.parent = program;
132 } 127 }
133 } 128 }
134 } 129 }
135 130
131 if (watch != null) _fsState.fileUris.forEach((f) => watch(f, true));
132
136 // TODO(scheglov) Add libraries which import changed libraries. 133 // TODO(scheglov) Add libraries which import changed libraries.
137 // For now the corresponding test works because we use full library 134 // For now the corresponding test works because we use full library
138 // contents to compute signatures (not just API parts). So, every library 135 // contents to compute signatures (not just API parts). So, every library
139 // that imports a changed one, is affected. 136 // that imports a changed one, is affected.
140 137
141 // Set the main method. 138 // Set the main method.
142 for (var library in program.libraries) { 139 for (var library in program.libraries) {
143 if (library.fileUri == _entryPoint.toString()) { 140 if (library.fileUri == _entryPoint.toString()) {
144 program.mainMethod = library.procedures.firstWhere( 141 program.mainMethod = library.procedures.firstWhere(
145 (procedure) => procedure.name.name == 'main', 142 (procedure) => procedure.name.name == 'main',
146 orElse: () => null); 143 orElse: () => null);
147 break; 144 break;
148 } 145 }
149 } 146 }
150 147
151 return new DeltaProgram(program); 148 return new DeltaProgram(program);
152 }); 149 });
153 } 150 }
154 151
155 @override 152 @override
156 void invalidate(Uri uri) { 153 void invalidate(Uri uri) {
157 _invalidatedFiles.add(uri); 154 _invalidatedFiles.add(uri);
158 } 155 }
159 156
160 @override 157 @override
161 void invalidateAll() => unimplemented(); 158 void invalidateAll() {
159 _invalidatedFiles.addAll(_fsState.fileUris);
160 }
162 161
163 /// Ensure that [dillTarget] includes the [cycle] libraries. It already 162 /// Ensure that [dillTarget] includes the [cycle] libraries. It already
164 /// contains all the libraries that sorted before the given [cycle] in 163 /// contains all the libraries that sorted before the given [cycle] in
165 /// topological order. Return the result with the cycle libraries. 164 /// topological order. Return the result with the cycle libraries.
166 Future<_LibraryCycleResult> _compileCycle( 165 Future<_LibraryCycleResult> _compileCycle(
167 CanonicalName nameRoot, DillTarget dillTarget, LibraryCycle cycle) async { 166 CanonicalName nameRoot, DillTarget dillTarget, LibraryCycle cycle) async {
168 return _logger.runAsync('Compile cycle $cycle', () async { 167 return _logger.runAsync('Compile cycle $cycle', () async {
169 String signature; 168 String signature;
170 { 169 {
171 var signatureBuilder = new ApiSignature(); 170 var signatureBuilder = new ApiSignature();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 /// TODO(scheglov) Use API signatures. 325 /// TODO(scheglov) Use API signatures.
327 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines. 326 /// TODO(scheglov) Or use tree shaking and compute signatures of outlines.
328 final String signature; 327 final String signature;
329 328
330 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies 329 /// Kernel libraries for libraries in the [cycle]. Bodies of dependencies
331 /// are not included, but but references to those dependencies are included. 330 /// are not included, but but references to those dependencies are included.
332 final List<Library> kernelLibraries; 331 final List<Library> kernelLibraries;
333 332
334 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries); 333 _LibraryCycleResult(this.cycle, this.signature, this.kernelLibraries);
335 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698