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 dart2js.source_mirrors.analyze; | 5 library dart2js.source_mirrors.analyze; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'source_mirrors.dart'; | 9 import 'source_mirrors.dart'; |
10 import 'dart2js_mirrors.dart' show Dart2JsMirrorSystem; | 10 import 'dart2js_mirrors.dart' show Dart2JsMirrorSystem; |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | 33 if (packageRoot != null && !packageRoot.path.endsWith("/")) { |
34 throw new ArgumentError("packageRoot must end with a /"); | 34 throw new ArgumentError("packageRoot must end with a /"); |
35 } | 35 } |
36 options = new List<String>.from(options); | 36 options = new List<String>.from(options); |
37 options.add('--analyze-only'); | 37 options.add('--analyze-only'); |
38 options.add('--analyze-signatures-only'); | 38 options.add('--analyze-signatures-only'); |
39 options.add('--analyze-all'); | 39 options.add('--analyze-all'); |
40 options.add('--categories=Client,Server'); | 40 options.add('--categories=Client,Server'); |
41 options.add('--enable-async'); | 41 options.add('--enable-async'); |
| 42 options.add('--allow-native-extensions'); |
42 | 43 |
43 bool compilationFailed = false; | 44 bool compilationFailed = false; |
44 void internalDiagnosticHandler(Uri uri, int begin, int end, | 45 void internalDiagnosticHandler(Uri uri, int begin, int end, |
45 String message, api.Diagnostic kind) { | 46 String message, api.Diagnostic kind) { |
46 if (kind == api.Diagnostic.ERROR || | 47 if (kind == api.Diagnostic.ERROR || |
47 kind == api.Diagnostic.CRASH) { | 48 kind == api.Diagnostic.CRASH) { |
48 compilationFailed = true; | 49 compilationFailed = true; |
49 } | 50 } |
50 diagnosticHandler(uri, begin, end, message, kind); | 51 diagnosticHandler(uri, begin, end, message, kind); |
51 } | 52 } |
52 | 53 |
53 Compiler compiler = new apiimpl.Compiler(inputProvider, | 54 Compiler compiler = new apiimpl.Compiler(inputProvider, |
54 null, | 55 null, |
55 internalDiagnosticHandler, | 56 internalDiagnosticHandler, |
56 libraryRoot, packageRoot, | 57 libraryRoot, packageRoot, |
57 options, | 58 options, |
58 const {}); | 59 const {}); |
59 compiler.librariesToAnalyzeWhenRun = libraries; | 60 compiler.librariesToAnalyzeWhenRun = libraries; |
60 return compiler.run(null).then((bool success) { | 61 return compiler.run(null).then((bool success) { |
61 if (success && !compilationFailed) { | 62 if (success && !compilationFailed) { |
62 return new Dart2JsMirrorSystem(compiler); | 63 return new Dart2JsMirrorSystem(compiler); |
63 } else { | 64 } else { |
64 throw new StateError('Failed to create mirror system.'); | 65 throw new StateError('Failed to create mirror system.'); |
65 } | 66 } |
66 }); | 67 }); |
67 } | 68 } |
OLD | NEW |