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

Side by Side Diff: pkg/compiler/lib/src/js/js.dart

Issue 1576063003: dart2js cps: Translate identity placeholders to refinement nodes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase again 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
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 _cachedLiteral = js.escapedString(text); 176 _cachedLiteral = js.escapedString(text);
177 } 177 }
178 return _cachedLiteral; 178 return _cachedLiteral;
179 } 179 }
180 180
181 @override 181 @override
182 String get value => _literal.value; 182 String get value => _literal.value;
183 } 183 }
184 184
185 /// True if the given template consists of just a placeholder. Such templates
186 /// are sometimes used to manually promote the type of an expression.
187 bool isIdentityTemplate(Template template) {
188 return template.ast is InterpolatedExpression;
189 }
190
185 /// Returns `true` if [template] will immediately give a TypeError if the first 191 /// Returns `true` if [template] will immediately give a TypeError if the first
186 /// placeholder is `null` or `undefined`. 192 /// placeholder is `null` or `undefined`.
187 bool isNullGuardOnFirstArgument(Template template) { 193 bool isNullGuardOnFirstArgument(Template template) {
188 // We look for a template of the form 194 // We look for a template of the form
189 // 195 //
190 // #.something 196 // #.something
191 // #.something() 197 // #.something()
192 // 198 //
193 Node node = template.ast; 199 Node node = template.ast;
194 if (node is Call) { 200 if (node is Call) {
195 Call call = node; 201 Call call = node;
196 node = call.target; 202 node = call.target;
197 } 203 }
198 if (node is PropertyAccess) { 204 if (node is PropertyAccess) {
199 PropertyAccess access = node; 205 PropertyAccess access = node;
200 if (access.receiver is InterpolatedExpression) { 206 if (access.receiver is InterpolatedExpression) {
201 InterpolatedExpression hole = access.receiver; 207 InterpolatedExpression hole = access.receiver;
202 return hole.isPositional && hole.nameOrPosition == 0; 208 return hole.isPositional && hole.nameOrPosition == 0;
203 } 209 }
204 } 210 }
205 return false; 211 return false;
206 } 212 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/finalize.dart ('k') | tests/compiler/dart2js/cps_ir/expected/operators2_3.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698