Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 } | |
| OLD | NEW |