OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.kernel_target; | 5 library fasta.kernel_target; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'dart:io' show File, IOSink; | 9 import 'dart:io' show File, IOSink; |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 String message = error.format(); | 209 String message = error.format(); |
210 print(message); | 210 print(message); |
211 errors.add(message); | 211 errors.add(message); |
212 } | 212 } |
213 program = erroneousProgram(isFullProgram); | 213 program = erroneousProgram(isFullProgram); |
214 return uri == null | 214 return uri == null |
215 ? new Future<Program>.value(program) | 215 ? new Future<Program>.value(program) |
216 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram); | 216 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram); |
217 } | 217 } |
218 | 218 |
| 219 Future<Program> writeOutline(Uri uri) async { |
| 220 if (loader.first == null) return null; |
| 221 try { |
| 222 await loader.buildOutlines(); |
| 223 loader.resolveParts(); |
| 224 loader.computeLibraryScopes(); |
| 225 loader.resolveTypes(); |
| 226 loader.buildProgram(); |
| 227 loader.checkSemantics(); |
| 228 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses(); |
| 229 installDefaultSupertypes(); |
| 230 installDefaultConstructors(sourceClasses); |
| 231 loader.resolveConstructors(); |
| 232 loader.finishTypeVariables(objectClassBuilder); |
| 233 program = link(new List<Library>.from(loader.libraries)); |
| 234 if (uri == null) return program; |
| 235 return await writeLinkedProgram(uri, program, isFullProgram: false); |
| 236 } on InputError catch (e) { |
| 237 return handleInputError(uri, e, isFullProgram: false); |
| 238 } catch (e, s) { |
| 239 return reportCrash(e, s, loader?.currentUriForCrashReporting); |
| 240 } |
| 241 } |
| 242 |
219 Future<Program> writeProgram(Uri uri, | 243 Future<Program> writeProgram(Uri uri, |
220 {bool dumpIr: false, bool verify: false}) async { | 244 {bool dumpIr: false, bool verify: false}) async { |
221 if (loader.first == null) return null; | 245 if (loader.first == null) return null; |
222 if (errors.isNotEmpty) { | 246 if (errors.isNotEmpty) { |
223 return handleInputError(uri, null, isFullProgram: true); | 247 return handleInputError(uri, null, isFullProgram: true); |
224 } | 248 } |
225 try { | 249 try { |
226 loader.computeHierarchy(program); | 250 loader.computeHierarchy(program); |
227 await loader.buildBodies(); | 251 await loader.buildBodies(); |
228 loader.finishStaticInvocations(); | 252 loader.finishStaticInvocations(); |
(...skipping 11 matching lines...) Expand all Loading... |
240 } | 264 } |
241 if (uri == null) return program; | 265 if (uri == null) return program; |
242 return await writeLinkedProgram(uri, program, isFullProgram: true); | 266 return await writeLinkedProgram(uri, program, isFullProgram: true); |
243 } on InputError catch (e) { | 267 } on InputError catch (e) { |
244 return handleInputError(uri, e, isFullProgram: true); | 268 return handleInputError(uri, e, isFullProgram: true); |
245 } catch (e, s) { | 269 } catch (e, s) { |
246 return reportCrash(e, s, loader?.currentUriForCrashReporting); | 270 return reportCrash(e, s, loader?.currentUriForCrashReporting); |
247 } | 271 } |
248 } | 272 } |
249 | 273 |
250 Future<Program> writeOutline(Uri uri) async { | |
251 if (loader.first == null) return null; | |
252 try { | |
253 await loader.buildOutlines(); | |
254 loader.resolveParts(); | |
255 loader.computeLibraryScopes(); | |
256 loader.resolveTypes(); | |
257 loader.buildProgram(); | |
258 loader.checkSemantics(); | |
259 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses(); | |
260 installDefaultSupertypes(); | |
261 installDefaultConstructors(sourceClasses); | |
262 loader.resolveConstructors(); | |
263 loader.finishTypeVariables(objectClassBuilder); | |
264 program = link(new List<Library>.from(loader.libraries)); | |
265 if (uri == null) return program; | |
266 return await writeLinkedProgram(uri, program, isFullProgram: false); | |
267 } on InputError catch (e) { | |
268 return handleInputError(uri, e, isFullProgram: false); | |
269 } catch (e, s) { | |
270 return reportCrash(e, s, loader?.currentUriForCrashReporting); | |
271 } | |
272 } | |
273 | |
274 Future writeDepsFile(Uri output, Uri depsFile) async { | 274 Future writeDepsFile(Uri output, Uri depsFile) async { |
275 if (loader.first == null) return null; | 275 if (loader.first == null) return null; |
276 StringBuffer sb = new StringBuffer(); | 276 StringBuffer sb = new StringBuffer(); |
277 Uri base = depsFile.resolve("."); | 277 Uri base = depsFile.resolve("."); |
278 sb.write(Uri.parse(relativizeUri(output, base: base)).toFilePath()); | 278 sb.write(Uri.parse(relativizeUri(output, base: base)).toFilePath()); |
279 sb.write(":"); | 279 sb.write(":"); |
280 for (Uri dependency in loader.getDependencies()) { | 280 for (Uri dependency in loader.getDependencies()) { |
281 sb.write(" "); | 281 sb.write(" "); |
282 sb.write(Uri.parse(relativizeUri(dependency, base: base)).toFilePath()); | 282 sb.write(Uri.parse(relativizeUri(dependency, base: base)).toFilePath()); |
283 } | 283 } |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 } | 657 } |
658 for (Constructor constructor in superclass.constructors) { | 658 for (Constructor constructor in superclass.constructors) { |
659 if (constructor.name.name.isEmpty) { | 659 if (constructor.name.name.isEmpty) { |
660 return constructor.function.requiredParameterCount == 0 | 660 return constructor.function.requiredParameterCount == 0 |
661 ? constructor | 661 ? constructor |
662 : null; | 662 : null; |
663 } | 663 } |
664 } | 664 } |
665 return null; | 665 return null; |
666 } | 666 } |
OLD | NEW |