| 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 | 7 import 'dart:async' show |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:io' show | 10 import 'dart:io' show |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 : dillTarget = dillTarget, | 104 : dillTarget = dillTarget, |
| 105 super(dillTarget.ticker, uriTranslator) { | 105 super(dillTarget.ticker, uriTranslator) { |
| 106 resetCrashReporting(); | 106 resetCrashReporting(); |
| 107 loader = new SourceLoader<Library>(this); | 107 loader = new SourceLoader<Library>(this); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void read(Uri uri) { | 110 void read(Uri uri) { |
| 111 loader.read(uri); | 111 loader.read(uri); |
| 112 } | 112 } |
| 113 | 113 |
| 114 LibraryBuilder createLibraryBuilder(Uri uri) { | 114 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri) { |
| 115 if (dillTarget.isLoaded) { | 115 if (dillTarget.isLoaded) { |
| 116 var builder = dillTarget.loader.builders[uri]; | 116 var builder = dillTarget.loader.builders[uri]; |
| 117 if (builder != null) { | 117 if (builder != null) { |
| 118 return builder; | 118 return builder; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 return new KernelLibraryBuilder(uri, loader); | 121 return new KernelLibraryBuilder(uri, fileUri, loader); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) { | 124 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) { |
| 125 if (cls == null) return; | 125 if (cls == null) return; |
| 126 TypeBuilder supertype = cls.supertype; | 126 TypeBuilder supertype = cls.supertype; |
| 127 add(InterfaceTypeBuilder type) { | 127 add(InterfaceTypeBuilder type) { |
| 128 Builder builder = type.builder; | 128 Builder builder = type.builder; |
| 129 if (builder is ClassBuilder) { | 129 if (builder is ClassBuilder) { |
| 130 set.add(builder); | 130 set.add(builder); |
| 131 } else if (builder is! InvalidTypeBuilder && | 131 } else if (builder is! InvalidTypeBuilder && |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return await writeLinkedProgram(uri, program, isFullProgram: false); | 260 return await writeLinkedProgram(uri, program, isFullProgram: false); |
| 261 } on InputError catch (e) { | 261 } on InputError catch (e) { |
| 262 return handleInputError(uri, e, isFullProgram: false); | 262 return handleInputError(uri, e, isFullProgram: false); |
| 263 } catch (e, s) { | 263 } catch (e, s) { |
| 264 return reportCrash(e, s, loader?.currentUriForCrashReporting); | 264 return reportCrash(e, s, loader?.currentUriForCrashReporting); |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 | 267 |
| 268 Program erroneousProgram(bool isFullProgram) { | 268 Program erroneousProgram(bool isFullProgram) { |
| 269 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); | 269 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); |
| 270 KernelLibraryBuilder library = new KernelLibraryBuilder(uri, loader); | 270 Uri fileUri = loader.first?.fileUri ?? uri; |
| 271 KernelLibraryBuilder library = |
| 272 new KernelLibraryBuilder(uri, fileUri, loader); |
| 271 loader.first = library; | 273 loader.first = library; |
| 272 if (isFullProgram) { | 274 if (isFullProgram) { |
| 273 // If this is an outline, we shouldn't add an executable main | 275 // If this is an outline, we shouldn't add an executable main |
| 274 // method. Similarly considerations apply to separate compilation. It | 276 // method. Similarly considerations apply to separate compilation. It |
| 275 // could also make sense to add a way to mark .dill files as having | 277 // could also make sense to add a way to mark .dill files as having |
| 276 // compile-time errors. | 278 // compile-time errors. |
| 277 KernelProcedureBuilder mainBuilder = new KernelProcedureBuilder(null, 0, | 279 KernelProcedureBuilder mainBuilder = new KernelProcedureBuilder(null, 0, |
| 278 null, "main", null, null, AsyncMarker.Sync, ProcedureKind.Method); | 280 null, "main", null, null, AsyncMarker.Sync, ProcedureKind.Method); |
| 279 library.addBuilder(mainBuilder.name, mainBuilder); | 281 library.addBuilder(mainBuilder.name, mainBuilder); |
| 280 mainBuilder.body = new ExpressionStatement( | 282 mainBuilder.body = new ExpressionStatement( |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 superclass = superclass.superclass; | 587 superclass = superclass.superclass; |
| 586 } | 588 } |
| 587 for (Constructor constructor in superclass.constructors) { | 589 for (Constructor constructor in superclass.constructors) { |
| 588 if (constructor.name.name.isEmpty) { | 590 if (constructor.name.name.isEmpty) { |
| 589 return constructor.function.requiredParameterCount == 0 ? | 591 return constructor.function.requiredParameterCount == 0 ? |
| 590 constructor : null; | 592 constructor : null; |
| 591 } | 593 } |
| 592 } | 594 } |
| 593 return null; | 595 return null; |
| 594 } | 596 } |
| OLD | NEW |