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 library runtime.tools.kernel_service; | 4 library runtime.tools.kernel_service; |
5 | 5 |
6 // This is an interface to the Dart Kernel parser and Kernel binary generator. | 6 // This is an interface to the Dart Kernel parser and Kernel binary generator. |
7 // | 7 // |
8 // It is used by the kernel-isolate to load Dart source code and generate | 8 // It is used by the kernel-isolate to load Dart source code and generate |
9 // Kernel binary format. | 9 // Kernel binary format. |
10 // | 10 // |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 declaredVariables: const {}); | 144 declaredVariables: const {}); |
145 DartLoader loader = | 145 DartLoader loader = |
146 await batch_loader.getLoader(new Repository(), dartOptions); | 146 await batch_loader.getLoader(new Repository(), dartOptions); |
147 var program = loader.loadProgram(fileName, target: target); | 147 var program = loader.loadProgram(fileName, target: target); |
148 | 148 |
149 var errors = loader.errors; | 149 var errors = loader.errors; |
150 if (errors.isNotEmpty) { | 150 if (errors.isNotEmpty) { |
151 return new CompilationError(loader.errors.toList()); | 151 return new CompilationError(loader.errors.toList()); |
152 } | 152 } |
153 | 153 |
154 // Link program into one file, cf. --link option in dartk. | 154 // Perform target-specific transformations. |
155 target.transformProgram(program); | 155 target.performModularTransformations(program); |
| 156 target.performGlobalTransformations(program); |
156 | 157 |
157 // Write the program to a list of bytes and return it. | 158 // Write the program to a list of bytes and return it. |
158 var sink = new DataSink(); | 159 var sink = new DataSink(); |
159 new BinaryPrinter(sink).writeProgramFile(program); | 160 new BinaryPrinter(sink).writeProgramFile(program); |
160 return new CompilationOk(sink.builder.takeBytes()); | 161 return new CompilationOk(sink.builder.takeBytes()); |
161 } | 162 } |
162 | 163 |
163 Future<CompilationResult> parseScript(DartLoaderBatch loader, Uri fileName, | 164 Future<CompilationResult> parseScript(DartLoaderBatch loader, Uri fileName, |
164 String packageConfig, String sdkPath) async { | 165 String packageConfig, String sdkPath) async { |
165 try { | 166 try { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (await new File.fromUri(packagesFile).exists()) { | 356 if (await new File.fromUri(packagesFile).exists()) { |
356 return packagesFile; | 357 return packagesFile; |
357 } | 358 } |
358 if (dir.parent.path == dir.path) { | 359 if (dir.parent.path == dir.path) { |
359 break; | 360 break; |
360 } | 361 } |
361 dir = dir.parent; | 362 dir = dir.parent; |
362 } | 363 } |
363 return null; | 364 return null; |
364 } | 365 } |
OLD | NEW |