Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2380573004: kernel->ssa: implement assert statements (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/options.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « pkg/compiler/lib/src/options.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698