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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library js; 5 library js;
6 6
7 import 'package:js_ast/js_ast.dart'; 7 import 'package:js_ast/js_ast.dart';
8 export 'package:js_ast/js_ast.dart'; 8 export 'package:js_ast/js_ast.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 } 156 }
157 } 157 }
158 _cachedLiteral = js.escapedString(text); 158 _cachedLiteral = js.escapedString(text);
159 } 159 }
160 return _cachedLiteral; 160 return _cachedLiteral;
161 } 161 }
162 162
163 @override 163 @override
164 String get value => _literal.value; 164 String get value => _literal.value;
165 } 165 }
166
167 /// Returns `true` if [template] will immediately give a TypeError if the first
168 /// placeholder is `null` or `undefined`.
169 bool isNullGuardOnFirstArgument(Template template) {
170 // We look for a template of the form
171 //
172 // #.something
173 // #.something()
174 //
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.
175 Node node = template.ast;
176 if (node is Call) {
177 Call call = node;
178 node = node.target;
179 }
180 if (node is PropertyAccess) {
181 PropertyAccess access = node;
182 if (access.receiver is InterpolatedExpression) {
183 InterpolatedExpression hole = access.receiver;
184 return hole.isPositional && hole.nameOrPosition == 0;
185 }
186 }
187 return false;
188 }
OLDNEW
« 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