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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_rti.dart

Issue 1180973003: dart2js cps: Support function types in 'is' and 'as' operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update doc comment for TypeCast Created 5 years, 6 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/ssa/builder.dart ('k') | tests/co19/co19-dart2js.status » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /** 5 /**
6 * This part contains helpers for supporting runtime type information. 6 * This part contains helpers for supporting runtime type information.
7 * 7 *
8 * The helper use a mixture of Dart and JavaScript objects. To indicate which is 8 * The helper use a mixture of Dart and JavaScript objects. To indicate which is
9 * used where we adopt the scheme of using explicit type annotation for Dart 9 * used where we adopt the scheme of using explicit type annotation for Dart
10 * objects and 'var' or omitted return type for JavaScript objects. 10 * objects and 'var' or omitted return type for JavaScript objects.
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 var rti = getRuntimeTypeInfo(o); 382 var rti = getRuntimeTypeInfo(o);
383 o = getInterceptor(o); 383 o = getInterceptor(o);
384 var type = getRawRuntimeType(o); 384 var type = getRawRuntimeType(o);
385 if (rti != null) { 385 if (rti != null) {
386 // If the type has type variables (that is, `rti != null`), make a copy of 386 // If the type has type variables (that is, `rti != null`), make a copy of
387 // the type arguments and insert [o] in the first position to create a 387 // the type arguments and insert [o] in the first position to create a
388 // compound type representation. 388 // compound type representation.
389 rti = JS('JSExtendableArray', '#.slice()', rti); // Make a copy. 389 rti = JS('JSExtendableArray', '#.slice()', rti); // Make a copy.
390 JS('', '#.splice(0, 0, #)', rti, type); // Insert type at position 0. 390 JS('', '#.splice(0, 0, #)', rti, type); // Insert type at position 0.
391 type = rti; 391 type = rti;
392 } else if (isDartFunctionType(t)) { 392 }
393 if (isDartFunctionType(t)) {
393 // Functions are treated specially and have their type information stored 394 // Functions are treated specially and have their type information stored
394 // directly in the instance. 395 // directly in the instance.
395 var targetSignatureFunction = 396 var targetSignatureFunction =
396 getField(o, '${JS_GET_NAME(JsGetName.SIGNATURE_NAME)}'); 397 getField(o, '${JS_GET_NAME(JsGetName.SIGNATURE_NAME)}');
397 if (targetSignatureFunction == null) return false; 398 if (targetSignatureFunction == null) return false;
398 type = invokeOn(targetSignatureFunction, o, null); 399 type = invokeOn(targetSignatureFunction, o, null);
399 return isFunctionSubtype(type, t); 400 return isFunctionSubtype(type, t);
400 } 401 }
401 return isSubtype(type, t); 402 return isSubtype(type, t);
402 } 403 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 * `null` and `undefined` (which we can avoid). 672 * `null` and `undefined` (which we can avoid).
672 */ 673 */
673 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); 674 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t);
674 675
675 /** 676 /**
676 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use 677 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use
677 * this helper instead of [identical] because `identical` needs to merge 678 * this helper instead of [identical] because `identical` needs to merge
678 * `null` and `undefined` (which we can avoid). 679 * `null` and `undefined` (which we can avoid).
679 */ 680 */
680 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); 681 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t);
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698