Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10702114: dart2dart: fix top level field declarations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 sb.add(element.parseNode(compiler).unparse());
Anton Muhin 2012/07/06 13:55:48 do we want to resort to node unparse? It might be
Roman 2012/07/09 12:26:00 Done.
65 sb.add(';');
66 } else {
67 sb.add(element.parseNode(compiler).unparse());
68 }
52 }); 69 });
53 compiler.assembledCode = sb.toString(); 70 compiler.assembledCode = sb.toString();
54 } catch (BailoutException e) { 71 } catch (BailoutException e) {
55 compiler.assembledCode = ''' 72 compiler.assembledCode = '''
56 main() { 73 main() {
57 final bailout_reason = "${e.reason}"; 74 final bailout_reason = "${e.reason}";
58 } 75 }
59 '''; 76 ''';
60 } 77 }
61 } 78 }
62 79
63 log(String message) => compiler.log('[DartBackend] $message'); 80 log(String message) => compiler.log('[DartBackend] $message');
64 } 81 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698