Chromium Code Reviews| Index: lib/compiler/implementation/dart_backend/backend.dart |
| diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart |
| index 45f0db10473e61a9ac9e52607baf8fade64fcd51..7b26f8fd14855d300def730cb09436b153588056 100644 |
| --- a/lib/compiler/implementation/dart_backend/backend.dart |
| +++ b/lib/compiler/implementation/dart_backend/backend.dart |
| @@ -2,6 +2,12 @@ |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| +class BailoutException { |
| + final String reason; |
| + |
| + const BailoutException(this.reason); |
| +} |
| + |
| class DartBackend extends Backend { |
| final List<CompilerTask> tasks; |
| final UnparseValidator unparseValidator; |
| @@ -30,7 +36,23 @@ class DartBackend extends Backend { |
| resolvedElements.forEach((element, treeElements) { |
| unparseValidator.check(element); |
| }); |
| - compiler.assembledCode = ''; |
| + |
| + // 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.
|
| + 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.
|
| + 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
|
| + } |
| + |
| + try { |
| + resolvedElements.forEach((element, treeElements) { |
| + bailout('I can do nothing right now.'); |
| + }); |
| + } catch (BailoutException e) { |
| + compiler.assembledCode = ''' |
| +main() { |
| + 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
|
| +} |
| +'''; |
| + } |
| } |
| log(String message) => compiler.log('[DartBackend] $message'); |