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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1507313006: dart2js cps: Add instruction for null checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix true/false misdocumentation about condition and do not emit call Created 5 years 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
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index 8bb26fd773bd3439b8db3e8c9a99466e54209db6..9efbc4b6eb1953beeda5332784bfbbd5c2cde02d 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -945,6 +945,24 @@ class CodeGenerator extends tree_ir.StatementVisitor
}
@override
+ void visitNullCheck(tree_ir.NullCheck node) {
+ js.Expression value = visitExpression(node.value);
+ js.Expression access = node.selector != null
+ ? js.js('#.#', [value, glue.invocationName(node.selector)])
+ : js.js('#.toString', [value]);
+ if (node.condition != null) {
+ js.Expression condition = visitExpression(node.condition);
+ js.Statement body = isNullReturn(node.next)
+ ? new js.ExpressionStatement(access)
+ : new js.Return(access);
+ accumulator.add(new js.If.noElse(condition, body));
+ } else {
+ accumulator.add(new js.ExpressionStatement(access));
+ }
+ visitStatement(node.next);
+ }
+
+ @override
js.Expression visitApplyBuiltinOperator(tree_ir.ApplyBuiltinOperator node) {
List<js.Expression> args = visitExpressionList(node.arguments);
switch (node.operator) {

Powered by Google App Engine
This is Rietveld 408576698