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 15 matching lines...) Expand all Loading... |
26 InvalidInitializer, | 26 InvalidInitializer, |
27 Library, | 27 Library, |
28 Name, | 28 Name, |
29 NamedExpression, | 29 NamedExpression, |
30 NullLiteral, | 30 NullLiteral, |
31 Procedure, | 31 Procedure, |
32 ProcedureKind, | 32 ProcedureKind, |
33 Program, | 33 Program, |
34 RedirectingInitializer, | 34 RedirectingInitializer, |
35 ReturnStatement, | 35 ReturnStatement, |
| 36 Source, |
36 StaticGet, | 37 StaticGet, |
37 StringLiteral, | 38 StringLiteral, |
38 SuperInitializer, | 39 SuperInitializer, |
39 Throw, | 40 Throw, |
40 VariableDeclaration, | 41 VariableDeclaration, |
41 VariableGet, | 42 VariableGet, |
42 VoidType; | 43 VoidType; |
43 | 44 |
44 import 'package:kernel/binary/ast_to_binary.dart' show | 45 import 'package:kernel/binary/ast_to_binary.dart' show |
45 BinaryPrinter; | 46 BinaryPrinter; |
46 | 47 |
47 import 'package:kernel/text/ast_to_text.dart' show | 48 import 'package:kernel/text/ast_to_text.dart' show |
48 Printer; | 49 Printer; |
49 | 50 |
50 import 'package:kernel/transformations/mixin_full_resolution.dart' show | 51 import 'package:kernel/transformations/mixin_full_resolution.dart' show |
51 MixinFullResolution, | 52 MixinFullResolution; |
52 SuperInitializerResolutionTransformer; | |
53 | 53 |
54 import '../source/source_loader.dart' show | 54 import '../source/source_loader.dart' show |
55 SourceLoader; | 55 SourceLoader; |
56 | 56 |
57 import '../source/source_class_builder.dart' show | 57 import '../source/source_class_builder.dart' show |
58 SourceClassBuilder; | 58 SourceClassBuilder; |
59 | 59 |
60 import '../target_implementation.dart' show | 60 import '../target_implementation.dart' show |
61 TargetImplementation; | 61 TargetImplementation; |
62 | 62 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 loader.first = library; | 274 loader.first = library; |
275 mainBuilder.body = new ExpressionStatement( | 275 mainBuilder.body = new ExpressionStatement( |
276 new Throw(new StringLiteral("${errors.join('\n')}"))); | 276 new Throw(new StringLiteral("${errors.join('\n')}"))); |
277 library.build(); | 277 library.build(); |
278 return link(<Library>[library.library]); | 278 return link(<Library>[library.library]); |
279 } | 279 } |
280 | 280 |
281 /// Creates a program by combining [libraries] with the libraries of | 281 /// Creates a program by combining [libraries] with the libraries of |
282 /// `dillTarget.loader.program`. | 282 /// `dillTarget.loader.program`. |
283 Program link(List<Library> libraries) { | 283 Program link(List<Library> libraries) { |
284 Map<String, List<int>> uriToLineStarts = <String, List<int>>{}; | 284 Map<String, Source> uriToSource = <String, Source>{}; |
285 | 285 |
286 // for (Library library in libraries) { | 286 // for (Library library in libraries) { |
287 // // TODO(ahe): Compute line starts instead. | 287 // // TODO(ahe): Compute line starts instead. |
288 // uriToLineStarts[library.fileUri] = <int>[0]; | 288 // uriToLineStarts[library.fileUri] = <int>[0]; |
289 // } | 289 // } |
290 | 290 |
291 final Program binary = dillTarget.loader.program; | 291 final Program binary = dillTarget.loader.program; |
292 if (binary != null) { | 292 if (binary != null) { |
293 libraries.addAll(binary.libraries); | 293 libraries.addAll(binary.libraries); |
294 uriToLineStarts.addAll(binary.uriToLineStarts); | 294 uriToSource.addAll(binary.uriToSource); |
295 } | 295 } |
296 | 296 |
297 // TODO(ahe): Remove this line. Kernel seems to generate a default line map | 297 // TODO(ahe): Remove this line. Kernel seems to generate a default line map |
298 // that used when there's no fileUri on an element. Instead, ensure all | 298 // that used when there's no fileUri on an element. Instead, ensure all |
299 // elements have a fileUri. | 299 // elements have a fileUri. |
300 uriToLineStarts[""] = <int>[0]; | 300 uriToSource[""] = new Source(<int>[0], ""); |
301 Program program = new Program(libraries, uriToLineStarts); | 301 Program program = new Program(libraries, uriToSource); |
302 if (loader.first != null) { | 302 if (loader.first != null) { |
303 Builder builder = loader.first.members["main"]; | 303 Builder builder = loader.first.members["main"]; |
304 if (builder is KernelProcedureBuilder) { | 304 if (builder is KernelProcedureBuilder) { |
305 program.mainMethod = builder.procedure; | 305 program.mainMethod = builder.procedure; |
306 } | 306 } |
307 } | 307 } |
308 // TODO(ahe): This is kinda hackish. Use the transformer instead. | 308 // TODO(ahe): This is kinda hackish. Use the transformer instead. |
309 LibraryBuilder builtin = | 309 LibraryBuilder builtin = |
310 dillTarget.loader.builders[Uri.parse("dart:_builtin")]; | 310 dillTarget.loader.builders[Uri.parse("dart:_builtin")]; |
311 if (builtin != null) { | 311 if (builtin != null) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 superclass = superclass.superclass; | 579 superclass = superclass.superclass; |
580 } | 580 } |
581 for (Constructor constructor in superclass.constructors) { | 581 for (Constructor constructor in superclass.constructors) { |
582 if (constructor.name.name.isEmpty) { | 582 if (constructor.name.name.isEmpty) { |
583 return constructor.function.requiredParameterCount == 0 ? | 583 return constructor.function.requiredParameterCount == 0 ? |
584 constructor : null; | 584 constructor : null; |
585 } | 585 } |
586 } | 586 } |
587 return null; | 587 return null; |
588 } | 588 } |
OLD | NEW |