Browse Source

Implement DUK_OPT_NO_STRICT_DECL

pull/92/head
Sami Vaarala 10 years ago
parent
commit
4453356fa3
  1. 5
      src/duk_features.h.in
  2. 8
      src/duk_js_compiler.c

5
src/duk_features.h.in

@ -2260,6 +2260,11 @@ typedef FILE duk_file;
#define DUK_USE_MATH_BUILTIN
#endif
#define DUK_USE_STRICT_DECL
#if defined(DUK_OPT_NO_STRICT_DECL)
#undef DUK_USE_STRICT_DECL
#endif
#define DUK_USE_REGEXP_SUPPORT
#if defined(DUK_OPT_NO_REGEXP_SUPPORT)
#undef DUK_USE_REGEXP_SUPPORT

8
src/duk_js_compiler.c

@ -6172,18 +6172,20 @@ DUK_LOCAL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_
DUK_DDD(DUK_DDDPRINT("directive contains escapes: valid directive "
"but we ignore such directives"));
} else {
/* XXX: how to compare 'use strict' most compactly?
* We don't necessarily want to add it to the built-ins
* because it's not needed at run time.
/*
* The length comparisons are present to handle
* strings like "use strict\u0000foo" as required.
*/
if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 &&
DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) {
#if defined(DUK_USE_STRICT_DECL)
DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld",
(long) comp_ctx->curr_func.is_strict, (long) 1));
comp_ctx->curr_func.is_strict = 1;
#else
DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring"));
#endif
} else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 &&
DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) {
DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld",

Loading…
Cancel
Save