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

Unified Diff: pkg/compiler/lib/src/js/js.dart

Issue 1567103006: Null check remover understands JS fragments. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/cps_ir/cps_ir_nodes.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/js.dart
diff --git a/pkg/compiler/lib/src/js/js.dart b/pkg/compiler/lib/src/js/js.dart
index 1a08cfbeb0798072ea178fd3993b134183c5c718..7cf2873ff03f4527d5e5e19a05265a3303744ade 100644
--- a/pkg/compiler/lib/src/js/js.dart
+++ b/pkg/compiler/lib/src/js/js.dart
@@ -162,4 +162,27 @@ class UnparsedNode extends DeferredString
@override
String get value => _literal.value;
-}
+}
+
+/// Returns `true` if [template] will immediately give a TypeError if the first
+/// placeholder is `null` or `undefined`.
+bool isNullGuardOnFirstArgument(Template template) {
+ // We look for a template of the form
+ //
+ // #.something
+ // #.something()
+ //
asgerf 2016/01/11 16:28:25 Would be it be worthwhile to unfold all the way to
sra1 2016/01/11 19:25:27 I will see if it makes a difference.
+ Node node = template.ast;
+ if (node is Call) {
+ Call call = node;
+ node = node.target;
+ }
+ if (node is PropertyAccess) {
+ PropertyAccess access = node;
+ if (access.receiver is InterpolatedExpression) {
+ InterpolatedExpression hole = access.receiver;
+ return hole.isPositional && hole.nameOrPosition == 0;
+ }
+ }
+ return false;
+}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698