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

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

Issue 2380573004: kernel->ssa: implement assert statements (Closed)
Patch Set: remove todo after discussion 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/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.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..4665ee8a0ee8ef4ed4813bb152f1e7ecfd90b810 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();
@@ -412,11 +416,38 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
@override
void visitIfStatement(ir.IfStatement ifStatement) {
- SsaBranchBuilder brancher = new SsaBranchBuilder(this, compiler);
- brancher.handleIf(
- () => ifStatement.condition.accept(this),
- () => ifStatement.then.accept(this),
- () => ifStatement.otherwise?.accept(this));
+ handleIf(
+ visitCondition: () => ifStatement.condition.accept(this),
+ visitThen: () => ifStatement.then.accept(this),
+ visitElse: () => ifStatement.otherwise?.accept(this));
+ }
+
+ @override
+ void visitAssertStatement(ir.AssertStatement assertStatement) {
+ if (!compiler.options.enableUserAssertions) return;
+ if (assertStatement.message == null) {
+ assertStatement.condition.accept(this);
+ _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();
+ }
+
+ handleIf(visitCondition: buildCondition, visitThen: fail);
}
@override
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698