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

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

Issue 10692073: Start emitting top-level functions. (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 25 matching lines...) Expand all
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 }
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