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

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

Issue 12042003: Move relational operators to the new interceptors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (revision 17334)
+++ sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (working copy)
@@ -12,116 +12,10 @@
part 'regexp_helper.dart';
part 'string_helper.dart';
-// Performance critical helper methods.
-gt(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# > #', a, b)
- : gt$slow(a, b);
-
-ge(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# >= #', a, b)
- : ge$slow(a, b);
-
-lt(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# < #', a, b)
- : lt$slow(a, b);
-
-le(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# <= #', a, b)
- : le$slow(a, b);
-
-gtB(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# > #', a, b)
- : identical(gt$slow(a, b), true);
-
-geB(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# >= #', a, b)
- : identical(ge$slow(a, b), true);
-
-ltB(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# < #', a, b)
- : identical(lt$slow(a, b), true);
-
-leB(var a, var b) => (a is num && b is num)
- ? JS('bool', r'# <= #', a, b)
- : identical(le$slow(a, b), true);
-
-/**
- * Returns true if both arguments are numbers.
- *
- * If only the first argument is a number, an
- * [ArgumentError] with the other argument is thrown.
- */
-bool checkNumbers(var a, var b) {
- if (a is num) {
- if (b is num) {
- return true;
- } else {
- throw new ArgumentError(b);
- }
- }
- return false;
-}
-
bool isJsArray(var value) {
return value != null && JS('bool', r'#.constructor === Array', value);
}
-eq(var a, var b) {
- if (JS('bool', r'# == null', a)) return JS('bool', r'# == null', b);
- if (JS('bool', r'# == null', b)) return false;
- if (JS('bool', r'typeof # === "object"', a)) {
- if (JS_HAS_EQUALS(a)) {
- return UNINTERCEPTED(a == b);
- }
- }
- // TODO(lrn): is NaN === NaN ? Is -0.0 === 0.0 ?
- return JS('bool', r'# === #', a, b);
-}
-
-bool eqB(var a, var b) {
- if (JS('bool', r'# == null', a)) return JS('bool', r'# == null', b);
- if (JS('bool', r'# == null', b)) return false;
- if (JS('bool', r'typeof # === "object"', a)) {
- if (JS_HAS_EQUALS(a)) {
- return identical(UNINTERCEPTED(a == b), true);
- }
- }
- // TODO(lrn): is NaN === NaN ? Is -0.0 === 0.0 ?
- return JS('bool', r'# === #', a, b);
-}
-
-eqq(var a, var b) {
- return JS('bool', r'# === #', a, b);
-}
-
-gt$slow(var a, var b) {
- if (checkNumbers(a, b)) {
- return JS('bool', r'# > #', a, b);
- }
- return UNINTERCEPTED(a > b);
-}
-
-ge$slow(var a, var b) {
- if (checkNumbers(a, b)) {
- return JS('bool', r'# >= #', a, b);
- }
- return UNINTERCEPTED(a >= b);
-}
-
-lt$slow(var a, var b) {
- if (checkNumbers(a, b)) {
- return JS('bool', r'# < #', a, b);
- }
- return UNINTERCEPTED(a < b);
-}
-
-le$slow(var a, var b) {
- if (checkNumbers(a, b)) {
- return JS('bool', r'# <= #', a, b);
- }
- return UNINTERCEPTED(a <= b);
-}
-
checkMutable(list, reason) {
if (JS('bool', r'!!(#.immutable$list)', list)) {
throw new UnsupportedError(reason);
@@ -1572,9 +1466,9 @@
*/
bool isSubtype(var s, var t) {
// If either type is dynamic, [s] is a subtype of [t].
- if (s == null || t == null) return true;
+ if (JS('bool', '# == null', s) || JS('bool', '# == null', t)) return true;
// Subtyping is reflexive.
- if (s == t) return true;
+ if (JS('bool', '# === #', s, t)) return true;
// Get the object describing the class and check for the subtyping flag
// constructed from the type of [t].
var typeOfS = isJsArray(s) ? s[0] : s;

Powered by Google App Engine
This is Rietveld 408576698