OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js_incremental; | 5 part of dart2js_incremental; |
6 | 6 |
7 /// Do not call this method directly. It will be made private. | 7 /// Do not call this method directly. It will be made private. |
8 // TODO(ahe): Make this method private. | 8 // TODO(ahe): Make this method private. |
9 Compiler reuseCompiler( | 9 Future<Compiler> reuseCompiler( |
10 {DiagnosticHandler diagnosticHandler, | 10 {DiagnosticHandler diagnosticHandler, |
11 CompilerInputProvider inputProvider, | 11 CompilerInputProvider inputProvider, |
12 CompilerOutputProvider outputProvider, | 12 CompilerOutputProvider outputProvider, |
13 List<String> options: const [], | 13 List<String> options: const [], |
14 Compiler cachedCompiler, | 14 Compiler cachedCompiler, |
15 Uri libraryRoot, | 15 Uri libraryRoot, |
16 Uri packageRoot, | 16 Uri packageRoot, |
17 bool packagesAreImmutable: false, | 17 bool packagesAreImmutable: false, |
18 Map<String, dynamic> environment, | 18 Map<String, dynamic> environment, |
19 bool reuseLibrary(LibraryElement library)}) { | 19 Future<bool> reuseLibrary(LibraryElement library)}) { |
20 UserTag oldTag = new UserTag('_reuseCompiler').makeCurrent(); | 20 UserTag oldTag = new UserTag('_reuseCompiler').makeCurrent(); |
21 if (libraryRoot == null) { | 21 if (libraryRoot == null) { |
22 throw 'Missing libraryRoot'; | 22 throw 'Missing libraryRoot'; |
23 } | 23 } |
24 if (inputProvider == null) { | 24 if (inputProvider == null) { |
25 throw 'Missing inputProvider'; | 25 throw 'Missing inputProvider'; |
26 } | 26 } |
27 if (diagnosticHandler == null) { | 27 if (diagnosticHandler == null) { |
28 throw 'Missing diagnosticHandler'; | 28 throw 'Missing diagnosticHandler'; |
29 } | 29 } |
(...skipping 18 matching lines...) Expand all Loading... |
48 } else if (compiler.compilerWasCancelled) { | 48 } else if (compiler.compilerWasCancelled) { |
49 print('Unable to reuse compiler due to cancel.'); | 49 print('Unable to reuse compiler due to cancel.'); |
50 } else if (compiler.enqueuer.resolution.hasEnqueuedReflectiveElements) { | 50 } else if (compiler.enqueuer.resolution.hasEnqueuedReflectiveElements) { |
51 print('Unable to reuse compiler due to dart:mirrors.'); | 51 print('Unable to reuse compiler due to dart:mirrors.'); |
52 } else if (compiler.deferredLoadTask.isProgramSplit) { | 52 } else if (compiler.deferredLoadTask.isProgramSplit) { |
53 print('Unable to reuse compiler due to deferred loading.'); | 53 print('Unable to reuse compiler due to deferred loading.'); |
54 } else { | 54 } else { |
55 print('Unable to reuse compiler.'); | 55 print('Unable to reuse compiler.'); |
56 } | 56 } |
57 } | 57 } |
58 compiler = new Compiler( | 58 oldTag.makeCurrent(); |
59 inputProvider, | 59 return new Future.value( |
60 outputProvider, | 60 new Compiler( |
61 diagnosticHandler, | 61 inputProvider, |
62 libraryRoot, | 62 outputProvider, |
63 packageRoot, | 63 diagnosticHandler, |
64 options, | 64 libraryRoot, |
65 environment); | 65 packageRoot, |
| 66 options, |
| 67 environment)); |
66 } else { | 68 } else { |
67 for (final task in compiler.tasks) { | 69 for (final task in compiler.tasks) { |
68 if (task.watch != null) { | 70 if (task.watch != null) { |
69 task.watch.reset(); | 71 task.watch.reset(); |
70 } | 72 } |
71 } | 73 } |
72 compiler | 74 compiler |
73 ..outputProvider = outputProvider | 75 ..outputProvider = outputProvider |
74 ..provider = inputProvider | 76 ..provider = inputProvider |
75 ..handler = diagnosticHandler | 77 ..handler = diagnosticHandler |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 ..precompiledFunction.clear() | 133 ..precompiledFunction.clear() |
132 ..precompiledConstructorNames.clear() | 134 ..precompiledConstructorNames.clear() |
133 ..hasMakeConstantList = false | 135 ..hasMakeConstantList = false |
134 ..elementDescriptors.clear(); | 136 ..elementDescriptors.clear(); |
135 | 137 |
136 backend | 138 backend |
137 ..preMirrorsMethodCount = 0; | 139 ..preMirrorsMethodCount = 0; |
138 | 140 |
139 if (reuseLibrary == null) { | 141 if (reuseLibrary == null) { |
140 reuseLibrary = (LibraryElement library) { | 142 reuseLibrary = (LibraryElement library) { |
141 return | 143 return new Future.value( |
142 library.isPlatformLibrary || | 144 library.isPlatformLibrary || |
143 (packagesAreImmutable && library.isPackageLibrary); | 145 (packagesAreImmutable && library.isPackageLibrary)); |
144 }; | 146 }; |
145 } | 147 } |
146 compiler.libraryLoader.reset(reuseLibrary: reuseLibrary); | 148 return compiler.libraryLoader.resetAsync(reuseLibrary).then((_) { |
| 149 oldTag.makeCurrent(); |
| 150 return compiler; |
| 151 }); |
147 } | 152 } |
148 oldTag.makeCurrent(); | |
149 return compiler; | |
150 } | 153 } |
OLD | NEW |