Fasta: Change BodyBuilder.buildCompileTimeError to throw an instance of _CompileTimeError.

This is a VM specific class that is recognized by exception handling code in VM.

Using this class instead of string guarantees that VM terminates with the correct exit code: kCompilationErrorExitCode (254) and not kErrorExitCode (255).

BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2689543002 .
This commit is contained in:
Vyacheslav Egorov
2017-02-09 17:13:47 +01:00
parent a191011c03
commit 5e09ca8d97
@@ -2186,7 +2186,13 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
Expression buildCompileTimeError(error, [int charOffset = -1]) {
String message = new InputError(uri, charOffset, error).format();
print(message);
return new Throw(new StringLiteral(message));
// TODO(ahe): Use a method on TargetImplementation for looking up the
// constructor.
final Constructor constructor = coreTypes.getCoreClass(
"dart:core", "_CompileTimeError").constructors.first;
return new Throw(new ConstructorInvocation(
constructor,
new Arguments(<Expression>[new StringLiteral(message)])));
}
Statement buildCompileTimeErrorStatement(error, [int charOffset = -1]) {