[fasta] Allow --dump-ir to print error program

For instance, with the program snippet from issue #31409 one would not
get any other output than the errors, and one would have to explicitly
dump the dill file afterwards to see what was actually generated.

This CL changes this, so the error-library is also printed (in addition
to the, at least in the case of issue #31409, empty list) as in

```
$ pkg/front_end/tool/fasta compile tmp.dart --dump-ir

tmp.dart:2:4: Error: Expected a function body or '=>'.
Try adding {}.
V();
   ^
tmp.dart:3:5: Error: Duplicated definition of 'V'.
var V;
    ^
tmp.dart: Error: Duplicated name: 'V'.
tmp.dart:2:1: Error: Duplicated name: V
V();
^
library;
import self as self;

static method #main() → dynamic {
  throw "tmp.dart:2:1: Error: Duplicated name: V\nV();\n^";
}
```

Bug:
Change-Id: I8739be43137f098e6dc50df27f4d1d8628bea469
Reviewed-on: https://dart-review.googlesource.com/32602
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2018-01-09 11:19:56 +01:00 committed by commit-bot@chromium.org
parent 426d94785d
commit f72603ab45

View file

@ -342,6 +342,7 @@ class KernelTarget extends TargetImplementation {
(LocatedMessage message) => new ExpressionStatement(new Throw(
new StringLiteral(context.format(message, Severity.error)))))));
}
loader.libraries.add(library.library);
library.build(loader.coreLibrary);
return link(<Library>[library.library]);
}