| 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 { | 5 class BailoutException { |
| 6 final String reason; | 6 final String reason; |
| 7 | 7 |
| 8 const BailoutException(this.reason); | 8 const BailoutException(this.reason); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 resolvedElements.forEach((element, treeElements) { | 36 resolvedElements.forEach((element, treeElements) { |
| 37 unparseValidator.check(element); | 37 unparseValidator.check(element); |
| 38 }); | 38 }); |
| 39 | 39 |
| 40 // TODO(antonm): Eventually bailouts will be proper errors. | 40 // TODO(antonm): Eventually bailouts will be proper errors. |
| 41 void bailout(String reason) { | 41 void bailout(String reason) { |
| 42 throw new BailoutException(reason); | 42 throw new BailoutException(reason); |
| 43 } | 43 } |
| 44 | 44 |
| 45 try { | 45 try { |
| 46 StringBuffer sb = new StringBuffer(); |
| 46 resolvedElements.forEach((element, treeElements) { | 47 resolvedElements.forEach((element, treeElements) { |
| 47 bailout('I can do nothing right now.'); | 48 if (!element.isTopLevel()) { |
| 49 bailout('Cannot process non top-level $element'); |
| 50 } |
| 51 sb.add(element.parseNode(compiler).unparse()); |
| 48 }); | 52 }); |
| 53 compiler.assembledCode = sb.toString(); |
| 49 } catch (BailoutException e) { | 54 } catch (BailoutException e) { |
| 50 compiler.assembledCode = ''' | 55 compiler.assembledCode = ''' |
| 51 main() { | 56 main() { |
| 52 final bailout_reason = "${e.reason}"; | 57 final bailout_reason = "${e.reason}"; |
| 53 } | 58 } |
| 54 '''; | 59 '''; |
| 55 } | 60 } |
| 56 } | 61 } |
| 57 | 62 |
| 58 log(String message) => compiler.log('[DartBackend] $message'); | 63 log(String message) => compiler.log('[DartBackend] $message'); |
| 59 } | 64 } |
| OLD | NEW |