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

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

Issue 10662055: Add bailouts to dart backend. (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 {
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.
ahe 2012/06/27 10:52:33 Not a proper sentence (eventually -> Eventually).
Anton Muhin 2012/06/27 15:59:46 Done.
41 bailout(String reason) {
ahe 2012/06/27 10:52:33 Type on argument, so please provide a return type.
Anton Muhin 2012/06/27 15:59:46 Done.
42 throw new BailoutException(reason);
ahe 2012/06/27 10:52:33 Our experience from the type checker is that throw
Anton Muhin 2012/06/27 15:59:46 Thanks a lot for a tip. I'll leave it for now as
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 bailout_reason = "${e.reason}";
ahe 2012/06/27 10:52:33 You should escape " and \
Anton Muhin 2012/06/27 15:59:46 Sorry, why?
ahe 2012/06/27 20:34:08 What if e.reason is: 'cannot find "foo"' On 2012/
Anton Muhin 2012/06/28 14:19:05 Yes, that may happen, but I hope bailouts will go
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 }
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