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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10916172: num implements Comparable and Hashable. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « lib/compiler/implementation/js_backend/backend.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
===================================================================
--- lib/compiler/implementation/lib/js_helper.dart (revision 12035)
+++ lib/compiler/implementation/lib/js_helper.dart (working copy)
@@ -1113,6 +1113,40 @@
}
/**
+ * Specialization of the type check for num and String and their
+ * supertype since [value] can be a JS primitive.
+ */
+numberOrStringSuperTypeCheck(value, property) {
+ if (value === null) return value;
+ if (value is String) return value;
+ if (value is num) return value;
+ if (JS('bool', '!!#[#]', value, property)) return value;
+ propertyTypeError(value, property);
+}
+
+numberOrStringSuperTypeCast(value, property) {
+ if (value is String) return value;
+ if (value is num) return value;
+ return propertyTypeCast(value, property);
+}
+
+numberOrStringSuperNativeTypeCheck(value, property) {
+ if (value === null) return value;
+ if (value is String) return value;
+ if (value is num) return value;
+ if (JS('bool', '#[#]()', value, property)) return value;
+ propertyTypeError(value, property);
+}
+
+numberOrStringSuperNativeTypeCast(value, property) {
+ if (value === null) return value;
+ if (value is String) return value;
+ if (value is num) return value;
+ if (JS('bool', '#[#]()', value, property)) return value;
+ propertyTypeCastError(value, property);
+}
+
+/**
* Specialization of the type check for String and its supertype
* since [value] can be a JS primitive.
*/
« no previous file with comments | « lib/compiler/implementation/js_backend/backend.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698