OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_incremental; | 5 library dart2js_incremental; |
6 | 6 |
7 import 'dart:async' show | 7 import 'dart:async' show |
8 EventSink, | 8 EventSink, |
9 Future; | 9 Future; |
10 | 10 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 String update = updater.computeUpdateJs(); | 139 String update = updater.computeUpdateJs(); |
140 _updates.add(update); | 140 _updates.add(update); |
141 return update; | 141 return update; |
142 } | 142 } |
143 }); | 143 }); |
144 } | 144 } |
145 | 145 |
146 String allUpdates() { | 146 String allUpdates() { |
147 jsAst.Node updates = jsAst.js.escapedString(_updates.join("")); | 147 jsAst.Node updates = jsAst.js.escapedString(_updates.join("")); |
148 | 148 |
| 149 JavaScriptBackend backend = _compiler.backend; |
| 150 |
149 jsAst.FunctionDeclaration mainRunner = jsAst.js.statement(r""" | 151 jsAst.FunctionDeclaration mainRunner = jsAst.js.statement(r""" |
150 function dartMainRunner(main, args) { | 152 function dartMainRunner(main, args) { |
151 $dart_unsafe_eval.patch(#); | 153 #helper.patch(#updates); |
152 return main(args); | 154 return main(args); |
153 }""", updates); | 155 }""", {'updates': updates, 'helper': backend.namer.accessIncrementalHelper}); |
154 | |
155 | 156 |
156 jsAst.Printer printer = new jsAst.Printer(_compiler, null); | 157 jsAst.Printer printer = new jsAst.Printer(_compiler, null); |
157 printer.blockOutWithoutBraces(mainRunner); | 158 printer.blockOutWithoutBraces(mainRunner); |
158 return printer.outBuffer.getText(); | 159 return printer.outBuffer.getText(); |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 class IncrementalCompilationFailed { | 163 class IncrementalCompilationFailed { |
163 final String reason; | 164 final String reason; |
164 | 165 |
165 const IncrementalCompilationFailed(this.reason); | 166 const IncrementalCompilationFailed(this.reason); |
166 | 167 |
167 String toString() => "Can't incrementally compile program.\n\n$reason"; | 168 String toString() => "Can't incrementally compile program.\n\n$reason"; |
168 } | 169 } |
OLD | NEW |