Browse Source

add stubbed Math built-in for BCC torturing

pull/9/head
Sami Vaarala 11 years ago
parent
commit
c889764db3
  1. 33
      src/duk_bi_math.c
  2. 6
      src/duk_features.h.in

33
src/duk_bi_math.c

@ -4,6 +4,8 @@
#include "duk_internal.h"
#if defined(DUK_USE_MATH_BUILTIN)
/*
* Use static helpers which can work with math.h functions matching
* the following signatures. This is not portable if any of these math
@ -248,3 +250,34 @@ duk_ret_t duk_bi_math_object_random(duk_context *ctx) {
duk_push_number(ctx, (duk_double_t) duk_util_tinyrandom_get_double((duk_hthread *) ctx));
return 1;
}
#else /* DUK_USE_MATH_BUILTIN */
/* A stubbed built-in is useful for e.g. compilation torture testing with BCC. */
duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx) {
DUK_UNREF(ctx);
return DUK_RET_UNIMPLEMENTED_ERROR;
}
duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx) {
DUK_UNREF(ctx);
return DUK_RET_UNIMPLEMENTED_ERROR;
}
duk_ret_t duk_bi_math_object_max(duk_context *ctx) {
DUK_UNREF(ctx);
return DUK_RET_UNIMPLEMENTED_ERROR;
}
duk_ret_t duk_bi_math_object_min(duk_context *ctx) {
DUK_UNREF(ctx);
return DUK_RET_UNIMPLEMENTED_ERROR;
}
duk_ret_t duk_bi_math_object_random(duk_context *ctx) {
DUK_UNREF(ctx);
return DUK_RET_UNIMPLEMENTED_ERROR;
}
#endif /* DUK_USE_MATH_BUILTIN */

6
src/duk_features.h.in

@ -1779,6 +1779,12 @@ typedef FILE duk_file;
* Ecmascript features / compliance options
*/
#if defined(DUK_F_BCC)
/* Math built-in is stubbed out on BCC to allow compiler torture testing. */
#else
#define DUK_USE_MATH_BUILTIN
#endif
#define DUK_USE_REGEXP_SUPPORT
#if defined(DUK_OPT_NO_REGEXP_SUPPORT)
#undef DUK_USE_REGEXP_SUPPORT

Loading…
Cancel
Save