Browse Source

move #if 0 explicit comparison helpers into macros in case they're needed (they call the same helper anyway)

pull/2/head
Sami Vaarala 11 years ago
parent
commit
b429ed70ec
  1. 16
      src/duk_js.h
  2. 27
      src/duk_js_ops.c

16
src/duk_js.h

@ -48,6 +48,22 @@ duk_hstring *duk_js_typeof(duk_hthread *thr, duk_tval *tv_x);
#define duk_js_samevalue(tv_x,tv_y) \ #define duk_js_samevalue(tv_x,tv_y) \
duk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_SAMEVALUE) duk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_SAMEVALUE)
/* E5 Sections 11.8.1, 11.8.5; x < y */
#define duk_js_lessthan(thr,tv_x,tv_y) \
duk_js_compare_helper((thr), (tv_x), (tv_Y), 1, 0)
/* E5 Sections 11.8.2, 11.8.5; x > y --> y < x */
#define duk_js_greaterthan(thr,tv_x,tv_y) \
duk_js_compare_helper((thr), (tv_y), (tv_x), 0, 0)
/* E5 Sections 11.8.3, 11.8.5; x <= y --> not (x > y) --> not (y < x) */
#define duk_js_lessthanorequal(thr,tv_x,tv_y) \
duk_js_compare_helper((thr), (tv_y), (tv_x), 0, 1);
/* E5 Sections 11.8.4, 11.8.5; x >= y --> not (x < y) */
#define duk_js_greaterthanorequal(thr,tv_x,tv_y) \
duk_js_compare_helper((thr), (tv_x), (tv_y), 1, 1);
/* identifiers and environment handling */ /* identifiers and environment handling */
int duk_js_getvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name, int throw_flag); int duk_js_getvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name, int throw_flag);
int duk_js_getvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, int throw_flag); int duk_js_getvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, int throw_flag);

27
src/duk_js_ops.c

@ -897,33 +897,6 @@ int duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, int
return retval; return retval;
} }
/* FIXME: remove these? or make them macros? */
#if 0 /* unused */
/* E5 Sections 11.8.1, 11.8.5 */
int duk_js_lessthan(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) {
/* x < y */
return duk_js_compare_helper(thr, tv_x, tv_y, 1, 0);
}
/* E5 Sections 11.8.2, 11.8.5 */
int duk_js_greaterthan(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) {
/* x > y --> y < x */
return duk_js_compare_helper(thr, tv_y, tv_x, 0, 0);
}
/* E5 Sections 11.8.3, 11.8.5 */
int duk_js_lessthanorequal(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) {
/* x <= y --> not (x > y) --> not (y < x) */
return duk_js_compare_helper(thr, tv_y, tv_x, 0, 1);
}
/* E5 Sections 11.8.4, 11.8.5 */
int duk_js_greaterthanorequal(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) {
/* x >= y --> not (x < y) */
return duk_js_compare_helper(thr, tv_x, tv_y, 1, 1);
}
#endif
/* /*
* instanceof * instanceof
*/ */

Loading…
Cancel
Save