| 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 class BailoutException { |
| 6 final String reason; |
| 7 |
| 8 const BailoutException(this.reason); |
| 9 } |
| 10 |
| 5 class DartBackend extends Backend { | 11 class DartBackend extends Backend { |
| 6 final List<CompilerTask> tasks; | 12 final List<CompilerTask> tasks; |
| 7 final UnparseValidator unparseValidator; | 13 final UnparseValidator unparseValidator; |
| 8 | 14 |
| 9 Map<Element, TreeElements> get resolvedElements() => | 15 Map<Element, TreeElements> get resolvedElements() => |
| 10 compiler.enqueuer.resolution.resolvedElements; | 16 compiler.enqueuer.resolution.resolvedElements; |
| 11 | 17 |
| 12 DartBackend(Compiler compiler, [bool validateUnparse = false]) | 18 DartBackend(Compiler compiler, [bool validateUnparse = false]) |
| 13 : tasks = <CompilerTask>[], | 19 : tasks = <CompilerTask>[], |
| 14 unparseValidator = new UnparseValidator(compiler, validateUnparse), | 20 unparseValidator = new UnparseValidator(compiler, validateUnparse), |
| 15 super(compiler) { | 21 super(compiler) { |
| 16 tasks.add(unparseValidator); | 22 tasks.add(unparseValidator); |
| 17 } | 23 } |
| 18 | 24 |
| 19 void enqueueHelpers(Enqueuer world) { | 25 void enqueueHelpers(Enqueuer world) { |
| 20 // TODO(antonm): Implement this method, if needed. | 26 // TODO(antonm): Implement this method, if needed. |
| 21 } | 27 } |
| 22 | 28 |
| 23 String codegen(WorkItem work) { } | 29 String codegen(WorkItem work) { } |
| 24 | 30 |
| 25 void processNativeClasses(Enqueuer world, | 31 void processNativeClasses(Enqueuer world, |
| 26 Collection<LibraryElement> libraries) { | 32 Collection<LibraryElement> libraries) { |
| 27 } | 33 } |
| 28 | 34 |
| 29 void assembleProgram() { | 35 void assembleProgram() { |
| 30 resolvedElements.forEach((element, treeElements) { | 36 resolvedElements.forEach((element, treeElements) { |
| 31 unparseValidator.check(element); | 37 unparseValidator.check(element); |
| 32 }); | 38 }); |
| 33 compiler.assembledCode = ''; | 39 |
| 40 // TODO(antonm): Eventually bailouts will be proper errors. |
| 41 void bailout(String reason) { |
| 42 throw new BailoutException(reason); |
| 43 } |
| 44 |
| 45 try { |
| 46 resolvedElements.forEach((element, treeElements) { |
| 47 bailout('I can do nothing right now.'); |
| 48 }); |
| 49 } catch (BailoutException e) { |
| 50 compiler.assembledCode = ''' |
| 51 main() { |
| 52 final bailout_reason = "${e.reason}"; |
| 53 } |
| 54 '''; |
| 55 } |
| 34 } | 56 } |
| 35 | 57 |
| 36 log(String message) => compiler.log('[DartBackend] $message'); | 58 log(String message) => compiler.log('[DartBackend] $message'); |
| 37 } | 59 } |
| OLD | NEW |