dart2js-kernel: Emit error trap for unimplemented features

The test will fail with an error like the following, rather than proceed with an incorrect null value.

R=efortuna@google.com

Review URL: https://codereview.chromium.org/2540363002 .

TypeError: Cannot read property 'Unhandled ir.FunctionExpression  (dynamic x) → dynamic => x' of null
This commit is contained in:
Stephen Adams 2016-11-30 16:52:07 -08:00
parent b8d3758dcd
commit ece7725d90

View file

@ -380,8 +380,17 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
@override
void defaultExpression(ir.Expression expression) {
// TODO(het): This is only to get tests working
stack.add(graph.addConstantNull(compiler));
// TODO(het): This is only to get tests working.
String message = 'Unhandled ir.${expression.runtimeType} $expression';
HInstruction nullValue = graph.addConstantNull(compiler);
HInstruction errorMessage =
graph.addConstantString(new DartString.literal(message), compiler);
HInstruction trap = new HForeignCode(
js.js.parseForeignJS("#.#"),
backend.dynamicType,
<HInstruction>[nullValue, errorMessage]);
trap.sideEffects..setAllSideEffects()..setDependsOnSomething();
push(trap);
}
/// Returns the current source element.