| 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 30 matching lines...) Expand all Loading... |
| 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 StringBuffer sb = new StringBuffer(); |
| 47 resolvedElements.forEach((element, treeElements) { | 47 resolvedElements.forEach((element, treeElements) { |
| 48 if (!element.isTopLevel()) { | 48 if (!element.isTopLevel()) { |
| 49 bailout('Cannot process non top-level $element'); | 49 bailout('Cannot process non top-level $element'); |
| 50 } | 50 } |
| 51 sb.add(element.parseNode(compiler).unparse()); | 51 |
| 52 if (element.isField()) { |
| 53 // Add modifiers first. |
| 54 sb.add(element.modifiers.toString()); |
| 55 sb.add(' '); |
| 56 // Figure out type. |
| 57 if (element is VariableElement) { |
| 58 VariableListElement variables = element.variables; |
| 59 if (variables.type !== null) { |
| 60 sb.add(variables.type); |
| 61 sb.add(' '); |
| 62 } |
| 63 } |
| 64 // TODO(smok): Maybe not rely on node unparsing, |
| 65 // but unparse initializer manually. |
| 66 sb.add(element.parseNode(compiler).unparse()); |
| 67 sb.add(';'); |
| 68 } else { |
| 69 sb.add(element.parseNode(compiler).unparse()); |
| 70 } |
| 52 }); | 71 }); |
| 53 compiler.assembledCode = sb.toString(); | 72 compiler.assembledCode = sb.toString(); |
| 54 } catch (BailoutException e) { | 73 } catch (BailoutException e) { |
| 55 compiler.assembledCode = ''' | 74 compiler.assembledCode = ''' |
| 56 main() { | 75 main() { |
| 57 final bailout_reason = "${e.reason}"; | 76 final bailout_reason = "${e.reason}"; |
| 58 } | 77 } |
| 59 '''; | 78 '''; |
| 60 } | 79 } |
| 61 } | 80 } |
| 62 | 81 |
| 63 log(String message) => compiler.log('[DartBackend] $message'); | 82 log(String message) => compiler.log('[DartBackend] $message'); |
| 64 } | 83 } |
| OLD | NEW |