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

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

Issue 2301293002: kernel -> ssa: implement if-statements (Closed)
Patch Set: add visitNot 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 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));
}
}
« 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