Index: pkg/compiler/lib/src/ssa/builder_kernel.dart |
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
index a309e3911e9bcdfa4f59b3942ccca4d25a70a8b8..bb19a1edba9cee65422d8a149a43a117afa5b8f5 100644 |
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
@@ -108,7 +108,11 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
void buildField(ir.Field field) { |
openFunction(); |
- field.initializer.accept(this); |
+ if (field.initializer != null) { |
+ field.initializer.accept(this); |
+ } else { |
+ stack.add(graph.addConstantNull(compiler)); |
+ } |
HInstruction value = pop(); |
closeAndGotoExit(new HReturn(value, null)); |
closeFunction(); |
@@ -420,6 +424,36 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
} |
@override |
+ void visitAssertStatement(ir.AssertStatement assertStatement) { |
+ if (!compiler.options.enableUserAssertions) return; |
+ if (assertStatement.message == null) { |
+ assertStatement.condition.accept(this); |
+ // TODO(het): should these be desugared in a kernel transformation? |
Siggi Cherem (dart-lang)
2016/09/29 15:36:52
maybe - but I think it's possible that we could us
Harry Terkelsen
2016/09/29 21:16:21
Removed TODO after our team meeting discussing thi
|
+ _pushStaticInvocation(astAdapter.assertHelper, <HInstruction>[pop()], |
+ astAdapter.assertHelperReturnType); |
+ pop(); |
+ return; |
+ } |
+ |
+ // if (assertTest(condition)) assertThrow(message); |
+ void buildCondition() { |
+ assertStatement.condition.accept(this); |
+ _pushStaticInvocation(astAdapter.assertTest, <HInstruction>[pop()], |
+ astAdapter.assertTestReturnType); |
+ } |
+ |
+ void fail() { |
+ assertStatement.message.accept(this); |
+ _pushStaticInvocation(astAdapter.assertThrow, <HInstruction>[pop()], |
+ astAdapter.assertThrowReturnType); |
+ pop(); |
+ } |
+ |
+ SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); |
+ brancher.handleIf(buildCondition, fail, null); |
Siggi Cherem (dart-lang)
2016/09/29 15:36:52
suggestion for later: it seems we always do:
Ss
Harry Terkelsen
2016/09/29 21:16:21
Good idea. I moved these to graph_builder
|
+ } |
+ |
+ @override |
void visitConditionalExpression(ir.ConditionalExpression conditional) { |
SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler); |
brancher.handleConditional( |