| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../compiler.dart' as api; | 9 import '../compiler.dart' as api; |
| 10 import 'dart2jslib.dart' as leg; | 10 import 'dart2jslib.dart' as leg; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 enableExperimentalMirrors: | 84 enableExperimentalMirrors: |
| 85 hasOption(options, '--enable-experimental-mirrors'), | 85 hasOption(options, '--enable-experimental-mirrors'), |
| 86 enableAsyncAwait: hasOption(options, '--enable-async'), | 86 enableAsyncAwait: hasOption(options, '--enable-async'), |
| 87 enableEnums: hasOption(options, '--enable-enum'), | 87 enableEnums: hasOption(options, '--enable-enum'), |
| 88 allowNativeExtensions: | 88 allowNativeExtensions: |
| 89 hasOption(options, '--allow-native-extensions')) { | 89 hasOption(options, '--allow-native-extensions')) { |
| 90 tasks.addAll([ | 90 tasks.addAll([ |
| 91 userHandlerTask = new leg.GenericTask('Diagnostic handler', this), | 91 userHandlerTask = new leg.GenericTask('Diagnostic handler', this), |
| 92 userProviderTask = new leg.GenericTask('Input provider', this), | 92 userProviderTask = new leg.GenericTask('Input provider', this), |
| 93 ]); | 93 ]); |
| 94 if (libraryRoot == null) { |
| 95 throw new ArgumentError("[libraryRoot] is null."); |
| 96 } |
| 94 if (!libraryRoot.path.endsWith("/")) { | 97 if (!libraryRoot.path.endsWith("/")) { |
| 95 throw new ArgumentError("libraryRoot must end with a /"); | 98 throw new ArgumentError("[libraryRoot] must end with a /."); |
| 96 } | 99 } |
| 97 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | 100 if (packageRoot == null) { |
| 98 throw new ArgumentError("packageRoot must end with a /"); | 101 throw new ArgumentError("[packageRoot] is null."); |
| 102 } |
| 103 if (!packageRoot.path.endsWith("/")) { |
| 104 throw new ArgumentError("[packageRoot] must end with a /."); |
| 99 } | 105 } |
| 100 if (!analyzeOnly) { | 106 if (!analyzeOnly) { |
| 101 if (enableAsyncAwait) { | 107 if (enableAsyncAwait) { |
| 102 throw new ArgumentError( | 108 throw new ArgumentError( |
| 103 "--enable-async is currently only supported with --analyze-only"); | 109 "--enable-async is currently only supported with --analyze-only"); |
| 104 } | 110 } |
| 105 if (allowNativeExtensions) { | 111 if (allowNativeExtensions) { |
| 106 throw new ArgumentError( | 112 throw new ArgumentError( |
| 107 "--allow-native-extensions is only supported in combination with " | 113 "--allow-native-extensions is only supported in combination with " |
| 108 "--analyze-only"); | 114 "--analyze-only"); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return libraryRoot.resolve(path); | 308 return libraryRoot.resolve(path); |
| 303 } | 309 } |
| 304 | 310 |
| 305 Uri resolvePatchUri(String dartLibraryPath) { | 311 Uri resolvePatchUri(String dartLibraryPath) { |
| 306 String patchPath = lookupPatchPath(dartLibraryPath); | 312 String patchPath = lookupPatchPath(dartLibraryPath); |
| 307 if (patchPath == null) return null; | 313 if (patchPath == null) return null; |
| 308 return libraryRoot.resolve(patchPath); | 314 return libraryRoot.resolve(patchPath); |
| 309 } | 315 } |
| 310 | 316 |
| 311 Uri translatePackageUri(leg.Spannable node, Uri uri) { | 317 Uri translatePackageUri(leg.Spannable node, Uri uri) { |
| 312 if (packageRoot == null) { | |
| 313 reportFatalError( | |
| 314 node, leg.MessageKind.PACKAGE_ROOT_NOT_SET, {'uri': uri}); | |
| 315 } | |
| 316 return packageRoot.resolve(uri.path); | 318 return packageRoot.resolve(uri.path); |
| 317 } | 319 } |
| 318 | 320 |
| 319 Future<bool> run(Uri uri) { | 321 Future<bool> run(Uri uri) { |
| 320 log('Allowed library categories: $allowedLibraryCategories'); | 322 log('Allowed library categories: $allowedLibraryCategories'); |
| 321 return super.run(uri).then((bool success) { | 323 return super.run(uri).then((bool success) { |
| 322 int cumulated = 0; | 324 int cumulated = 0; |
| 323 for (final task in tasks) { | 325 for (final task in tasks) { |
| 324 int elapsed = task.timing; | 326 int elapsed = task.timing; |
| 325 if (elapsed != 0) { | 327 if (elapsed != 0) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 print('$message: ${tryToString(exception)}'); | 386 print('$message: ${tryToString(exception)}'); |
| 385 print(tryToString(stackTrace)); | 387 print(tryToString(stackTrace)); |
| 386 } | 388 } |
| 387 | 389 |
| 388 fromEnvironment(String name) => environment[name]; | 390 fromEnvironment(String name) => environment[name]; |
| 389 | 391 |
| 390 LibraryInfo lookupLibraryInfo(String libraryName) { | 392 LibraryInfo lookupLibraryInfo(String libraryName) { |
| 391 return library_info.LIBRARIES[libraryName]; | 393 return library_info.LIBRARIES[libraryName]; |
| 392 } | 394 } |
| 393 } | 395 } |
| OLD | NEW |