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 2e107bce7a3590aebbe5283701a917279120c803..346a168633157cdb220b3e81029ef0750b33489a 100644 |
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
@@ -21,6 +21,7 @@ import 'graph_builder.dart'; |
import 'kernel_ast_adapter.dart'; |
import 'locals_handler.dart'; |
import 'nodes.dart'; |
+import 'ssa_branch_builder.dart'; |
class SsaKernelBuilderTask extends CompilerTask { |
final JavaScriptBackend backend; |
@@ -67,7 +68,6 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
JavaScriptBackend get backend => compiler.backend; |
- LocalsHandler localsHandler; |
SourceInformationBuilder sourceInformationBuilder; |
KernelAstAdapter astAdapter; |
@@ -113,6 +113,23 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
return graph; |
} |
+ @override |
+ HInstruction popBoolified() { |
+ HInstruction value = pop(); |
+ // TODO(het): add boolean conversion type check |
+ HInstruction result = new HBoolify(value, backend.boolType); |
+ add(result); |
+ return result; |
+ } |
+ |
+ // TODO(het): This implementation is shared with [SsaBuilder]. Should we just |
+ // allow [GraphBuilder] to access `compiler`? |
+ @override |
+ pushCheckNull(HInstruction expression) { |
+ push(new HIdentity( |
+ expression, graph.addConstantNull(compiler), null, backend.boolType)); |
+ } |
+ |
/// Builds a SSA graph for [method]. |
void buildMethod(IrFunction method, FunctionElement functionElement) { |
openFunction(method, functionElement); |
@@ -156,6 +173,12 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
} |
@override |
+ visitExpressionStatement(ir.ExpressionStatement exprStatement) { |
+ exprStatement.expression.accept(this); |
+ pop(); |
+ } |
+ |
+ @override |
void visitReturnStatement(ir.ReturnStatement returnStatement) { |
HInstruction value; |
if (returnStatement.expression == null) { |
@@ -172,6 +195,15 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
} |
@override |
+ void visitIfStatement(ir.IfStatement ifStatement) { |
+ SsaBranchBuilder branchBuilder = new SsaBranchBuilder(this, compiler); |
+ branchBuilder.handleIf( |
+ () => ifStatement.condition.accept(this), |
+ () => ifStatement.then.accept(this), |
+ () => ifStatement.otherwise?.accept(this)); |
+ } |
+ |
+ @override |
void visitIntLiteral(ir.IntLiteral intLiteral) { |
stack.add(graph.addConstantInt(intLiteral.value, compiler)); |
} |
@@ -275,8 +307,8 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
} |
@override |
- visitExpressionStatement(ir.ExpressionStatement exprStatement) { |
- exprStatement.expression.accept(this); |
- pop(); |
+ visitNot(ir.Not not) { |
+ not.operand.accept(this); |
+ push(new HNot(popBoolified(), backend.boolType)); |
} |
} |