From 250521a747980a9f987a6b69401a214af769838e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Sun, 12 Jan 2025 10:55:25 +0100 Subject: [PATCH] Use stdbool rather than custom booleans Fixes: https://github.com/quickjs-ng/quickjs/issues/817 --- cutils.c | 6 +- cutils.h | 22 +- dirent_compat.h | 4 +- gen/function_source.c | 6 +- gen/hello.c | 4 +- gen/hello_module.c | 10 +- gen/repl.c | 2 +- gen/standalone.c | 2 +- gen/test_fib.c | 4 +- libbf.c | 110 +- libregexp.c | 120 +-- libregexp.h | 11 +- libunicode.c | 34 +- libunicode.h | 21 +- qjs.c | 10 +- qjsc.c | 6 +- quickjs-libc.c | 86 +- quickjs-libc.h | 5 +- quickjs.c | 2266 +++++++++++++++++++++-------------------- quickjs.h | 95 +- run-test262.c | 88 +- unicode_gen.c | 50 +- 22 files changed, 1475 insertions(+), 1487 deletions(-) diff --git a/cutils.c b/cutils.c index 8dc27dd4..21265ea4 100644 --- a/cutils.c +++ b/cutils.c @@ -125,7 +125,7 @@ int dbuf_realloc(DynBuf *s, size_t new_size) new_size = size; new_buf = s->realloc_func(s->opaque, s->buf, new_size); if (!new_buf) { - s->error = TRUE; + s->error = true; return -1; } s->buf = new_buf; @@ -1209,12 +1209,12 @@ typedef struct { js__once_cb callback; } js__once_data_t; -static BOOL WINAPI js__once_inner(INIT_ONCE *once, void *param, void **context) { +static int WINAPI js__once_inner(INIT_ONCE *once, void *param, void **context) { js__once_data_t *data = param; data->callback(); - return TRUE; + return 1; } void js_once(js_once_t *guard, js__once_cb callback) { diff --git a/cutils.h b/cutils.h index 18e6dc5f..527ba1cb 100644 --- a/cutils.h +++ b/cutils.h @@ -25,6 +25,7 @@ #ifndef CUTILS_H #define CUTILS_H +#include #include #include #include @@ -112,15 +113,6 @@ extern "C" { #define minimum_length(n) static n #endif -typedef int BOOL; - -#ifndef FALSE -enum { - FALSE = 0, - TRUE = 1, -}; -#endif - void js__pstrcpy(char *buf, int buf_size, const char *str); char *js__pstrcat(char *buf, int buf_size, const char *s); int js__strstart(const char *str, const char *val, const char **ptr); @@ -428,7 +420,7 @@ typedef struct DynBuf { uint8_t *buf; size_t size; size_t allocated_size; - BOOL error; /* true if a memory allocation error occurred */ + bool error; /* true if a memory allocation error occurred */ DynBufReallocFunc *realloc_func; void *opaque; /* for realloc_func */ } DynBuf; @@ -456,12 +448,12 @@ static inline int dbuf_put_u64(DynBuf *s, uint64_t val) int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s, FORMAT_STRING(const char *fmt), ...); void dbuf_free(DynBuf *s); -static inline BOOL dbuf_error(DynBuf *s) { +static inline bool dbuf_error(DynBuf *s) { return s->error; } static inline void dbuf_set_error(DynBuf *s) { - s->error = TRUE; + s->error = true; } /*---- UTF-8 and UTF-16 handling ----*/ @@ -485,17 +477,17 @@ size_t utf8_decode_buf16(uint16_t *dest, size_t dest_len, const char *src, size_ size_t utf8_encode_buf8(char *dest, size_t dest_len, const uint8_t *src, size_t src_len); size_t utf8_encode_buf16(char *dest, size_t dest_len, const uint16_t *src, size_t src_len); -static inline BOOL is_surrogate(uint32_t c) +static inline bool is_surrogate(uint32_t c) { return (c >> 11) == (0xD800 >> 11); // 0xD800-0xDFFF } -static inline BOOL is_hi_surrogate(uint32_t c) +static inline bool is_hi_surrogate(uint32_t c) { return (c >> 10) == (0xD800 >> 10); // 0xD800-0xDBFF } -static inline BOOL is_lo_surrogate(uint32_t c) +static inline bool is_lo_surrogate(uint32_t c) { return (c >> 10) == (0xDC00 >> 10); // 0xDC00-0xDFFF } diff --git a/dirent_compat.h b/dirent_compat.h index 077674e4..1d6c4802 100644 --- a/dirent_compat.h +++ b/dirent_compat.h @@ -656,7 +656,7 @@ dirent_next( } else if (dirp->handle != INVALID_HANDLE_VALUE) { /* Get the next directory entry from stream */ - if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) { + if (FindNextFileW (dirp->handle, &dirp->data) != 0) { /* Got a file */ p = &dirp->data; } else { @@ -1163,4 +1163,4 @@ dirent_set_errno( #ifdef __cplusplus } #endif -#endif /*DIRENT_H*/ \ No newline at end of file +#endif /*DIRENT_H*/ diff --git a/gen/function_source.c b/gen/function_source.c index 00b9aab1..306739df 100644 --- a/gen/function_source.c +++ b/gen/function_source.c @@ -5,7 +5,7 @@ const uint32_t qjsc_function_source_size = 320; const uint8_t qjsc_function_source[320] = { - 0x13, 0x05, 0x01, 0x30, 0x74, 0x65, 0x73, 0x74, + 0x14, 0x05, 0x01, 0x30, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x6a, 0x73, 0x01, 0x0c, 0x61, 0x63, @@ -15,13 +15,13 @@ const uint8_t qjsc_function_source[320] = { 0x6e, 0x20, 0x66, 0x28, 0x29, 0x20, 0x7b, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x34, 0x32, 0x20, 0x7d, 0x0d, 0xc0, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0c, 0x20, 0xfa, 0x01, 0xa2, + 0x00, 0x00, 0x00, 0x0c, 0x20, 0x0a, 0x01, 0xa2, 0x01, 0x00, 0x05, 0x00, 0x03, 0x02, 0x01, 0x74, 0x05, 0xc2, 0x03, 0x02, 0x00, 0x30, 0xc4, 0x03, 0x04, 0x00, 0x70, 0xc2, 0x03, 0x04, 0x02, 0x70, 0x10, 0x00, 0x01, 0x00, 0xe4, 0x01, 0x00, 0x01, 0x00, 0xc6, 0x03, 0x00, 0x0d, 0xc4, 0x03, 0x01, - 0x01, 0x0c, 0x43, 0xfa, 0x01, 0xc4, 0x03, 0x00, + 0x01, 0x0c, 0x43, 0x0a, 0x01, 0xc4, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0xbd, 0x2a, 0x28, 0xc0, 0x03, 0x03, 0x01, 0x00, 0x1a, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, diff --git a/gen/hello.c b/gen/hello.c index e68d3c7c..8c3492eb 100644 --- a/gen/hello.c +++ b/gen/hello.c @@ -5,14 +5,14 @@ const uint32_t qjsc_hello_size = 103; const uint8_t qjsc_hello[103] = { - 0x13, 0x04, 0x01, 0x22, 0x65, 0x78, 0x61, 0x6d, + 0x14, 0x04, 0x01, 0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x6a, 0x73, 0x01, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x01, 0x06, 0x6c, 0x6f, 0x67, 0x01, 0x16, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x0d, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x20, 0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00, + 0x0c, 0x20, 0x0a, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x19, 0x00, 0x08, 0xeb, 0x02, 0x29, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x43, 0xe2, 0x00, 0x00, 0x00, 0x04, 0xe3, 0x00, 0x00, diff --git a/gen/hello_module.c b/gen/hello_module.c index 31987a57..a9268567 100644 --- a/gen/hello_module.c +++ b/gen/hello_module.c @@ -5,15 +5,15 @@ const uint32_t qjsc_fib_module_size = 290; const uint8_t qjsc_fib_module[290] = { - 0x13, 0x03, 0x01, 0x2c, 0x65, 0x78, 0x61, 0x6d, + 0x14, 0x03, 0x01, 0x2c, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x62, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x6a, 0x73, 0x01, 0x06, 0x66, 0x69, 0x62, 0x01, 0x02, 0x6e, 0x0d, 0xc0, 0x03, 0x00, 0x01, 0x00, 0x00, 0xc2, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x20, - 0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09, 0x00, 0xc2, 0x03, 0x00, 0x01, - 0x0c, 0x43, 0xfa, 0x01, 0xc2, 0x03, 0x01, 0x00, + 0x0c, 0x43, 0x0a, 0x01, 0xc2, 0x03, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x1a, 0x01, 0xc4, 0x03, 0x00, 0x01, 0x00, 0xc2, 0x03, 0x00, 0x00, 0xd2, 0xb5, 0xa8, 0xeb, 0x03, 0xb5, 0x28, 0xd2, 0xb6, @@ -47,7 +47,7 @@ const uint8_t qjsc_fib_module[290] = { const uint32_t qjsc_hello_module_size = 187; const uint8_t qjsc_hello_module[187] = { - 0x13, 0x07, 0x01, 0x30, 0x65, 0x78, 0x61, 0x6d, + 0x14, 0x07, 0x01, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x6a, 0x73, 0x01, 0x1e, 0x2e, 0x2f, @@ -59,7 +59,7 @@ const uint8_t qjsc_hello_module[187] = { 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x10, 0x66, 0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d, 0xc0, 0x03, 0x01, 0xc2, 0x03, 0x00, 0x00, 0x01, - 0x00, 0xc4, 0x03, 0x00, 0x00, 0x0c, 0x20, 0xfa, + 0x00, 0xc4, 0x03, 0x00, 0x00, 0x0c, 0x20, 0x0a, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x32, 0x00, 0xc4, 0x03, 0x00, 0x0c, 0x08, 0xeb, 0x02, 0x29, 0x39, 0xe3, 0x00, 0x00, 0x00, diff --git a/gen/repl.c b/gen/repl.c index b79df848..841bb872 100644 --- a/gen/repl.c +++ b/gen/repl.c @@ -5,7 +5,7 @@ const uint32_t qjsc_repl_size = 23360; const uint8_t qjsc_repl[23360] = { - 0x13, 0x96, 0x04, 0x01, 0x0e, 0x72, 0x65, 0x70, + 0x14, 0x96, 0x04, 0x01, 0x0e, 0x72, 0x65, 0x70, 0x6c, 0x2e, 0x6a, 0x73, 0x01, 0x0e, 0x71, 0x6a, 0x73, 0x3a, 0x73, 0x74, 0x64, 0x01, 0x0c, 0x71, 0x6a, 0x73, 0x3a, 0x6f, 0x73, 0x01, 0x12, 0x71, diff --git a/gen/standalone.c b/gen/standalone.c index 998907ab..7efaab28 100644 --- a/gen/standalone.c +++ b/gen/standalone.c @@ -5,7 +5,7 @@ const uint32_t qjsc_standalone_size = 2466; const uint8_t qjsc_standalone[2466] = { - 0x13, 0x4d, 0x01, 0x1a, 0x73, 0x74, 0x61, 0x6e, + 0x14, 0x4d, 0x01, 0x1a, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x6c, 0x6f, 0x6e, 0x65, 0x2e, 0x6a, 0x73, 0x01, 0x0e, 0x71, 0x6a, 0x73, 0x3a, 0x73, 0x74, 0x64, 0x01, 0x0c, 0x71, 0x6a, 0x73, 0x3a, diff --git a/gen/test_fib.c b/gen/test_fib.c index 971ee69f..660e0f12 100644 --- a/gen/test_fib.c +++ b/gen/test_fib.c @@ -5,7 +5,7 @@ const uint32_t qjsc_test_fib_size = 294; const uint8_t qjsc_test_fib[294] = { - 0x13, 0x0e, 0x01, 0x28, 0x65, 0x78, 0x61, 0x6d, + 0x14, 0x0e, 0x01, 0x28, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x66, 0x69, 0x62, 0x2e, 0x6a, 0x73, 0x01, 0x0c, 0x71, 0x6a, 0x73, 0x3a, 0x6f, 0x73, @@ -21,7 +21,7 @@ const uint8_t qjsc_test_fib[294] = { 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x10, 0x66, 0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d, 0xc0, 0x03, 0x01, 0xc2, 0x03, 0x00, 0x00, 0x01, - 0x00, 0xfc, 0x01, 0x00, 0x01, 0x0c, 0x20, 0xfa, + 0x00, 0xfc, 0x01, 0x00, 0x01, 0x0c, 0x20, 0x0a, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05, 0x03, 0x00, 0x73, 0x00, 0xc4, 0x03, 0x00, 0x0d, 0xc6, 0x03, 0x00, 0x0d, 0xc8, 0x03, 0x01, 0x0d, 0x08, diff --git a/libbf.c b/libbf.c index 6293f4ea..07d27cfa 100644 --- a/libbf.c +++ b/libbf.c @@ -646,20 +646,20 @@ int bf_normalize_and_round(bf_t *r, limb_t prec1, bf_flags_t flags) rounding */ int bf_can_round(const bf_t *a, slimb_t prec, bf_rnd_t rnd_mode, slimb_t k) { - BOOL is_rndn; + bool is_rndn; slimb_t bit_pos, n; limb_t bit; if (a->expn == BF_EXP_INF || a->expn == BF_EXP_NAN) - return FALSE; + return false; if (rnd_mode == BF_RNDF) { return (k >= (prec + 1)); } if (a->expn == BF_EXP_ZERO) - return FALSE; + return false; is_rndn = (rnd_mode == BF_RNDN || rnd_mode == BF_RNDNA); if (k < (prec + 2)) - return FALSE; + return false; bit_pos = a->len * LIMB_BITS - 1 - prec; n = k - prec; /* bit pattern for RNDN or RNDNA: 0111.. or 1000... @@ -672,11 +672,11 @@ int bf_can_round(const bf_t *a, slimb_t prec, bf_rnd_t rnd_mode, slimb_t k) /* XXX: slow, but a few iterations on average */ while (n != 0) { if (get_bit(a->tab, a->len, bit_pos) != bit) - return TRUE; + return true; bit_pos--; n--; } - return FALSE; + return false; } /* Cannot fail with BF_ST_MEM_ERROR. */ @@ -955,20 +955,20 @@ static int bf_add_internal(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec, i = r_len - tot_len; while (i < 0) { slimb_t ap, bp; - BOOL inflag; + bool inflag; ap = a_offset + i; bp = b_bit_offset + i * LIMB_BITS; - inflag = FALSE; + inflag = false; if (ap >= 0 && ap < a->len) { v1 = a->tab[ap]; - inflag = TRUE; + inflag = true; } else { v1 = 0; } if (bp + LIMB_BITS > 0 && bp < (slimb_t)(b->len * LIMB_BITS)) { v2 = get_bits(b->tab, b->len, bp); - inflag = TRUE; + inflag = true; } else { v2 = 0; } @@ -1758,7 +1758,7 @@ int bf_divrem(bf_t *q, bf_t *r, const bf_t *a, const bf_t *b, bf_t a1_s, *a1 = &a1_s; bf_t b1_s, *b1 = &b1_s; int q_sign, ret; - BOOL is_ceil, is_rndn; + bool is_ceil, is_rndn; assert(q != a && q != b); assert(r != a && r != b); @@ -1785,7 +1785,7 @@ int bf_divrem(bf_t *q, bf_t *r, const bf_t *a, const bf_t *b, case BF_RNDZ: case BF_RNDN: case BF_RNDNA: - is_ceil = FALSE; + is_ceil = false; break; case BF_RNDD: is_ceil = q_sign; @@ -1794,7 +1794,7 @@ int bf_divrem(bf_t *q, bf_t *r, const bf_t *a, const bf_t *b, is_ceil = q_sign ^ 1; break; case BF_RNDA: - is_ceil = TRUE; + is_ceil = true; break; case BF_DIVREM_EUCLIDIAN: is_ceil = a->sign; @@ -2900,13 +2900,13 @@ static int strcasestart(const char *str, const char *val, const char **ptr) static int bf_atof_internal(bf_t *r, slimb_t *pexponent, const char *str, const char **pnext, int radix, - limb_t prec, bf_flags_t flags, BOOL is_dec) + limb_t prec, bf_flags_t flags, bool is_dec) { const char *p, *p_start; int is_neg, radix_bits, exp_is_neg, ret, digits_per_limb, shift; limb_t cur_limb; slimb_t pos, expn, int_len, digit_count; - BOOL has_decpt, is_bin_exp; + bool has_decpt, is_bin_exp; bf_t a_s, *a; *pexponent = 0; @@ -2991,14 +2991,14 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent, cur_limb = 0; bf_resize(a, 1); pos = 0; - has_decpt = FALSE; + has_decpt = false; int_len = digit_count = 0; for(;;) { limb_t c; if (*p == '.' && (p > p_start || bf_to_digit(p[1]) < radix)) { if (has_decpt) break; - has_decpt = TRUE; + has_decpt = true; int_len = digit_count; p++; } @@ -3067,7 +3067,7 @@ static int bf_atof_internal(bf_t *r, slimb_t *pexponent, /* parse the exponent, if any */ expn = 0; - is_bin_exp = FALSE; + is_bin_exp = false; if (((radix == 10 && (*p == 'e' || *p == 'E')) || (radix != 10 && (*p == '@' || (radix_bits && (*p == 'p' || *p == 'P'))))) && @@ -3162,14 +3162,14 @@ int bf_atof2(bf_t *r, slimb_t *pexponent, limb_t prec, bf_flags_t flags) { return bf_atof_internal(r, pexponent, str, pnext, radix, prec, flags, - FALSE); + false); } int bf_atof(bf_t *r, const char *str, const char **pnext, int radix, limb_t prec, bf_flags_t flags) { slimb_t dummy_exp; - return bf_atof_internal(r, &dummy_exp, str, pnext, radix, prec, flags, FALSE); + return bf_atof_internal(r, &dummy_exp, str, pnext, radix, prec, flags, false); } /* base conversion to radix */ @@ -3340,7 +3340,7 @@ slimb_t bf_mul_log2_radix(slimb_t a1, unsigned int radix, int is_inv, { int is_neg; limb_t a; - BOOL is_ceil; + bool is_ceil; is_ceil = is_ceil1; a = a1; @@ -3510,7 +3510,7 @@ static int bf_integer_to_radix(bf_t *r, const bf_t *a, limb_t radixl) static int bf_convert_to_radix(bf_t *r, slimb_t *pE, const bf_t *a, int radix, limb_t P, bf_rnd_t rnd_mode, - BOOL is_fixed_exponent) + bool is_fixed_exponent) { slimb_t E, e, prec, extra_bits, ziv_extra_bits, prec0; bf_t B_s, *B = &B_s; @@ -3526,7 +3526,7 @@ static int bf_convert_to_radix(bf_t *r, slimb_t *pE, E = *pE; } else { /* compute the new exponent */ - E = 1 + bf_mul_log2_radix(a->expn - 1, radix, TRUE, FALSE); + E = 1 + bf_mul_log2_radix(a->expn - 1, radix, true, false); } // bf_print_str("a", a); // printf("E=%ld P=%ld radix=%d\n", E, P, radix); @@ -3539,7 +3539,7 @@ static int bf_convert_to_radix(bf_t *r, slimb_t *pE, e_sign = 1; } /* Note: precision for log2(radix) is not critical here */ - prec0 = bf_mul_log2_radix(P, radix, FALSE, TRUE); + prec0 = bf_mul_log2_radix(P, radix, false, true); ziv_extra_bits = 16; for(;;) { prec = prec0 + ziv_extra_bits; @@ -3632,12 +3632,12 @@ static void limb_to_a2(char *buf, limb_t n, unsigned int radix_bits, int len) } } -/* 'a' must be an integer if the is_dec = FALSE or if the radix is not +/* 'a' must be an integer if the is_dec = false or if the radix is not a power of two. A dot is added before the 'dot_pos' digit. dot_pos = n_digits does not display the dot. 0 <= dot_pos <= n_digits. n_digits >= 1. */ static void output_digits(DynBuf *s, const bf_t *a1, int radix, limb_t n_digits, - limb_t dot_pos, BOOL is_dec) + limb_t dot_pos, bool is_dec) { limb_t i, v, l; slimb_t pos, pos_incr; @@ -3721,7 +3721,7 @@ static void *bf_dbuf_realloc(void *opaque, void *ptr, size_t size) /* return the length in bytes. A trailing '\0' is added */ static char *bf_ftoa_internal(size_t *plen, const bf_t *a2, int radix, - limb_t prec, bf_flags_t flags, BOOL is_dec) + limb_t prec, bf_flags_t flags, bool is_dec) { bf_context_t *ctx = a2->ctx; DynBuf s_s, *s = &s_s; @@ -3810,11 +3810,11 @@ static char *bf_ftoa_internal(size_t *plen, const bf_t *a2, int radix, a->sign = 0; /* one more digit for the rounding */ - n = 1 + bf_mul_log2_radix(bf_max(a->expn, 0), radix, TRUE, TRUE); + n = 1 + bf_mul_log2_radix(bf_max(a->expn, 0), radix, true, true); n_digits = n + prec; n1 = n; if (bf_convert_to_radix(a1, &n1, a, radix, n_digits, - flags & BF_RND_MASK, TRUE)) + flags & BF_RND_MASK, true)) goto fail1; start = s->size; output_digits(s, a1, radix, n_digits, n, is_dec); @@ -3897,7 +3897,7 @@ static char *bf_ftoa_internal(size_t *plen, const bf_t *a2, int radix, slimb_t n_digits_max, n_digits_min; assert(prec != BF_PREC_INF); - n_digits = 1 + bf_mul_log2_radix(prec, radix, TRUE, TRUE); + n_digits = 1 + bf_mul_log2_radix(prec, radix, true, true); /* max number of digits for non exponential notation. The rational is to have the same rule as JS i.e. n_max = 21 for 64 bit float in base 10. */ @@ -3914,7 +3914,7 @@ static char *bf_ftoa_internal(size_t *plen, const bf_t *a2, int radix, while (n_digits_min < n_digits_max) { n_digits = (n_digits_min + n_digits_max) / 2; if (bf_convert_to_radix(a1, &n, a, radix, n_digits, - flags & BF_RND_MASK, FALSE)) { + flags & BF_RND_MASK, false)) { bf_delete(b); goto fail1; } @@ -3938,7 +3938,7 @@ static char *bf_ftoa_internal(size_t *plen, const bf_t *a2, int radix, } } if (bf_convert_to_radix(a1, &n, a, radix, n_digits, - flags & BF_RND_MASK, FALSE)) { + flags & BF_RND_MASK, false)) { fail1: bf_delete(a1); goto fail; @@ -4017,7 +4017,7 @@ static char *bf_ftoa_internal(size_t *plen, const bf_t *a2, int radix, char *bf_ftoa(size_t *plen, const bf_t *a, int radix, limb_t prec, bf_flags_t flags) { - return bf_ftoa_internal(plen, a, radix, prec, flags, FALSE); + return bf_ftoa_internal(plen, a, radix, prec, flags, false); } /***************************************************************/ @@ -4025,7 +4025,7 @@ char *bf_ftoa(size_t *plen, const bf_t *a, int radix, limb_t prec, /* Note: the algorithm is from MPFR */ static void bf_const_log2_rec(bf_t *T, bf_t *P, bf_t *Q, limb_t n1, - limb_t n2, BOOL need_P) + limb_t n2, bool need_P) { bf_context_t *s = T->ctx; if ((n2 - n1) == 1) { @@ -4045,7 +4045,7 @@ static void bf_const_log2_rec(bf_t *T, bf_t *P, bf_t *Q, limb_t n1, bf_t Q1_s, *Q1 = &Q1_s; m = n1 + ((n2 - n1) >> 1); - bf_const_log2_rec(T, P, Q, n1, m, TRUE); + bf_const_log2_rec(T, P, Q, n1, m, true); bf_init(s, T1); bf_init(s, P1); bf_init(s, Q1); @@ -4073,7 +4073,7 @@ static void bf_const_log2_internal(bf_t *T, limb_t prec) N = w / 3 + 1; bf_init(T->ctx, P); bf_init(T->ctx, Q); - bf_const_log2_rec(T, P, Q, 0, N, FALSE); + bf_const_log2_rec(T, P, Q, 0, N, false); bf_div(T, T, Q, prec, BF_RNDN); bf_delete(P); bf_delete(Q); @@ -4635,10 +4635,10 @@ static int bf_pow_int(bf_t *r, const bf_t *x, limb_t prec, void *opaque) return ret; } -/* x must be a finite non zero float. Return TRUE if there is a +/* x must be a finite non zero float. Return true if there is a floating point number r such as x=r^(2^n) and return this floating - point number 'r'. Otherwise return FALSE and r is undefined. */ -static BOOL check_exact_power2n(bf_t *r, const bf_t *x, slimb_t n) + point number 'r'. Otherwise return false and r is undefined. */ +static bool check_exact_power2n(bf_t *r, const bf_t *x, slimb_t n) { bf_context_t *s = r->ctx; bf_t T_s, *T = &T_s; @@ -4650,17 +4650,17 @@ static BOOL check_exact_power2n(bf_t *r, const bf_t *x, slimb_t n) /* fast check on the exponent */ if (n > (LIMB_BITS - 1)) { if (e != 0) - return FALSE; + return false; er = 0; } else { if ((e & (((limb_t)1 << n) - 1)) != 0) - return FALSE; + return false; er = e >> n; } /* every perfect odd square = 1 modulo 8 */ v = get_bits(x->tab, x->len, x->len * LIMB_BITS - x->expn + e); if ((v & 7) != 1) - return FALSE; + return false; bf_init(s, T); bf_set(T, x); @@ -4669,10 +4669,10 @@ static BOOL check_exact_power2n(bf_t *r, const bf_t *x, slimb_t n) if (i != 0) bf_set(T, r); if (bf_sqrtrem(r, NULL, T) != 0) - return FALSE; + return false; } r->expn += er; - return TRUE; + return true; } /* prec = BF_PREC_INF is accepted for x and y integers and y >= 0 */ @@ -4681,7 +4681,7 @@ int bf_pow(bf_t *r, const bf_t *x, const bf_t *y, limb_t prec, bf_flags_t flags) bf_context_t *s = r->ctx; bf_t T_s, *T = &T_s; bf_t ytmp_s; - BOOL y_is_int, y_is_odd; + bool y_is_int, y_is_odd; int r_sign, ret, rnd_mode; slimb_t y_emin; @@ -5072,7 +5072,7 @@ static int bf_atan_internal(bf_t *r, const bf_t *a, limb_t prec, void *opaque) { bf_context_t *s = r->ctx; - BOOL add_pi2 = (BOOL)(intptr_t)opaque; + bool add_pi2 = (bool)(intptr_t)opaque; bf_t T_s, *T = &T_s; bf_t U_s, *U = &U_s; bf_t V_s, *V = &V_s; @@ -5197,7 +5197,7 @@ int bf_atan(bf_t *r, const bf_t *a, limb_t prec, bf_flags_t flags) } } - return bf_ziv_rounding(r, a, prec, flags, bf_atan_internal, (void *)FALSE); + return bf_ziv_rounding(r, a, prec, flags, bf_atan_internal, (void *)false); } static int bf_atan2_internal(bf_t *r, const bf_t *y, limb_t prec, void *opaque) @@ -5247,7 +5247,7 @@ int bf_atan2(bf_t *r, const bf_t *y, const bf_t *x, static int bf_asin_internal(bf_t *r, const bf_t *a, limb_t prec, void *opaque) { bf_context_t *s = r->ctx; - BOOL is_acos = (BOOL)(intptr_t)opaque; + bool is_acos = (bool)(intptr_t)opaque; bf_t T_s, *T = &T_s; limb_t prec1, prec2; @@ -5313,7 +5313,7 @@ int bf_asin(bf_t *r, const bf_t *a, limb_t prec, bf_flags_t flags) } } - return bf_ziv_rounding(r, a, prec, flags, bf_asin_internal, (void *)FALSE); + return bf_ziv_rounding(r, a, prec, flags, bf_asin_internal, (void *)false); } int bf_acos(bf_t *r, const bf_t *a, limb_t prec, bf_flags_t flags) @@ -5347,7 +5347,7 @@ int bf_acos(bf_t *r, const bf_t *a, limb_t prec, bf_flags_t flags) return 0; } - return bf_ziv_rounding(r, a, prec, flags, bf_asin_internal, (void *)TRUE); + return bf_ziv_rounding(r, a, prec, flags, bf_asin_internal, (void *)true); } /***************************************************************/ @@ -6930,7 +6930,7 @@ int bfdec_divrem(bfdec_t *q, bfdec_t *r, const bfdec_t *a, const bfdec_t *b, bfdec_t b1_s, *b1 = &b1_s; bfdec_t r1_s, *r1 = &r1_s; int q_sign, res; - BOOL is_ceil, is_rndn; + bool is_ceil, is_rndn; assert(q != a && q != b); assert(r != a && r != b); @@ -6957,7 +6957,7 @@ int bfdec_divrem(bfdec_t *q, bfdec_t *r, const bfdec_t *a, const bfdec_t *b, case BF_RNDZ: case BF_RNDN: case BF_RNDNA: - is_ceil = FALSE; + is_ceil = false; break; case BF_RNDD: is_ceil = q_sign; @@ -6966,7 +6966,7 @@ int bfdec_divrem(bfdec_t *q, bfdec_t *r, const bfdec_t *a, const bfdec_t *b, is_ceil = q_sign ^ 1; break; case BF_RNDA: - is_ceil = TRUE; + is_ceil = true; break; case BF_DIVREM_EUCLIDIAN: is_ceil = a->sign; @@ -7196,7 +7196,7 @@ int bfdec_pow_ui(bfdec_t *r, const bfdec_t *a, limb_t b) char *bfdec_ftoa(size_t *plen, const bfdec_t *a, limb_t prec, bf_flags_t flags) { - return bf_ftoa_internal(plen, (const bf_t *)a, 10, prec, flags, TRUE); + return bf_ftoa_internal(plen, (const bf_t *)a, 10, prec, flags, true); } int bfdec_atof(bfdec_t *r, const char *str, const char **pnext, @@ -7204,7 +7204,7 @@ int bfdec_atof(bfdec_t *r, const char *str, const char **pnext, { slimb_t dummy_exp; return bf_atof_internal((bf_t *)r, &dummy_exp, str, pnext, 10, prec, - flags, TRUE); + flags, true); } #endif /* USE_BF_DEC */ diff --git a/libregexp.c b/libregexp.c index b4b0e0cd..7e32705a 100644 --- a/libregexp.c +++ b/libregexp.c @@ -67,10 +67,10 @@ typedef struct { const uint8_t *buf_end; const uint8_t *buf_start; int re_flags; - BOOL is_unicode; - BOOL unicode_sets; - BOOL ignore_case; - BOOL dotall; + bool is_unicode; + bool unicode_sets; + bool ignore_case; + bool dotall; int capture_count; int total_capture_count; /* -1 = not computed yet */ int has_named_captures; /* -1 = don't know, 0 = no, 1 = yes */ @@ -143,19 +143,19 @@ static const uint16_t char_range_s[] = { 0xFEFF, 0xFEFF + 1, }; -BOOL lre_is_space(int c) +bool lre_is_space(int c) { int i, n, low, high; n = (countof(char_range_s) - 1) / 2; for(i = 0; i < n; i++) { low = char_range_s[2 * i + 1]; if (c < low) - return FALSE; + return false; high = char_range_s[2 * i + 2]; if (c < high) - return TRUE; + return true; } - return FALSE; + return false; } uint32_t const lre_id_start_table_ascii[4] = { @@ -196,7 +196,7 @@ static const uint16_t *char_range_table[] = { static int cr_init_char_range(REParseState *s, CharRange *cr, uint32_t c) { - BOOL invert; + bool invert; const uint16_t *c_pt; int len, i; @@ -390,7 +390,7 @@ static int re_parse_out_of_memory(REParseState *s) /* If allow_overflow is false, return -1 in case of overflow. Otherwise return INT32_MAX. */ -static int parse_digits(const uint8_t **pp, BOOL allow_overflow) +static int parse_digits(const uint8_t **pp, bool allow_overflow) { const uint8_t *p; uint64_t v; @@ -548,7 +548,7 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16) } /* XXX: we use the same chars for name and value */ -static BOOL is_unicode_char(int c) +static bool is_unicode_char(int c) { return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || @@ -557,12 +557,12 @@ static BOOL is_unicode_char(int c) } static int parse_unicode_property(REParseState *s, CharRange *cr, - const uint8_t **pp, BOOL is_inv) + const uint8_t **pp, bool is_inv) { const uint8_t *p; char name[64], value[64]; char *q; - BOOL script_ext; + bool script_ext; int ret; p = *pp; @@ -592,10 +592,10 @@ static int parse_unicode_property(REParseState *s, CharRange *cr, // printf("name=%s value=%s\n", name, value); if (!strcmp(name, "Script") || !strcmp(name, "sc")) { - script_ext = FALSE; + script_ext = false; goto do_script; } else if (!strcmp(name, "Script_Extensions") || !strcmp(name, "scx")) { - script_ext = TRUE; + script_ext = true; do_script: cr_init(cr, s->opaque, lre_realloc); ret = unicode_script(cr, value, script_ext); @@ -654,7 +654,7 @@ static int parse_unicode_property(REParseState *s, CharRange *cr, (CLASS_RANGE_BASE). In case of class range, 'cr' is initialized. Otherwise, it is ignored. */ static int get_class_atom(REParseState *s, CharRange *cr, - const uint8_t **pp, BOOL inclass) + const uint8_t **pp, bool inclass) { const uint8_t *p, *p_next; uint32_t c; @@ -813,7 +813,7 @@ static int re_parse_char_class(REParseState *s, const uint8_t **pp) uint32_t c1, c2; CharRange cr_s, *cr = &cr_s; CharRange cr1_s, *cr1 = &cr1_s; - BOOL invert; + bool invert; cr_init(cr, s->opaque, lre_realloc); p = *pp; @@ -838,16 +838,16 @@ static int re_parse_char_class(REParseState *s, const uint8_t **pp) } while (n < 4); } - invert = FALSE; + invert = false; if (*p == '^') { p++; - invert = TRUE; + invert = true; } for(;;) { if (*p == ']') break; - c1 = get_class_atom(s, cr1, &p, TRUE); + c1 = get_class_atom(s, cr1, &p, true); if ((int)c1 < 0) goto fail; if (*p == '-' && p[1] == ']' && s->unicode_sets) { @@ -865,7 +865,7 @@ static int re_parse_char_class(REParseState *s, const uint8_t **pp) /* Annex B: match '-' character */ goto class_atom; } - c2 = get_class_atom(s, cr1, &p0, TRUE); + c2 = get_class_atom(s, cr1, &p0, true); if ((int)c2 < 0) goto fail; if (c2 >= CLASS_RANGE_BASE) { @@ -923,13 +923,13 @@ static int re_parse_char_class(REParseState *s, const uint8_t **pp) - true if the opcodes may not advance the char pointer - false if the opcodes always advance the char pointer */ -static BOOL re_need_check_advance(const uint8_t *bc_buf, int bc_buf_len) +static bool re_need_check_advance(const uint8_t *bc_buf, int bc_buf_len) { int pos, opcode, len; uint32_t val; - BOOL ret; + bool ret; - ret = TRUE; + ret = true; pos = 0; while (pos < bc_buf_len) { @@ -950,7 +950,7 @@ static BOOL re_need_check_advance(const uint8_t *bc_buf, int bc_buf_len) case REOP_dot: case REOP_any: simple_char: - ret = FALSE; + ret = false; break; case REOP_line_start: case REOP_line_end: @@ -970,7 +970,7 @@ static BOOL re_need_check_advance(const uint8_t *bc_buf, int bc_buf_len) break; default: /* safe behvior: we cannot predict the outcome */ - return TRUE; + return true; } pos += len; } @@ -1136,7 +1136,7 @@ static int re_count_captures(REParseState *s) return s->total_capture_count; } -static BOOL re_has_named_captures(REParseState *s) +static bool re_has_named_captures(REParseState *s) { if (s->has_named_captures < 0) re_count_captures(s); @@ -1164,13 +1164,13 @@ static int find_group_name(REParseState *s, const char *name) return -1; } -static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir); +static int re_parse_disjunction(REParseState *s, bool is_backward_dir); -static int re_parse_term(REParseState *s, BOOL is_backward_dir) +static int re_parse_term(REParseState *s, bool is_backward_dir) { const uint8_t *p; int c, last_atom_start, quant_min, quant_max, last_capture_count; - BOOL greedy, add_zero_advance_check, is_neg, is_backward_lookahead; + bool greedy, add_zero_advance_check, is_neg, is_backward_lookahead; CharRange cr_s, *cr = &cr_s; last_atom_start = -1; @@ -1206,11 +1206,11 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) } else { const uint8_t *p1 = p + 1; /* Annex B: error if it is like a repetition count */ - parse_digits(&p1, TRUE); + parse_digits(&p1, true); if (*p1 == ',') { p1++; if (lre_is_digit(*p1)) { - parse_digits(&p1, TRUE); + parse_digits(&p1, true); } } if (*p1 != '}') { @@ -1236,14 +1236,14 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) return -1; } else if ((p[2] == '=' || p[2] == '!')) { is_neg = (p[2] == '!'); - is_backward_lookahead = FALSE; + is_backward_lookahead = false; p += 3; goto lookahead; } else if (p[2] == '<' && (p[3] == '=' || p[3] == '!')) { int pos; is_neg = (p[3] == '!'); - is_backward_lookahead = TRUE; + is_backward_lookahead = true; p += 4; /* lookahead */ lookahead: @@ -1376,7 +1376,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) { const uint8_t *q = ++p; - c = parse_digits(&p, FALSE); + c = parse_digits(&p, false); if (c < 0 || (c >= s->capture_count && c >= re_count_captures(s))) { if (!s->is_unicode) { /* Annex B.1.4: accept legacy octal */ @@ -1425,7 +1425,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) goto parse_class_atom; default: parse_class_atom: - c = get_class_atom(s, cr, &p, FALSE); + c = get_class_atom(s, cr, &p, false); if ((int)c < 0) return -1; normal_char: @@ -1485,12 +1485,12 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) break; } p++; - quant_min = parse_digits(&p, TRUE); + quant_min = parse_digits(&p, true); quant_max = quant_min; if (*p == ',') { p++; if (lre_is_digit(*p)) { - quant_max = parse_digits(&p, TRUE); + quant_max = parse_digits(&p, true); if (quant_max < quant_min) { invalid_quant_count: return re_parse_error(s, "invalid repetition count"); @@ -1508,10 +1508,10 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) return -1; } quantifier: - greedy = TRUE; + greedy = true; if (*p == '?') { p++; - greedy = FALSE; + greedy = false; } if (last_atom_start < 0) { return re_parse_error(s, "nothing to repeat"); @@ -1571,7 +1571,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) if (quant_max == 0) { s->byte_code.size = last_atom_start; } else if (quant_max == 1 || quant_max == INT32_MAX) { - BOOL has_goto = (quant_max == INT32_MAX); + bool has_goto = (quant_max == INT32_MAX); if (dbuf_insert(&s->byte_code, last_atom_start, 5 + add_zero_advance_check)) goto out_of_memory; s->byte_code.buf[last_atom_start] = REOP_split_goto_first + @@ -1596,7 +1596,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) pos += 4; if (add_zero_advance_check) { s->byte_code.buf[pos++] = REOP_push_char_pos; - re_emit_op(s, REOP_check_advance); + re_emit_op(s, REOP_check_advance); } re_emit_goto(s, REOP_loop, last_atom_start + 5); re_emit_op(s, REOP_drop); @@ -1658,7 +1658,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir) return re_parse_out_of_memory(s); } -static int re_parse_alternative(REParseState *s, BOOL is_backward_dir) +static int re_parse_alternative(REParseState *s, bool is_backward_dir) { const uint8_t *p; int ret; @@ -1692,7 +1692,7 @@ static int re_parse_alternative(REParseState *s, BOOL is_backward_dir) return 0; } -static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir) +static int re_parse_disjunction(REParseState *s, bool is_backward_dir) { int start, len, pos; @@ -1781,7 +1781,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size, { REParseState s_s, *s = &s_s; int stack_size; - BOOL is_sticky; + bool is_sticky; memset(s, 0, sizeof(*s)); s->opaque = opaque; @@ -1817,7 +1817,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size, } re_emit_op_u8(s, REOP_save_start, 0); - if (re_parse_disjunction(s, FALSE)) { + if (re_parse_disjunction(s, false)) { error: dbuf_free(&s->byte_code); dbuf_free(&s->group_names); @@ -1868,12 +1868,12 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size, return s->byte_code.buf; } -static BOOL is_line_terminator(uint32_t c) +static bool is_line_terminator(uint32_t c) { return (c == '\n' || c == '\r' || c == CP_LS || c == CP_PS); } -static BOOL is_word_char(uint32_t c) +static bool is_word_char(uint32_t c) { return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || @@ -1989,9 +1989,9 @@ typedef struct { int cbuf_type; int capture_count; int stack_size_max; - BOOL multi_line; - BOOL ignore_case; - BOOL is_unicode; + bool multi_line; + bool ignore_case; + bool is_unicode; void *opaque; /* used for stack overflow check */ size_t state_size; @@ -2042,7 +2042,7 @@ static int push_state(REExecContext *s, static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, StackInt *stack, int stack_len, const uint8_t *pc, const uint8_t *cptr, - BOOL no_recurse) + bool no_recurse) { int opcode, ret; int cbuf_type; @@ -2256,17 +2256,17 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, case REOP_word_boundary: case REOP_not_word_boundary: { - BOOL v1, v2; + bool v1, v2; /* char before */ if (cptr == s->cbuf) { - v1 = FALSE; + v1 = false; } else { PEEK_PREV_CHAR(c, cptr, s->cbuf, cbuf_type); v1 = is_word_char(c); } /* current char */ if (cptr >= cbuf_end) { - v2 = FALSE; + v2 = false; } else { PEEK_CHAR(c, cptr, cbuf_end, cbuf_type); v2 = is_word_char(c); @@ -2419,7 +2419,7 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, q = 0; for(;;) { res = lre_exec_backtrack(s, capture, stack, stack_len, - pc1, cptr, TRUE); + pc1, cptr, true); if (res == -1) return res; if (!res) @@ -2484,7 +2484,7 @@ int lre_exec(uint8_t **capture, alloca_size = s->stack_size_max * sizeof(stack_buf[0]); stack_buf = alloca(alloca_size); ret = lre_exec_backtrack(s, capture, stack_buf, 0, bc_buf + RE_HEADER_LEN, - cbuf + (cindex << cbuf_type), FALSE); + cbuf + (cindex << cbuf_type), false); lre_realloc(s->opaque, s->state_stack, 0); return ret; } @@ -2510,7 +2510,7 @@ const char *lre_get_groupnames(const uint8_t *bc_buf) return (const char *)(bc_buf + RE_HEADER_LEN + re_bytecode_len); } -void lre_byte_swap(uint8_t *buf, size_t len, BOOL is_byte_swapped) +void lre_byte_swap(uint8_t *buf, size_t len, bool is_byte_swapped) { uint8_t *p, *pe; uint32_t n, r, nw; @@ -2586,9 +2586,9 @@ void lre_byte_swap(uint8_t *buf, size_t len, BOOL is_byte_swapped) #ifdef TEST -BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size) +bool lre_check_stack_overflow(void *opaque, size_t alloca_size) { - return FALSE; + return false; } void *lre_realloc(void *opaque, void *ptr, size_t size) diff --git a/libregexp.h b/libregexp.h index c2e664a2..0b8fec52 100644 --- a/libregexp.h +++ b/libregexp.h @@ -24,6 +24,7 @@ #ifndef LIBREGEXP_H #define LIBREGEXP_H +#include #include #include "libunicode.h" @@ -32,8 +33,6 @@ extern "C" { #endif -#define LRE_BOOL int /* for documentation purposes */ - #define LRE_FLAG_GLOBAL (1 << 0) #define LRE_FLAG_IGNORECASE (1 << 1) #define LRE_FLAG_MULTILINE (1 << 2) @@ -55,12 +54,12 @@ int lre_exec(uint8_t **capture, int cbuf_type, void *opaque); int lre_parse_escape(const uint8_t **pp, int allow_utf16); -LRE_BOOL lre_is_space(int c); +bool lre_is_space(int c); -void lre_byte_swap(uint8_t *buf, size_t len, LRE_BOOL is_byte_swapped); +void lre_byte_swap(uint8_t *buf, size_t len, bool is_byte_swapped); /* must be provided by the user */ -LRE_BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size); +bool lre_check_stack_overflow(void *opaque, size_t alloca_size); void *lre_realloc(void *opaque, void *ptr, size_t size); /* JS identifier test */ @@ -86,8 +85,6 @@ static inline int lre_js_is_ident_next(int c) } } -#undef LRE_BOOL - #ifdef __cplusplus } /* extern "C" { */ #endif diff --git a/libunicode.c b/libunicode.c index e880dada..a621c523 100644 --- a/libunicode.c +++ b/libunicode.c @@ -190,7 +190,7 @@ int lre_case_conv(uint32_t *res, uint32_t c, int conv_type) return 1; } -static int lre_case_folding_entry(uint32_t c, uint32_t idx, uint32_t v, BOOL is_unicode) +static int lre_case_folding_entry(uint32_t c, uint32_t idx, uint32_t v, bool is_unicode) { uint32_t res[LRE_CC_RES_LEN_MAX]; int len; @@ -216,7 +216,7 @@ static int lre_case_folding_entry(uint32_t c, uint32_t idx, uint32_t v, BOOL is_ c = c - 'a' + 'A'; } else { /* legacy regexp: to upper case if single char >= 128 */ - len = lre_case_conv_entry(res, c, FALSE, idx, v); + len = lre_case_conv_entry(res, c, false, idx, v); if (len == 1 && res[0] >= 128) c = res[0]; } @@ -225,7 +225,7 @@ static int lre_case_folding_entry(uint32_t c, uint32_t idx, uint32_t v, BOOL is_ } /* JS regexp specific rules for case folding */ -int lre_canonicalize(uint32_t c, BOOL is_unicode) +int lre_canonicalize(uint32_t c, bool is_unicode) { if (c < 128) { /* fast case */ @@ -241,7 +241,7 @@ int lre_canonicalize(uint32_t c, BOOL is_unicode) } else { uint32_t v, code, len; int idx, idx_min, idx_max; - + idx_min = 0; idx_max = countof(case_conv_table1) - 1; while (idx_min <= idx_max) { @@ -302,7 +302,7 @@ static int get_index_pos(uint32_t *pcode, uint32_t c, return (idx_min + 1) * UNICODE_INDEX_BLOCK_LEN + (v >> 21); } -static BOOL lre_is_in_table(uint32_t c, const uint8_t *table, +static bool lre_is_in_table(uint32_t c, const uint8_t *table, const uint8_t *index_table, int index_table_len) { uint32_t code, b, bit; @@ -311,7 +311,7 @@ static BOOL lre_is_in_table(uint32_t c, const uint8_t *table, pos = get_index_pos(&code, c, index_table, index_table_len); if (pos < 0) - return FALSE; /* outside the table */ + return false; /* outside the table */ p = table + pos; bit = 0; for(;;) { @@ -337,7 +337,7 @@ static BOOL lre_is_in_table(uint32_t c, const uint8_t *table, } } -BOOL lre_is_cased(uint32_t c) +bool lre_is_cased(uint32_t c) { uint32_t v, code, len; int idx, idx_min, idx_max; @@ -354,7 +354,7 @@ BOOL lre_is_cased(uint32_t c) } else if (c >= code + len) { idx_min = idx + 1; } else { - return TRUE; + return true; } } return lre_is_in_table(c, unicode_prop_Cased1_table, @@ -362,7 +362,7 @@ BOOL lre_is_cased(uint32_t c) sizeof(unicode_prop_Cased1_index) / 3); } -BOOL lre_is_case_ignorable(uint32_t c) +bool lre_is_case_ignorable(uint32_t c) { return lre_is_in_table(c, unicode_prop_Case_Ignorable_table, unicode_prop_Case_Ignorable_index, @@ -530,14 +530,14 @@ int cr_invert(CharRange *cr) return 0; } -BOOL lre_is_id_start(uint32_t c) +bool lre_is_id_start(uint32_t c) { return lre_is_in_table(c, unicode_prop_ID_Start_table, unicode_prop_ID_Start_index, sizeof(unicode_prop_ID_Start_index) / 3); } -BOOL lre_is_id_continue(uint32_t c) +bool lre_is_id_continue(uint32_t c) { return lre_is_id_start(c) || lre_is_in_table(c, unicode_prop_ID_Continue1_table, @@ -545,7 +545,7 @@ BOOL lre_is_id_continue(uint32_t c) sizeof(unicode_prop_ID_Continue1_index) / 3); } -BOOL lre_is_white_space(uint32_t c) +bool lre_is_white_space(uint32_t c) { return lre_is_in_table(c, unicode_prop_White_Space_table, unicode_prop_White_Space_index, @@ -759,7 +759,7 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c, /* return the length of the decomposition (length <= UNICODE_DECOMP_LEN_MAX) or 0 if no decomposition */ -static int unicode_decomp_char(uint32_t *res, uint32_t c, BOOL is_compat1) +static int unicode_decomp_char(uint32_t *res, uint32_t c, bool is_compat1) { uint32_t v, type, is_compat, code, len; int idx_min, idx_max, idx; @@ -953,7 +953,7 @@ int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len, void *opaque, DynBufReallocFunc *realloc_func) { int *buf, buf_len, i, p, starter_pos, cc, last_cc, out_len; - BOOL is_compat; + bool is_compat; DynBuf dbuf_s, *dbuf = &dbuf_s; is_compat = n_type >> 1; @@ -1053,14 +1053,14 @@ static int unicode_find_name(const char *name_table, const char *name) /* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2 if not found */ int unicode_script(CharRange *cr, - const char *script_name, BOOL is_ext) + const char *script_name, bool is_ext) { int script_idx; const uint8_t *p, *p_end; uint32_t c, c1, b, n, v, v_len, i, type; CharRange cr1_s = { 0 }, *cr1 = NULL; CharRange cr2_s = { 0 }, *cr2 = &cr2_s; - BOOL is_common; + bool is_common; script_idx = unicode_find_name(unicode_script_name_table, script_name); if (script_idx < 0) @@ -1380,7 +1380,7 @@ static void cr_sort_and_remove_overlap(CharRange *cr) /* canonicalize a character set using the JS regex case folding rules (see lre_canonicalize()) */ -int cr_regexp_canonicalize(CharRange *cr, BOOL is_unicode) +int cr_regexp_canonicalize(CharRange *cr, bool is_unicode) { CharRange cr_inter, cr_mask, cr_result, cr_sub; uint32_t v, code, len, i, idx, start, end, c, d_start, d_end, d; diff --git a/libunicode.h b/libunicode.h index 00400ffa..8e6f2a01 100644 --- a/libunicode.h +++ b/libunicode.h @@ -24,6 +24,7 @@ #ifndef LIBUNICODE_H #define LIBUNICODE_H +#include #include #include @@ -31,8 +32,6 @@ extern "C" { #endif -#define LRE_BOOL int /* for documentation purposes */ - #define LRE_CC_RES_LEN_MAX 3 typedef enum { @@ -43,9 +42,9 @@ typedef enum { } UnicodeNormalizationEnum; int lre_case_conv(uint32_t *res, uint32_t c, int conv_type); -int lre_canonicalize(uint32_t c, LRE_BOOL is_unicode); -LRE_BOOL lre_is_cased(uint32_t c); -LRE_BOOL lre_is_case_ignorable(uint32_t c); +int lre_canonicalize(uint32_t c, bool is_unicode); +bool lre_is_cased(uint32_t c); +bool lre_is_case_ignorable(uint32_t c); /* char ranges */ @@ -103,11 +102,11 @@ int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len, const uint32_t *b_pt, int b_len, int op); int cr_invert(CharRange *cr); -int cr_regexp_canonicalize(CharRange *cr, LRE_BOOL is_unicode); +int cr_regexp_canonicalize(CharRange *cr, bool is_unicode); -LRE_BOOL lre_is_id_start(uint32_t c); -LRE_BOOL lre_is_id_continue(uint32_t c); -LRE_BOOL lre_is_white_space(uint32_t c); +bool lre_is_id_start(uint32_t c); +bool lre_is_id_continue(uint32_t c); +bool lre_is_white_space(uint32_t c); int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len, UnicodeNormalizationEnum n_type, @@ -116,12 +115,10 @@ int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len, /* Unicode character range functions */ int unicode_script(CharRange *cr, - const char *script_name, LRE_BOOL is_ext); + const char *script_name, bool is_ext); int unicode_general_category(CharRange *cr, const char *gc_name); int unicode_prop(CharRange *cr, const char *prop_name); -#undef LRE_BOOL - #ifdef __cplusplus } /* extern "C" { */ #endif diff --git a/qjs.c b/qjs.c index e6636d81..38c5f984 100644 --- a/qjs.c +++ b/qjs.c @@ -58,11 +58,11 @@ static int qjs__argc; static char **qjs__argv; -static BOOL is_standalone(const char *exe) +static bool is_standalone(const char *exe) { FILE *exe_f = fopen(exe, "rb"); if (!exe_f) - return FALSE; + return false; if (fseek(exe_f, -trailer_size, SEEK_END) < 0) goto fail; uint8_t buf[TRAILER_SIZE]; @@ -72,7 +72,7 @@ static BOOL is_standalone(const char *exe) return !memcmp(buf, trailer_magic, trailer_magic_size); fail: fclose(exe_f); - return FALSE; + return false; } static JSValue load_standalone_module(JSContext *ctx) @@ -87,7 +87,7 @@ static JSValue load_standalone_module(JSContext *ctx) JS_FreeValue(ctx, obj); goto exception; } - js_module_set_import_meta(ctx, obj, FALSE, TRUE); + js_module_set_import_meta(ctx, obj, false, true); val = JS_EvalFunction(ctx, JS_DupValue(ctx, obj)); val = js_std_await(ctx, val); @@ -116,7 +116,7 @@ static int eval_buf(JSContext *ctx, const void *buf, int buf_len, val = JS_Eval(ctx, buf, buf_len, filename, eval_flags | JS_EVAL_FLAG_COMPILE_ONLY); if (!JS_IsException(val)) { - js_module_set_import_meta(ctx, val, TRUE, TRUE); + js_module_set_import_meta(ctx, val, true, true); val = JS_EvalFunction(ctx, val); } val = js_std_await(ctx, val); diff --git a/qjsc.c b/qjsc.c index 21546143..3e9665a0 100644 --- a/qjsc.c +++ b/qjsc.c @@ -158,7 +158,7 @@ static void dump_hex(FILE *f, const uint8_t *buf, size_t len) static void output_object_code(JSContext *ctx, FILE *fo, JSValue obj, const char *c_name, - BOOL load_only) + bool load_only) { uint8_t *out_buf; size_t out_buf_len; @@ -261,7 +261,7 @@ JSModuleDef *jsc_module_loader(JSContext *ctx, if (namelist_find(&cname_list, cname)) { find_unique_cname(cname, sizeof(cname)); } - output_object_code(ctx, outfile, func_val, cname, TRUE); + output_object_code(ctx, outfile, func_val, cname, true); /* the module is already referenced, so we must free it */ m = JS_VALUE_GET_PTR(func_val); @@ -307,7 +307,7 @@ static void compile_file(JSContext *ctx, FILE *fo, } else { get_c_name(c_name, sizeof(c_name), filename); } - output_object_code(ctx, fo, obj, c_name, FALSE); + output_object_code(ctx, fo, obj, c_name, false); JS_FreeValue(ctx, obj); } diff --git a/quickjs-libc.c b/quickjs-libc.c index 0219bb46..a93d5d87 100644 --- a/quickjs-libc.c +++ b/quickjs-libc.c @@ -161,7 +161,7 @@ typedef struct JSThreadState { struct list_head port_list; /* list of JSWorkerMessageHandler.link */ int eval_script_recurse; /* only used in the main thread */ int64_t next_timer_id; /* for setTimeout / setInterval */ - BOOL can_js_os_poll; + bool can_js_os_poll; /* not used in the main thread */ JSWorkerMessagePipe *recv_pipe, *send_pipe; JSClassID std_file_class_id; @@ -175,7 +175,7 @@ static void js_std_dbuf_init(JSContext *ctx, DynBuf *s) dbuf_init2(s, JS_GetRuntime(ctx), (DynBufReallocFunc *)js_realloc_rt); } -static BOOL my_isdigit(int c) +static bool my_isdigit(int c) { return (c >= '0' && c <= '9'); } @@ -477,7 +477,7 @@ static JSValue js_loadScript(JSContext *ctx, JSValue this_val, return ret; } -static int get_bool_option(JSContext *ctx, BOOL *pbool, +static int get_bool_option(JSContext *ctx, bool *pbool, JSValue obj, const char *option) { @@ -504,7 +504,7 @@ static JSValue js_std_loadFile(JSContext *ctx, JSValue this_val, const char *filename; JSValue ret, options_obj; size_t buf_len; - BOOL binary = FALSE; + bool binary = false; if (argc >= 2) { options_obj = argv[1]; @@ -521,7 +521,7 @@ static JSValue js_std_loadFile(JSContext *ctx, JSValue this_val, if (!buf) return JS_NULL; if (binary) { - ret = JS_NewUint8Array(ctx, buf, buf_len, free_buf, NULL, FALSE); + ret = JS_NewUint8Array(ctx, buf, buf_len, free_buf, NULL, false); } else { ret = JS_NewStringLen(ctx, (char *)buf, buf_len); js_free(ctx, buf); @@ -543,9 +543,9 @@ static JSModuleDef *js_module_loader_so(JSContext *ctx, JSInitModuleFunc *init; char *filename = NULL; size_t len = strlen(module_name); - JS_BOOL is_absolute = len > 2 && ((module_name[0] >= 'A' && module_name[0] <= 'Z') || + bool is_absolute = len > 2 && ((module_name[0] >= 'A' && module_name[0] <= 'Z') || (module_name[0] >= 'a' && module_name[0] <= 'z')) && module_name[1] == ':'; - JS_BOOL is_relative = len > 2 && module_name[0] == '.' && (module_name[1] == '/' || module_name[1] == '\\'); + bool is_relative = len > 2 && module_name[0] == '.' && (module_name[1] == '/' || module_name[1] == '\\'); if (is_absolute || is_relative) { filename = (char *)module_name; } else { @@ -639,7 +639,7 @@ static JSModuleDef *js_module_loader_so(JSContext *ctx, #endif /* !_WIN32 */ int js_module_set_import_meta(JSContext *ctx, JSValue func_val, - JS_BOOL use_realpath, JS_BOOL is_main) + bool use_realpath, bool is_main) { JSModuleDef *m; char buf[PATH_MAX + 16]; @@ -717,7 +717,7 @@ JSModuleDef *js_module_loader(JSContext *ctx, if (JS_IsException(func_val)) return NULL; /* XXX: could propagate the exception */ - js_module_set_import_meta(ctx, func_val, TRUE, FALSE); + js_module_set_import_meta(ctx, func_val, true, false); /* the module is already referenced, so we must free it */ m = JS_VALUE_GET_PTR(func_val); JS_FreeValue(ctx, func_val); @@ -768,7 +768,7 @@ static void setenv(const char *name, const char *value, int overwrite) static void unsetenv(const char *name) { - setenv(name, "", TRUE); + setenv(name, "", true); } #endif /* _WIN32 */ @@ -784,7 +784,7 @@ static JSValue js_std_setenv(JSContext *ctx, JSValue this_val, JS_FreeCString(ctx, name); return JS_EXCEPTION; } - setenv(name, value, TRUE); + setenv(name, value, true); JS_FreeCString(ctx, name); JS_FreeCString(ctx, value); return JS_UNDEFINED; @@ -862,12 +862,12 @@ static JSValue js_evalScript(JSContext *ctx, JSValue this_val, size_t len; JSValue ret, obj; JSValue options_obj; - BOOL backtrace_barrier = FALSE; - BOOL eval_function = FALSE; - BOOL eval_module = FALSE; - BOOL compile_only = FALSE; - BOOL compile_module = FALSE; - BOOL is_async = FALSE; + bool backtrace_barrier = false; + bool eval_function = false; + bool eval_module = false; + bool compile_only = false; + bool compile_module = false; + bool is_async = false; int flags; if (argc >= 2) { @@ -900,7 +900,7 @@ static JSValue js_evalScript(JSContext *ctx, JSValue this_val, if (JS_ResolveModule(ctx, obj) < 0) return JS_EXCEPTION; - js_module_set_import_meta(ctx, obj, FALSE, FALSE); + js_module_set_import_meta(ctx, obj, false, false); return JS_EvalFunction(ctx, obj); } @@ -942,10 +942,10 @@ static JSValue js_evalScript(JSContext *ctx, JSValue this_val, typedef struct { FILE *f; - BOOL is_popen; + bool is_popen; } JSSTDFile; -static BOOL is_stdio(FILE *f) +static bool is_stdio(FILE *f) { return f == stdin || f == stdout || f == stderr; } @@ -983,7 +983,7 @@ static JSValue js_std_strerror(JSContext *ctx, JSValue this_val, return JS_NewString(ctx, strerror(err)); } -static JSValue js_new_std_file(JSContext *ctx, FILE *f, BOOL is_popen) +static JSValue js_new_std_file(JSContext *ctx, FILE *f, bool is_popen) { JSRuntime *rt = JS_GetRuntime(ctx); JSThreadState *ts = js_get_thread_state(rt); @@ -1039,7 +1039,7 @@ static JSValue js_std_open(JSContext *ctx, JSValue this_val, JS_FreeCString(ctx, mode); if (!f) return JS_NULL; - return js_new_std_file(ctx, f, FALSE); + return js_new_std_file(ctx, f, false); fail: JS_FreeCString(ctx, filename); JS_FreeCString(ctx, mode); @@ -1076,7 +1076,7 @@ static JSValue js_std_popen(JSContext *ctx, JSValue this_val, JS_FreeCString(ctx, mode); if (!f) return JS_NULL; - return js_new_std_file(ctx, f, TRUE); + return js_new_std_file(ctx, f, true); fail: JS_FreeCString(ctx, filename); JS_FreeCString(ctx, mode); @@ -1111,7 +1111,7 @@ static JSValue js_std_fdopen(JSContext *ctx, JSValue this_val, JS_FreeCString(ctx, mode); if (!f) return JS_NULL; - return js_new_std_file(ctx, f, FALSE); + return js_new_std_file(ctx, f, false); fail: JS_FreeCString(ctx, mode); return JS_EXCEPTION; @@ -1127,7 +1127,7 @@ static JSValue js_std_tmpfile(JSContext *ctx, JSValue this_val, js_set_error_object(ctx, argv[0], f ? 0 : errno); if (!f) return JS_NULL; - return js_new_std_file(ctx, f, FALSE); + return js_new_std_file(ctx, f, false); } #endif @@ -1482,14 +1482,14 @@ static JSValue js_std_urlGet(JSContext *ctx, JSValue this_val, JSValue response = JS_UNDEFINED, ret_obj; JSValue options_obj; FILE *f; - BOOL binary_flag, full_flag; + bool binary_flag, full_flag; url = JS_ToCString(ctx, argv[0]); if (!url) return JS_EXCEPTION; - binary_flag = FALSE; - full_flag = FALSE; + binary_flag = false; + full_flag = false; if (argc >= 2) { options_obj = argv[1]; @@ -1718,9 +1718,9 @@ static int js_std_init(JSContext *ctx, JSModuleDef *m) JS_SetModuleExportList(ctx, m, js_std_funcs, countof(js_std_funcs)); - JS_SetModuleExport(ctx, m, "in", js_new_std_file(ctx, stdin, FALSE)); - JS_SetModuleExport(ctx, m, "out", js_new_std_file(ctx, stdout, FALSE)); - JS_SetModuleExport(ctx, m, "err", js_new_std_file(ctx, stderr, FALSE)); + JS_SetModuleExport(ctx, m, "in", js_new_std_file(ctx, stdin, false)); + JS_SetModuleExport(ctx, m, "out", js_new_std_file(ctx, stdout, false)); + JS_SetModuleExport(ctx, m, "err", js_new_std_file(ctx, stderr, false)); return 0; } @@ -1785,7 +1785,7 @@ static JSValue js_os_seek(JSContext *ctx, JSValue this_val, { int fd, whence; int64_t pos, ret; - BOOL is_bigint; + bool is_bigint; if (JS_ToInt32(ctx, &fd, argv[0])) return JS_EXCEPTION; @@ -1990,7 +1990,7 @@ static JSValue js_os_rename(JSContext *ctx, JSValue this_val, return JS_NewInt32(ctx, ret); } -static BOOL is_main_thread(JSRuntime *rt) +static bool is_main_thread(JSRuntime *rt) { JSThreadState *ts = js_get_thread_state(rt); return !ts->recv_pipe; @@ -2980,7 +2980,7 @@ static int my_execvpe(const char *filename, char **argv, char **envp) char *path, *p, *p_next, *p1; char buf[PATH_MAX]; size_t filename_len, path_len; - BOOL eacces_error; + bool eacces_error; filename_len = strlen(filename); if (filename_len == 0) { @@ -2993,7 +2993,7 @@ static int my_execvpe(const char *filename, char **argv, char **envp) path = getenv("PATH"); if (!path) path = (char *)"/bin:/usr/bin"; - eacces_error = FALSE; + eacces_error = false; p = path; for(p = path; p != NULL; p = p_next) { p1 = strchr(p, ':'); @@ -3016,7 +3016,7 @@ static int my_execvpe(const char *filename, char **argv, char **envp) switch(errno) { case EACCES: - eacces_error = TRUE; + eacces_error = true; break; case ENOENT: case ENOTDIR: @@ -3053,7 +3053,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValue this_val, char **envp = environ; uint32_t exec_argc, i; int ret, pid, status; - BOOL block_flag = TRUE, use_path = TRUE; + bool block_flag = true, use_path = true; static const char *std_name[3] = { "stdin", "stdout", "stderr" }; int std_fds[3]; uint32_t uid = -1, gid = -1; @@ -3525,7 +3525,7 @@ static void *worker_func(void *opaque) fprintf(stderr, "JS_NewContext failure"); } - JS_SetCanBlock(rt, TRUE); + JS_SetCanBlock(rt, true); js_std_add_helpers(ctx, -1, NULL); @@ -3930,7 +3930,7 @@ static int js_os_init(JSContext *ctx, JSModuleDef *m) JSRuntime *rt = JS_GetRuntime(ctx); JSThreadState *ts = js_get_thread_state(rt); - ts->can_js_os_poll = TRUE; + ts->can_js_os_poll = true; #ifdef USE_WORKER { @@ -4137,7 +4137,7 @@ static void js_dump_obj(JSContext *ctx, FILE *f, JSValue val) static void js_std_dump_error1(JSContext *ctx, JSValue exception_val) { JSValue val; - BOOL is_error; + bool is_error; is_error = JS_IsError(ctx, exception_val); js_dump_obj(ctx, stderr, exception_val); @@ -4161,7 +4161,7 @@ void js_std_dump_error(JSContext *ctx) void js_std_promise_rejection_tracker(JSContext *ctx, JSValue promise, JSValue reason, - BOOL is_handled, void *opaque) + bool is_handled, void *opaque) { if (!is_handled) { fprintf(stderr, "Possibly unhandled promise rejection: "); @@ -4244,7 +4244,7 @@ void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len, goto exception; if (load_only) { if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) { - js_module_set_import_meta(ctx, obj, FALSE, FALSE); + js_module_set_import_meta(ctx, obj, false, false); } } else { if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) { @@ -4252,7 +4252,7 @@ void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len, JS_FreeValue(ctx, obj); goto exception; } - js_module_set_import_meta(ctx, obj, FALSE, TRUE); + js_module_set_import_meta(ctx, obj, false, true); val = JS_EvalFunction(ctx, obj); val = js_std_await(ctx, val); } else { diff --git a/quickjs-libc.h b/quickjs-libc.h index 19fad581..6b49363f 100644 --- a/quickjs-libc.h +++ b/quickjs-libc.h @@ -24,6 +24,7 @@ #ifndef QUICKJS_LIBC_H #define QUICKJS_LIBC_H +#include #include #include @@ -44,14 +45,14 @@ void js_std_free_handlers(JSRuntime *rt); void js_std_dump_error(JSContext *ctx); uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename); int js_module_set_import_meta(JSContext *ctx, JSValue func_val, - JS_BOOL use_realpath, JS_BOOL is_main); + bool use_realpath, bool is_main); JSModuleDef *js_module_loader(JSContext *ctx, const char *module_name, void *opaque); void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len, int flags); void js_std_promise_rejection_tracker(JSContext *ctx, JSValue promise, JSValue reason, - JS_BOOL is_handled, void *opaque); + bool is_handled, void *opaque); void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt)); #ifdef __cplusplus diff --git a/quickjs.c b/quickjs.c index b853f892..8bc34f38 100644 --- a/quickjs.c +++ b/quickjs.c @@ -269,11 +269,11 @@ struct JSRuntime { JSValue current_exception; /* true if inside an out of memory error, to avoid recursing */ - BOOL in_out_of_memory : 8; + bool in_out_of_memory; /* and likewise if inside Error.prepareStackTrace() */ - BOOL in_prepare_stack_trace : 8; + bool in_prepare_stack_trace; /* true if inside JS_FreeRuntime */ - BOOL in_free : 8; + bool in_free; struct JSStackFrame *current_stack_frame; @@ -294,7 +294,7 @@ struct JSRuntime { /* used to allocate, free and clone SharedArrayBuffers */ JSSharedArrayBufferFunctions sab_funcs; - BOOL can_block : 8; /* TRUE if Atomics.wait can block */ + bool can_block; /* true if Atomics.wait can block */ uint32_t dump_flags : 24; /* Shape hash table */ @@ -515,7 +515,7 @@ typedef struct JSClosureVar { uint8_t is_lexical : 1; uint8_t var_kind : 4; /* see JSVarKindEnum */ /* 8 bits available */ - uint16_t var_idx; /* is_local = TRUE: index to a normal variable of the + uint16_t var_idx; /* is_local = true: index to a normal variable of the parent function. otherwise: index to a closure variable of the parent function */ JSAtom var_name; @@ -725,7 +725,7 @@ typedef enum JSIteratorHelperKindEnum { typedef struct JSForInIterator { JSValue obj; - BOOL is_array; + bool is_array; uint32_t array_length; uint32_t idx; } JSForInIterator; @@ -759,13 +759,13 @@ typedef struct JSTypedArray { JSObject *buffer; /* based array buffer */ uint32_t offset; /* byte offset in the array buffer */ uint32_t length; /* byte length in the array buffer */ - BOOL track_rab; /* auto-track length of backing array buffer */ + bool track_rab; /* auto-track length of backing array buffer */ } JSTypedArray; typedef struct JSAsyncFunctionState { JSValue this_val; /* 'this' generator argument */ int argc; /* number of function arguments */ - BOOL throw_flag; /* used to throw an exception in JS_CallInternal() */ + bool throw_flag; /* used to throw an exception in JS_CallInternal() */ JSStackFrame frame; } JSAsyncFunctionState; @@ -774,7 +774,7 @@ typedef struct JSAsyncFunctionState { typedef struct JSAsyncFunctionData { JSGCObjectHeader header; /* must come first */ JSValue resolving_funcs[2]; - BOOL is_active; /* true if the async function state is valid */ + bool is_active; /* true if the async function state is valid */ JSAsyncFunctionState func_state; } JSAsyncFunctionData; @@ -845,9 +845,9 @@ struct JSModuleDef { JSValue module_ns; JSValue func_obj; /* only used for JS modules */ JSModuleInitFunc *init_func; /* only used for C modules */ - BOOL has_tla : 8; /* true if func_obj contains await */ - BOOL resolved : 8; - BOOL func_created : 8; + bool has_tla; /* true if func_obj contains await */ + bool resolved; + bool func_created; JSModuleStatus status : 8; /* temp use during js_module_link() & js_module_evaluate() */ int dfs_index, dfs_ancestor_index; @@ -857,14 +857,14 @@ struct JSModuleDef { int async_parent_modules_count; int async_parent_modules_size; int pending_async_dependencies; - BOOL async_evaluation; + bool async_evaluation; int64_t async_evaluation_timestamp; JSModuleDef *cycle_root; JSValue promise; /* corresponds to spec field: capability */ JSValue resolving_funcs[2]; /* corresponds to spec field: capability */ /* true if evaluation yielded an exception. It is saved in eval_exception */ - BOOL eval_has_exception : 8; + bool eval_has_exception; JSValue eval_exception; JSValue meta_obj; /* for import.meta */ }; @@ -935,10 +935,10 @@ struct JSObject { uint8_t extensible : 1; uint8_t free_mark : 1; /* only used when freeing objects with cycles */ - uint8_t is_exotic : 1; /* TRUE if object has exotic property handlers */ - uint8_t fast_array : 1; /* TRUE if u.array is used for get/put (for JS_CLASS_ARRAY, JS_CLASS_ARGUMENTS and typed arrays) */ - uint8_t is_constructor : 1; /* TRUE if object is a constructor function */ - uint8_t is_uncatchable_error : 1; /* if TRUE, error is not catchable */ + uint8_t is_exotic : 1; /* true if object has exotic property handlers */ + uint8_t fast_array : 1; /* true if u.array is used for get/put (for JS_CLASS_ARRAY, JS_CLASS_ARGUMENTS and typed arrays) */ + uint8_t is_constructor : 1; /* true if object is a constructor function */ + uint8_t is_uncatchable_error : 1; /* if true, error is not catchable */ uint8_t tmp_mark : 1; /* used in JS_WriteObjectRec() */ uint8_t is_HTMLDDA : 1; /* specific annex B IsHtmlDDA behavior */ uint16_t class_id; /* see JS_CLASS_x */ @@ -1016,7 +1016,7 @@ typedef struct JSCallSiteData { JSValue filename; JSValue func; JSValue func_name; - BOOL native; + bool native; int line_num; int col_num; } JSCallSiteData; @@ -1090,7 +1090,7 @@ static JSValue JS_CallFree(JSContext *ctx, JSValue func_obj, JSValue this_obj, static JSValue JS_InvokeFree(JSContext *ctx, JSValue this_val, JSAtom atom, int argc, JSValue *argv); static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, - JSValue val, BOOL is_array_ctor); + JSValue val, bool is_array_ctor); static JSValue JS_EvalObject(JSContext *ctx, JSValue this_obj, JSValue val, int flags, int scope_idx); JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...); @@ -1186,11 +1186,11 @@ typedef enum JSStrictEqModeEnum { JS_EQ_SAME_VALUE_ZERO, } JSStrictEqModeEnum; -static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, +static bool js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, JSStrictEqModeEnum eq_mode); -static BOOL js_strict_eq(JSContext *ctx, JSValue op1, JSValue op2); -static BOOL js_same_value(JSContext *ctx, JSValue op1, JSValue op2); -static BOOL js_same_value_zero(JSContext *ctx, JSValue op1, JSValue op2); +static bool js_strict_eq(JSContext *ctx, JSValue op1, JSValue op2); +static bool js_same_value(JSContext *ctx, JSValue op1, JSValue op2); +static bool js_same_value_zero(JSContext *ctx, JSValue op1, JSValue op2); static JSValue JS_ToObjectFree(JSContext *ctx, JSValue val); static JSProperty *add_property(JSContext *ctx, JSObject *p, JSAtom prop, int prop_flags); @@ -1210,7 +1210,7 @@ JSValue JS_ThrowOutOfMemory(JSContext *ctx); static JSValue JS_ThrowTypeErrorRevokedProxy(JSContext *ctx); static JSValue js_proxy_getPrototypeOf(JSContext *ctx, JSValue obj); static int js_proxy_setPrototypeOf(JSContext *ctx, JSValue obj, - JSValue proto_val, BOOL throw_flag); + JSValue proto_val, bool throw_flag); static int js_proxy_isExtensible(JSContext *ctx, JSValue obj); static int js_proxy_preventExtensions(JSContext *ctx, JSValue obj); static int js_proxy_isArray(JSContext *ctx, JSValue obj); @@ -1220,7 +1220,7 @@ static int JS_CreateProperty(JSContext *ctx, JSObject *p, int flags); static int js_string_memcmp(const JSString *p1, const JSString *p2, int len); static void reset_weak_ref(JSRuntime *rt, JSWeakRefRecord **first_weak_ref); -static BOOL is_valid_weakref_target(JSValue val); +static bool is_valid_weakref_target(JSValue val); static void insert_weakref_record(JSValue target, struct JSWeakRefRecord *wr); static JSValue js_array_buffer_constructor3(JSContext *ctx, JSValue new_target, @@ -1228,10 +1228,10 @@ static JSValue js_array_buffer_constructor3(JSContext *ctx, JSClassID class_id, uint8_t *buf, JSFreeArrayBufferDataFunc *free_func, - void *opaque, BOOL alloc_flag); + void *opaque, bool alloc_flag); static void js_array_buffer_free(JSRuntime *rt, void *opaque, void *ptr); static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValue obj); -static BOOL array_buffer_is_resizable(const JSArrayBuffer *abuf); +static bool array_buffer_is_resizable(const JSArrayBuffer *abuf); static JSValue js_typed_array_constructor(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, @@ -1240,12 +1240,12 @@ static JSValue js_typed_array_constructor_ta(JSContext *ctx, JSValue new_target, JSValue src_obj, int classid, uint32_t len); -static BOOL typed_array_is_oob(JSObject *p); +static bool typed_array_is_oob(JSObject *p); static uint32_t typed_array_get_length(JSContext *ctx, JSObject *p); static JSValue JS_ThrowTypeErrorDetachedArrayBuffer(JSContext *ctx); static JSValue JS_ThrowTypeErrorArrayBufferOOB(JSContext *ctx); static JSVarRef *get_var_ref(JSContext *ctx, JSStackFrame *sf, int var_idx, - BOOL is_arg); + bool is_arg); static JSValue js_generator_function_call(JSContext *ctx, JSValue func_obj, JSValue this_obj, int argc, JSValue *argv, @@ -1273,12 +1273,12 @@ static JSValue js_promise_resolve(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic); static JSValue js_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv); -static BOOL js_string_eq(const JSString *p1, const JSString *p2); +static bool js_string_eq(const JSString *p1, const JSString *p2); static int js_string_compare(const JSString *p1, const JSString *p2); static int JS_SetPropertyValue(JSContext *ctx, JSValue this_obj, JSValue prop, JSValue val, int flags); static int JS_NumberIsInteger(JSContext *ctx, JSValue val); -static BOOL JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValue val); +static bool JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValue val); static JSValue JS_ToNumberFree(JSContext *ctx, JSValue val); static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, JSObject *p, JSAtom prop); @@ -1300,7 +1300,7 @@ static __exception int js_set_length64(JSContext *ctx, JSValue obj, static void free_arg_list(JSContext *ctx, JSValue *tab, uint32_t len); static JSValue *build_arg_list(JSContext *ctx, uint32_t *plen, JSValue array_arg); -static BOOL js_get_fast_array(JSContext *ctx, JSValue obj, +static bool js_get_fast_array(JSContext *ctx, JSValue obj, JSValue **arrpp, uint32_t *countp); static JSValue JS_CreateAsyncFromSyncIterator(JSContext *ctx, JSValue sync_iter); @@ -1320,7 +1320,8 @@ static JSValue js_module_ns_autoinit(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); -static void js_set_uncatchable_error(JSContext *ctx, JSValue val, BOOL flag); + +static void js_set_uncatchable_error(JSContext *ctx, JSValue val, bool flag); static JSValue js_new_callsite(JSContext *ctx, JSCallSiteData *csd); static void js_new_callsite_data(JSContext *ctx, JSCallSiteData *csd, JSStackFrame *sf); @@ -1334,7 +1335,7 @@ static const JSClassExoticMethods js_string_exotic_methods; static const JSClassExoticMethods js_proxy_exotic_methods; static const JSClassExoticMethods js_module_ns_exotic_methods; -static inline BOOL double_is_int32(double d) +static inline bool double_is_int32(double d) { uint64_t u, e; JSFloat64Union t; @@ -1399,7 +1400,7 @@ JSValue JS_NewNumber(JSContext *ctx, double d) return js_number(d); } -static JSValue js_bool(JS_BOOL v) +static JSValue js_bool(bool v) { return JS_MKVAL(JS_TAG_BOOL, (v != 0)); } @@ -1425,9 +1426,9 @@ JSValue JS_DupValueRT(JSRuntime *rt, JSValue v) static void js_trigger_gc(JSRuntime *rt, size_t size) { - BOOL force_gc; + bool force_gc; #ifdef FORCE_GC_AT_MALLOC - force_gc = TRUE; + force_gc = true; #else force_gc = ((rt->malloc_state.malloc_size + size) > rt->malloc_gc_threshold); @@ -1792,7 +1793,7 @@ static inline uintptr_t js_get_stack_pointer(void) #endif } -static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size) +static inline bool js_check_stack_overflow(JSRuntime *rt, size_t alloca_size) { uintptr_t sp; sp = js_get_stack_pointer() - alloca_size; @@ -1955,7 +1956,7 @@ void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque) rt->interrupt_opaque = opaque; } -void JS_SetCanBlock(JSRuntime *rt, BOOL can_block) +void JS_SetCanBlock(JSRuntime *rt, bool can_block) { rt->can_block = can_block; } @@ -1989,7 +1990,7 @@ int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func, return 0; } -BOOL JS_IsJobPending(JSRuntime *rt) +bool JS_IsJobPending(JSRuntime *rt) { return !list_empty(&rt->job_list); } @@ -2030,7 +2031,7 @@ static inline uint32_t atom_get_free(const JSAtomStruct *p) return (uintptr_t)p >> 1; } -static inline BOOL atom_is_free(const JSAtomStruct *p) +static inline bool atom_is_free(const JSAtomStruct *p) { return (uintptr_t)p & 1; } @@ -2096,7 +2097,7 @@ void JS_FreeRuntime(JSRuntime *rt) struct list_head *el, *el1; int i; - rt->in_free = TRUE; + rt->in_free = true; JS_FreeValueRT(rt, rt->current_exception); list_for_each_safe(el, el1, &rt->job_list) { @@ -2112,7 +2113,7 @@ void JS_FreeRuntime(JSRuntime *rt) #ifdef DUMP_LEAKS /* leaking objects */ if (check_dump_flag(rt, DUMP_LEAKS)) { - BOOL header_done; + bool header_done; JSGCObjectHeader *p; int count; @@ -2124,14 +2125,14 @@ void JS_FreeRuntime(JSRuntime *rt) } gc_decref(rt); - header_done = FALSE; + header_done = false; list_for_each(el, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); if (p->ref_count != 0) { if (!header_done) { printf("Object leaks:\n"); JS_DumpObjectHeader(rt); - header_done = TRUE; + header_done = true; } JS_DumpGCObject(rt, p); } @@ -2165,14 +2166,14 @@ void JS_FreeRuntime(JSRuntime *rt) #ifdef DUMP_ATOM_LEAKS /* only the atoms defined in JS_InitAtoms() should be left */ if (check_dump_flag(rt, DUMP_ATOM_LEAKS)) { - BOOL header_done = FALSE; + bool header_done = false; for(i = 0; i < rt->atom_size; i++) { JSAtomStruct *p = rt->atom_array[i]; if (!atom_is_free(p) /* && p->str*/) { if (i >= JS_ATOM_END || p->header.ref_count != 1) { if (!header_done) { - header_done = TRUE; + header_done = true; if (rt->rt_info) { printf("%s:1: atom leakage:", rt->rt_info); } else { @@ -2552,7 +2553,7 @@ void JS_UpdateStackTop(JSRuntime *rt) update_stack_limit(rt); } -static inline BOOL is_strict_mode(JSContext *ctx) +static inline bool is_strict_mode(JSContext *ctx) { JSStackFrame *sf = ctx->rt->current_stack_frame; return sf && sf->is_strict_mode; @@ -2567,12 +2568,12 @@ static inline BOOL is_strict_mode(JSContext *ctx) /* return the max count from the hash size */ #define JS_ATOM_COUNT_RESIZE(n) ((n) * 2) -static inline BOOL __JS_AtomIsConst(JSAtom v) +static inline bool __JS_AtomIsConst(JSAtom v) { return (int32_t)v < JS_ATOM_END; } -static inline BOOL __JS_AtomIsTaggedInt(JSAtom v) +static inline bool __JS_AtomIsTaggedInt(JSAtom v) { return (v & JS_ATOM_TAG_INT) != 0; } @@ -2592,8 +2593,8 @@ static inline int is_num(int c) return c >= '0' && c <= '9'; } -/* return TRUE if the string is a number n with 0 <= n <= 2^32-1 */ -static inline BOOL is_num_string(uint32_t *pval, const JSString *p) +/* return true if the string is a number n with 0 <= n <= 2^32-1 */ +static inline bool is_num_string(uint32_t *pval, const JSString *p) { uint32_t n; uint64_t n64; @@ -2601,29 +2602,29 @@ static inline BOOL is_num_string(uint32_t *pval, const JSString *p) len = p->len; if (len == 0 || len > 10) - return FALSE; + return false; c = string_get(p, 0); if (is_num(c)) { if (c == '0') { if (len != 1) - return FALSE; + return false; n = 0; } else { n = c - '0'; for(i = 1; i < len; i++) { c = string_get(p, i); if (!is_num(c)) - return FALSE; + return false; n64 = (uint64_t)n * 10 + (c - '0'); if ((n64 >> 32) != 0) - return FALSE; + return false; n = n64; } } *pval = n; - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -3193,7 +3194,7 @@ static JSValue JS_NewSymbolFromAtom(JSContext *ctx, JSAtom descr, } /* `description` may be pure ASCII or UTF-8 encoded */ -JSValue JS_NewSymbol(JSContext *ctx, const char *description, JS_BOOL is_global) +JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global) { JSAtom atom = JS_NewAtom(ctx, description); if (atom == JS_ATOM_NULL) @@ -3245,7 +3246,7 @@ static const char *JS_AtomGetStr(JSContext *ctx, char *buf, int buf_size, JSAtom return JS_AtomGetStrRT(ctx->rt, buf, buf_size, atom); } -static JSValue __JS_AtomToValue(JSContext *ctx, JSAtom atom, BOOL force_string) +static JSValue __JS_AtomToValue(JSContext *ctx, JSAtom atom, bool force_string) { char buf[ATOM_GET_STR_BUF_SIZE]; @@ -3274,21 +3275,21 @@ static JSValue __JS_AtomToValue(JSContext *ctx, JSAtom atom, BOOL force_string) JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom) { - return __JS_AtomToValue(ctx, atom, FALSE); + return __JS_AtomToValue(ctx, atom, false); } JSValue JS_AtomToString(JSContext *ctx, JSAtom atom) { - return __JS_AtomToValue(ctx, atom, TRUE); + return __JS_AtomToValue(ctx, atom, true); } -/* return TRUE if the atom is an array index (i.e. 0 <= index <= +/* return true if the atom is an array index (i.e. 0 <= index <= 2^32-2 and return its value */ -static BOOL JS_AtomIsArrayIndex(JSContext *ctx, uint32_t *pval, JSAtom atom) +static bool JS_AtomIsArrayIndex(JSContext *ctx, uint32_t *pval, JSAtom atom) { if (__JS_AtomIsTaggedInt(atom)) { *pval = __JS_AtomToUInt32(atom); - return TRUE; + return true; } else { JSRuntime *rt = ctx->rt; JSAtomStruct *p; @@ -3299,10 +3300,10 @@ static BOOL JS_AtomIsArrayIndex(JSContext *ctx, uint32_t *pval, JSAtom atom) if (p->atom_type == JS_ATOM_TYPE_STRING && is_num_string(&val, p) && val != -1) { *pval = val; - return TRUE; + return true; } else { *pval = 0; - return FALSE; + return false; } } } @@ -3389,17 +3390,17 @@ static JSValue JS_AtomIsNumericIndex1(JSContext *ctx, JSAtom atom) } } -/* return -1 if exception or TRUE/FALSE */ +/* return -1 if exception or true/false */ static int JS_AtomIsNumericIndex(JSContext *ctx, JSAtom atom) { JSValue num; num = JS_AtomIsNumericIndex1(ctx, atom); if (likely(JS_IsUndefined(num))) - return FALSE; + return false; if (JS_IsException(num)) return -1; JS_FreeValue(ctx, num); - return TRUE; + return true; } void JS_FreeAtom(JSContext *ctx, JSAtom v) @@ -3414,15 +3415,15 @@ void JS_FreeAtomRT(JSRuntime *rt, JSAtom v) __JS_FreeAtom(rt, v); } -/* return TRUE if 'v' is a symbol with a string description */ -static BOOL JS_AtomSymbolHasDescription(JSContext *ctx, JSAtom v) +/* return true if 'v' is a symbol with a string description */ +static bool JS_AtomSymbolHasDescription(JSContext *ctx, JSAtom v) { JSRuntime *rt; JSAtomStruct *p; rt = ctx->rt; if (__JS_AtomIsTaggedInt(v)) - return FALSE; + return false; p = rt->atom_array[v]; return (((p->atom_type == JS_ATOM_TYPE_SYMBOL && p->hash == JS_ATOM_HASH_SYMBOL) || @@ -3524,7 +3525,7 @@ static JSAtom js_atom_concat_num(JSContext *ctx, JSAtom name, uint32_t n) return js_atom_concat_str(ctx, name, buf); } -static inline BOOL JS_IsEmptyString(JSValue v) +static inline bool JS_IsEmptyString(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_STRING && JS_VALUE_GET_STRING(v)->len == 0; } @@ -3551,7 +3552,7 @@ JSClassID JS_GetClassID(JSValue v) return p->class_id; } -BOOL JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id) +bool JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id) { return (class_id < rt->class_count && rt->class_array[class_id].class_id != 0); @@ -4122,7 +4123,7 @@ JSValue JS_NewAtomString(JSContext *ctx, const char *str) /* return (NULL, 0) if exception. */ /* return pointer into a JSString with a live ref_count */ /* cesu8 determines if non-BMP1 codepoints are encoded as 1 or 2 utf-8 sequences */ -const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValue val1, BOOL cesu8) +const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValue val1, bool cesu8) { JSValue val; JSString *str, *str_new; @@ -4288,9 +4289,9 @@ static int js_string_memcmp(const JSString *p1, const JSString *p2, int len) return res; } -static BOOL js_string_eq(const JSString *p1, const JSString *p2) { +static bool js_string_eq(const JSString *p1, const JSString *p2) { if (p1->len != p2->len) - return FALSE; + return false; return js_string_memcmp(p1, p2, p1->len) == 0; } @@ -4532,8 +4533,8 @@ static no_inline JSShape *js_new_shape2(JSContext *ctx, JSObject *proto, /* insert in the hash table */ sh->hash = shape_initial_hash(proto); - sh->is_hashed = TRUE; - sh->has_small_array_index = FALSE; + sh->is_hashed = true; + sh->has_small_array_index = false; js_shape_hash_link(ctx->rt, sh); return sh; } @@ -4564,7 +4565,7 @@ static JSShape *js_clone_shape(JSContext *ctx, JSShape *sh1) sh = get_shape_from_alloc(sh_alloc, hash_size); sh->header.ref_count = 1; add_gc_object(ctx->rt, &sh->header, JS_GC_OBJ_TYPE_SHAPE); - sh->is_hashed = FALSE; + sh->is_hashed = false; if (sh->proto) { js_dup(JS_MKPTR(JS_TAG_OBJECT, sh->proto)); } @@ -4898,7 +4899,7 @@ static JSValue JS_NewObjectFromShape(JSContext *ctx, JSShape *sh, JSClassID clas if (unlikely(!p)) goto fail; p->class_id = class_id; - p->extensible = TRUE; + p->extensible = true; p->free_mark = 0; p->is_exotic = 0; p->fast_array = 0; @@ -5072,7 +5073,7 @@ static void js_function_set_properties(JSContext *ctx, JSValue func_obj, JS_AtomToString(ctx, name), JS_PROP_CONFIGURABLE); } -static BOOL js_class_has_bytecode(JSClassID class_id) +static bool js_class_has_bytecode(JSClassID class_id) { return (class_id == JS_CLASS_BYTECODE_FUNCTION || class_id == JS_CLASS_GENERATOR_FUNCTION || @@ -5923,7 +5924,7 @@ static void gc_free_cycles(JSRuntime *rt) struct list_head *el, *el1; JSGCObjectHeader *p; #ifdef DUMP_GC_FREE - BOOL header_done = FALSE; + bool header_done = false; #endif rt->gc_phase = JS_GC_PHASE_REMOVE_CYCLES; @@ -5944,7 +5945,7 @@ static void gc_free_cycles(JSRuntime *rt) if (!header_done) { printf("Freeing cycles:\n"); JS_DumpObjectHeader(rt); - header_done = TRUE; + header_done = true; } JS_DumpGCObject(rt, p); } @@ -5985,11 +5986,11 @@ void JS_RunGC(JSRuntime *rt) /* Return false if not an object or if the object has already been freed (zombie objects are visible in finalizers when freeing cycles). */ -BOOL JS_IsLiveObject(JSRuntime *rt, JSValue obj) +bool JS_IsLiveObject(JSRuntime *rt, JSValue obj) { JSObject *p; if (!JS_IsObject(obj)) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); return !p->free_mark; } @@ -6494,7 +6495,7 @@ JSValue JS_GetException(JSContext *ctx) return val; } -JS_BOOL JS_HasException(JSContext *ctx) +bool JS_HasException(JSContext *ctx) { return !JS_IsUninitialized(ctx->rt->current_exception); } @@ -6645,7 +6646,7 @@ static void build_backtrace(JSContext *ctx, JSValue error_obj, JSValue filter_fu const char *str1; JSObject *p; JSFunctionBytecode *b; - BOOL backtrace_barrier, has_prepare; + bool backtrace_barrier, has_prepare; JSRuntime *rt; JSCallSiteData csd[64]; uint32_t i; @@ -6655,13 +6656,13 @@ static void build_backtrace(JSContext *ctx, JSValue error_obj, JSValue filter_fu stack_trace_limit = min_int(stack_trace_limit, countof(csd)); stack_trace_limit = max_int(stack_trace_limit, 0); rt = ctx->rt; - has_prepare = FALSE; + has_prepare = false; i = 0; if (!rt->in_prepare_stack_trace && !JS_IsNull(ctx->error_ctor)) { prepare = js_dup(ctx->error_prepare_stack); has_prepare = JS_IsFunction(ctx, prepare); - rt->in_prepare_stack_trace = TRUE; + rt->in_prepare_stack_trace = true; } if (has_prepare) { @@ -6708,7 +6709,7 @@ static void build_backtrace(JSContext *ctx, JSValue error_obj, JSValue filter_fu p = JS_VALUE_GET_OBJ(sf->cur_func); b = NULL; - backtrace_barrier = FALSE; + backtrace_barrier = false; if (js_class_has_bytecode(p->class_id)) { b = p->u.func.function_bytecode; @@ -6799,22 +6800,22 @@ static void build_backtrace(JSContext *ctx, JSValue error_obj, JSValue filter_fu dbuf_free(&dbuf); } - rt->in_prepare_stack_trace = FALSE; + rt->in_prepare_stack_trace = false; JS_DefinePropertyValue(ctx, error_obj, JS_ATOM_stack, stack, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); } /* Note: it is important that no exception is returned by this function */ -static BOOL is_backtrace_needed(JSContext *ctx, JSValue obj) +static bool is_backtrace_needed(JSContext *ctx, JSValue obj) { JSObject *p; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); if (p->class_id != JS_CLASS_ERROR) - return FALSE; + return false; if (find_own_property1(p, JS_ATOM_stack)) - return FALSE; - return TRUE; + return false; + return true; } JSValue JS_NewError(JSContext *ctx) @@ -6827,7 +6828,7 @@ JSValue JS_NewError(JSContext *ctx) } static JSValue JS_MakeError(JSContext *ctx, JSErrorEnum error_num, - const char *message, BOOL add_backtrace) + const char *message, bool add_backtrace) { JSValue obj, msg; @@ -6853,7 +6854,7 @@ static JSValue JS_MakeError(JSContext *ctx, JSErrorEnum error_num, /* fmt and arguments may be pure ASCII or UTF-8 encoded contents */ static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num, - const char *fmt, va_list ap, BOOL add_backtrace) + const char *fmt, va_list ap, bool add_backtrace) { char buf[256]; JSValue obj; @@ -6872,7 +6873,7 @@ static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num, { JSRuntime *rt = ctx->rt; JSStackFrame *sf; - BOOL add_backtrace; + bool add_backtrace; /* the backtrace is added later if called from a bytecode function */ sf = rt->current_stack_frame; @@ -6925,7 +6926,7 @@ static int __attribute__((format(printf, 3, 4))) JS_ThrowTypeErrorOrFalse(JSCont va_end(ap); return -1; } else { - return FALSE; + return false; } } @@ -6957,7 +6958,7 @@ static int JS_ThrowTypeErrorReadOnly(JSContext *ctx, int flags, JSAtom atom) JS_ThrowTypeErrorAtom(ctx, "'%s' is read-only", atom); return -1; } else { - return FALSE; + return false; } } @@ -6998,9 +6999,9 @@ JSValue JS_ThrowOutOfMemory(JSContext *ctx) { JSRuntime *rt = ctx->rt; if (!rt->in_out_of_memory) { - rt->in_out_of_memory = TRUE; + rt->in_out_of_memory = true; JS_ThrowInternalError(ctx, "out of memory"); - rt->in_out_of_memory = FALSE; + rt->in_out_of_memory = false; } return JS_EXCEPTION; } @@ -7037,7 +7038,7 @@ static JSValue JS_ThrowReferenceErrorUninitialized(JSContext *ctx, JSAtom name) static JSValue JS_ThrowReferenceErrorUninitialized2(JSContext *ctx, JSFunctionBytecode *b, - int idx, BOOL is_ref) + int idx, bool is_ref) { JSAtom atom = JS_ATOM_NULL; if (is_ref) { @@ -7066,7 +7067,7 @@ static no_inline __exception int __js_poll_interrupts(JSContext *ctx) if (rt->interrupt_handler(rt, rt->interrupt_opaque)) { /* XXX: should set a specific flag to avoid catching */ JS_ThrowInternalError(ctx, "interrupted"); - js_set_uncatchable_error(ctx, ctx->rt->current_exception, TRUE); + js_set_uncatchable_error(ctx, ctx->rt->current_exception, true); return -1; } } @@ -7082,10 +7083,10 @@ static inline __exception int js_poll_interrupts(JSContext *ctx) } } -/* return -1 (exception) or TRUE/FALSE */ +/* return -1 (exception) or true/false */ static int JS_SetPrototypeInternal(JSContext *ctx, JSValue obj, JSValue proto_val, - BOOL throw_flag) + bool throw_flag) { JSObject *proto, *p, *p1; JSShape *sh; @@ -7111,26 +7112,26 @@ static int JS_SetPrototypeInternal(JSContext *ctx, JSValue obj, } if (throw_flag && JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) - return TRUE; + return true; if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_setPrototypeOf(ctx, obj, proto_val, throw_flag); sh = p->shape; if (sh->proto == proto) - return TRUE; + return true; if (p == JS_VALUE_GET_OBJ(ctx->class_proto[JS_CLASS_OBJECT])) { if (throw_flag) { JS_ThrowTypeError(ctx, "'Immutable prototype object \'Object.prototype\' cannot have their prototype set'"); return -1; } - return FALSE; + return false; } if (!p->extensible) { if (throw_flag) { JS_ThrowTypeError(ctx, "object is not extensible"); return -1; } else { - return FALSE; + return false; } } if (proto) { @@ -7142,7 +7143,7 @@ static int JS_SetPrototypeInternal(JSContext *ctx, JSValue obj, JS_ThrowTypeError(ctx, "circular prototype chain"); return -1; } else { - return FALSE; + return false; } } /* Note: for Proxy objects, proto is NULL */ @@ -7157,13 +7158,13 @@ static int JS_SetPrototypeInternal(JSContext *ctx, JSValue obj, if (sh->proto) JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, sh->proto)); sh->proto = proto; - return TRUE; + return true; } -/* return -1 (exception) or TRUE/FALSE */ +/* return -1 (exception) or true/false */ int JS_SetPrototype(JSContext *ctx, JSValue obj, JSValue proto_val) { - return JS_SetPrototypeInternal(ctx, obj, proto_val, TRUE); + return JS_SetPrototypeInternal(ctx, obj, proto_val, true); } /* Only works for primitive types, otherwise return JS_NULL. */ @@ -7234,17 +7235,17 @@ int JS_SetLength(JSContext *ctx, JSValue obj, int64_t len) { return js_set_length64(ctx, obj, len); } -/* return TRUE, FALSE or (-1) in case of exception */ +/* return true, false or (-1) in case of exception */ static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValue val, JSValue obj) { JSValue obj_proto; JSObject *proto; const JSObject *p, *proto1; - BOOL ret; + int ret; if (!JS_IsFunction(ctx, obj)) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); if (p->class_id == JS_CLASS_BOUND_FUNCTION) { JSBoundFunction *s = p->u.bound_function; @@ -7253,7 +7254,7 @@ static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValue val, /* Only explicitly boxed values are instances of constructors */ if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; obj_proto = JS_GetProperty(ctx, obj, JS_ATOM_prototype); if (JS_VALUE_GET_TAG(obj_proto) != JS_TAG_OBJECT) { if (!JS_IsException(obj_proto)) @@ -7277,12 +7278,12 @@ static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValue val, break; } if (JS_IsNull(obj1)) { - ret = FALSE; + ret = false; break; } if (proto == JS_VALUE_GET_OBJ(obj1)) { JS_FreeValue(ctx, obj1); - ret = TRUE; + ret = true; break; } /* must check for timeout to avoid infinite loop */ @@ -7293,13 +7294,13 @@ static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValue val, } } } else { - ret = FALSE; + ret = false; } break; } p = proto1; if (proto == p) { - ret = TRUE; + ret = true; break; } } @@ -7308,7 +7309,7 @@ static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValue val, return ret; } -/* return TRUE, FALSE or (-1) in case of exception */ +/* return true, false or (-1) in case of exception */ int JS_IsInstanceOf(JSContext *ctx, JSValue val, JSValue obj) { JSValue method; @@ -7369,7 +7370,7 @@ static int JS_AutoInitProperty(JSContext *ctx, JSObject *p, JSAtom prop, static JSValue JS_GetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop, JSValue this_obj, JSInlineCacheUpdate *icu, - BOOL throw_ref_error) + bool throw_ref_error) { JSObject *p; JSProperty *pr; @@ -7516,20 +7517,20 @@ static JSValue JS_GetPropertyInternal2(JSContext *ctx, JSValue obj, static JSValue JS_GetPropertyInternal(JSContext *ctx, JSValue obj, JSAtom prop, JSValue this_obj, - BOOL throw_ref_error) + bool throw_ref_error) { return JS_GetPropertyInternal2(ctx, obj, prop, this_obj, NULL, throw_ref_error); } JSValue JS_GetProperty(JSContext *ctx, JSValue this_obj, JSAtom prop) { - return JS_GetPropertyInternal2(ctx, this_obj, prop, this_obj, NULL, FALSE); + return JS_GetPropertyInternal2(ctx, this_obj, prop, this_obj, NULL, false); } static JSValue JS_GetPropertyInternalWithIC(JSContext *ctx, JSValue obj, JSAtom prop, JSValue this_obj, JSInlineCacheUpdate *icu, - BOOL throw_ref_error) + bool throw_ref_error) { uint32_t tag, offset; JSObject *p; @@ -7753,7 +7754,7 @@ static int num_keys_cmp(const void *p1, const void *p2, void *opaque) JSAtom atom1 = ((const JSPropertyEnum *)p1)->atom; JSAtom atom2 = ((const JSPropertyEnum *)p2)->atom; uint32_t v1, v2; - BOOL atom1_is_integer, atom2_is_integer; + bool atom1_is_integer, atom2_is_integer; atom1_is_integer = JS_AtomIsArrayIndex(ctx, &v1, atom1); atom2_is_integer = JS_AtomIsArrayIndex(ctx, &v2, atom2); @@ -7790,7 +7791,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, JSAtom atom; uint32_t num_keys_count, str_keys_count, sym_keys_count, atom_count; uint32_t num_index, str_index, sym_index, exotic_count, exotic_keys_count; - BOOL is_enumerable, num_sorted; + bool is_enumerable, num_sorted; uint32_t num_key; JSAtomKindEnum kind; @@ -7853,7 +7854,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, atom = tab_exotic[i].atom; kind = JS_AtomGetKind(ctx, atom); if (((flags >> kind) & 1) != 0) { - is_enumerable = FALSE; + is_enumerable = false; if (flags & (JS_GPN_SET_ENUM | JS_GPN_ENUM_ONLY)) { JSPropertyDescriptor desc; int res; @@ -7893,7 +7894,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, str_index = num_keys_count; sym_index = str_index + str_keys_count; - num_sorted = TRUE; + num_sorted = true; sh = p->shape; for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { atom = prs->atom; @@ -7904,7 +7905,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, ((flags >> kind) & 1) != 0) { if (JS_AtomIsArrayIndex(ctx, &num_key, atom)) { j = num_index++; - num_sorted = FALSE; + num_sorted = false; } else if (kind == JS_ATOM_KIND_STRING) { j = str_index++; } else { @@ -7933,7 +7934,7 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, js_free_prop_enum(ctx, tab_atom, num_index); return -1; } - tab_atom[num_index].is_enumerable = TRUE; + tab_atom[num_index].is_enumerable = true; num_index++; } } @@ -7981,7 +7982,7 @@ int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab, } /* Return -1 if exception, - FALSE if the property does not exist, TRUE if it exists. If TRUE is + false if the property does not exist, true if it exists. If true is returned, the property descriptor 'desc' is filled present. */ static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, JSObject *p, JSAtom prop) @@ -8031,7 +8032,7 @@ static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, /* nothing to do: delay instantiation until actual value and/or attributes are read */ } } - return TRUE; + return true; } if (p->is_exotic) { if (p->fast_array) { @@ -8047,7 +8048,7 @@ static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, desc->setter = JS_UNDEFINED; desc->value = JS_GetPropertyUint32(ctx, JS_MKPTR(JS_TAG_OBJECT, p), idx); } - return TRUE; + return true; } } } else { @@ -8058,7 +8059,7 @@ static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, } } } - return FALSE; + return false; } int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc, @@ -8077,13 +8078,13 @@ void JS_FreePropertyEnum(JSContext *ctx, JSPropertyEnum *tab, js_free_prop_enum(ctx, tab, len); } -/* return -1 if exception (Proxy object only) or TRUE/FALSE */ +/* return -1 if exception (Proxy object only) or true/false */ int JS_IsExtensible(JSContext *ctx, JSValue obj) { JSObject *p; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_isExtensible(ctx, obj); @@ -8091,21 +8092,21 @@ int JS_IsExtensible(JSContext *ctx, JSValue obj) return p->extensible; } -/* return -1 if exception (Proxy object only) or TRUE/FALSE */ +/* return -1 if exception (Proxy object only) or true/false */ int JS_PreventExtensions(JSContext *ctx, JSValue obj) { JSObject *p; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_preventExtensions(ctx, obj); - p->extensible = FALSE; - return TRUE; + p->extensible = false; + return true; } -/* return -1 if exception otherwise TRUE or FALSE */ +/* return -1 if exception otherwise true or false */ int JS_HasProperty(JSContext *ctx, JSValue obj, JSAtom prop) { JSObject *p; @@ -8113,7 +8114,7 @@ int JS_HasProperty(JSContext *ctx, JSValue obj, JSAtom prop) JSValue obj1; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); for(;;) { if (p->is_exotic) { @@ -8138,14 +8139,14 @@ int JS_HasProperty(JSContext *ctx, JSValue obj, JSAtom prop) if (ret != 0) { if (ret < 0) return -1; - return FALSE; + return false; } } p = p->shape->proto; if (!p) break; } - return FALSE; + return false; } /* val must be a symbol */ @@ -8182,62 +8183,62 @@ JSAtom JS_ValueToAtom(JSContext *ctx, JSValue val) return atom; } -static BOOL js_get_fast_array_element(JSContext *ctx, JSObject *p, +static bool js_get_fast_array_element(JSContext *ctx, JSObject *p, uint32_t idx, JSValue *pval) { switch(p->class_id) { case JS_CLASS_ARRAY: case JS_CLASS_ARGUMENTS: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_dup(p->u.array.u.values[idx]); - return TRUE; + return true; case JS_CLASS_INT8_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_int32(p->u.array.u.int8_ptr[idx]); - return TRUE; + return true; case JS_CLASS_UINT8C_ARRAY: case JS_CLASS_UINT8_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_int32(p->u.array.u.uint8_ptr[idx]); - return TRUE; + return true; case JS_CLASS_INT16_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_int32(p->u.array.u.int16_ptr[idx]); - return TRUE; + return true; case JS_CLASS_UINT16_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_int32(p->u.array.u.uint16_ptr[idx]); - return TRUE; + return true; case JS_CLASS_INT32_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_int32(p->u.array.u.int32_ptr[idx]); - return TRUE; + return true; case JS_CLASS_UINT32_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_uint32(p->u.array.u.uint32_ptr[idx]); - return TRUE; + return true; case JS_CLASS_BIG_INT64_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = JS_NewBigInt64(ctx, p->u.array.u.int64_ptr[idx]); - return TRUE; + return true; case JS_CLASS_BIG_UINT64_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = JS_NewBigUint64(ctx, p->u.array.u.uint64_ptr[idx]); - return TRUE; + return true; case JS_CLASS_FLOAT16_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_float64(fromfp16(p->u.array.u.fp16_ptr[idx])); - return TRUE; + return true; case JS_CLASS_FLOAT32_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_float64(p->u.array.u.float_ptr[idx]); - return TRUE; + return true; case JS_CLASS_FLOAT64_ARRAY: - if (unlikely(idx >= p->u.array.count)) return FALSE; + if (unlikely(idx >= p->u.array.count)) return false; *pval = js_float64(p->u.array.u.double_ptr[idx]); - return TRUE; + return true; default: - return FALSE; + return false; } } @@ -8285,8 +8286,8 @@ JSValue JS_GetPropertyUint32(JSContext *ctx, JSValue this_obj, /* Check if an object has a generalized numeric property. Return value: -1 for exception, *pval set to JS_EXCEPTION - TRUE if property exists, stored into *pval, - FALSE if property does not exist. *pval set to JS_UNDEFINED. + true if property exists, stored into *pval, + false if property does not exist. *pval set to JS_UNDEFINED. */ static int JS_TryGetPropertyInt64(JSContext *ctx, JSValue obj, int64_t idx, JSValue *pval) { @@ -8299,7 +8300,7 @@ static int JS_TryGetPropertyInt64(JSContext *ctx, JSValue obj, int64_t idx, JSVa /* fast path for array and typed array access */ JSObject *p = JS_VALUE_GET_OBJ(obj); if (js_get_fast_array_element(ctx, p, idx, pval)) - return TRUE; + return true; } val = JS_EXCEPTION; present = -1; @@ -8310,7 +8311,7 @@ static int JS_TryGetPropertyInt64(JSContext *ctx, JSValue obj, int64_t idx, JSVa val = JS_GetProperty(ctx, obj, prop); if (unlikely(JS_IsException(val))) present = -1; - } else if (present == FALSE) { + } else if (present == false) { val = JS_UNDEFINED; } JS_FreeAtom(ctx, prop); @@ -8383,7 +8384,7 @@ static JSProperty *add_property(JSContext *ctx, if (!new_sh) return NULL; /* hash the cloned shape */ - new_sh->is_hashed = TRUE; + new_sh->is_hashed = true; js_shape_hash_link(ctx->rt, new_sh); js_free_shape(ctx->rt, p->shape); p->shape = new_sh; @@ -8451,7 +8452,7 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) if (likely(pr->atom == atom)) { /* found ! */ if (!(pr->flags & JS_PROP_CONFIGURABLE)) - return FALSE; + return false; /* realloc the shape if needed */ if (lpr) lpr_idx = lpr - get_shape_prop(sh); @@ -8480,7 +8481,7 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) sh->deleted_prop_count >= ((unsigned)sh->prop_count / 2)) { compact_properties(ctx, p); } - return TRUE; + return true; } lpr = pr; h = pr->hash_next; @@ -8497,13 +8498,13 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) if (idx == p->u.array.count - 1) { JS_FreeValue(ctx, p->u.array.u.values[idx]); p->u.array.count = idx; - return TRUE; + return true; } if (convert_fast_array_to_array(ctx, p)) return -1; goto redo; } else { - return FALSE; + return false; } } } else { @@ -8514,7 +8515,7 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) } } /* not found */ - return TRUE; + return true; } static int call_setter(JSContext *ctx, JSObject *setter, @@ -8530,7 +8531,7 @@ static int call_setter(JSContext *ctx, JSObject *setter, if (JS_IsException(ret)) return -1; JS_FreeValue(ctx, ret); - return TRUE; + return true; } else { JS_FreeValue(ctx, val); if ((flags & JS_PROP_THROW) || @@ -8538,7 +8539,7 @@ static int call_setter(JSContext *ctx, JSObject *setter, JS_ThrowTypeError(ctx, "no setter for property"); return -1; } - return FALSE; + return false; } } @@ -8550,7 +8551,7 @@ static int set_array_length(JSContext *ctx, JSObject *p, JSValue val, int i, ret; /* Note: this call can reallocate the properties of 'p' */ - ret = JS_ToArrayLengthFree(ctx, &len, val, FALSE); + ret = JS_ToArrayLengthFree(ctx, &len, val, false); if (ret) return -1; /* JS_ToArrayLengthFree() must be done before the read-only test */ @@ -8630,7 +8631,7 @@ static int set_array_length(JSContext *ctx, JSObject *p, JSValue val, return JS_ThrowTypeErrorOrFalse(ctx, flags, "not configurable"); } } - return TRUE; + return true; } /* return -1 if exception */ @@ -8651,7 +8652,7 @@ static int expand_fast_array(JSContext *ctx, JSObject *p, uint32_t new_len) } /* Preconditions: 'p' must be of class JS_CLASS_ARRAY, p->fast_array = - TRUE and p->extensible = TRUE */ + true and p->extensible = true */ static int add_fast_array_element(JSContext *ctx, JSObject *p, JSValue val, int flags) { @@ -8679,7 +8680,7 @@ static int add_fast_array_element(JSContext *ctx, JSObject *p, } p->u.array.u.values[new_len - 1] = val; p->u.array.count = new_len; - return TRUE; + return true; } static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc) @@ -8689,7 +8690,7 @@ static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc) JS_FreeValue(ctx, desc->value); } -/* return -1 in case of exception or TRUE or FALSE. Warning: 'val' is +/* return -1 in case of exception or true or false. Warning: 'val' is freed by the function. 'flags' is a bitmask of JS_PROP_NO_ADD, JS_PROP_THROW or JS_PROP_THROW_STRICT. If JS_PROP_NO_ADD is set, the new property is not added and an error is raised. @@ -8735,7 +8736,7 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop, /* fast case */ add_ic_slot(ctx, icu, prop, p, offset); set_value(ctx, &pr->u.value, val); - return TRUE; + return true; } else if (prs->flags & JS_PROP_LENGTH) { assert(p->class_id == JS_CLASS_ARRAY); assert(prop == JS_ATOM_length); @@ -8749,7 +8750,7 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop, if (p->class_id == JS_CLASS_MODULE_NS) goto read_only_prop; set_value(ctx, pr->u.var_ref->pvalue, val); - return TRUE; + return true; } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* Instantiate property and retry (potentially useless) */ if (JS_AutoInitProperty(ctx, p, prop, pr, prs)) @@ -8793,7 +8794,7 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop, if (JS_IsException(val)) return -1; } - return TRUE; + return true; } } } else { @@ -8899,7 +8900,7 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop, if (!pr) goto fail; pr->u.value = val; - return TRUE; + return true; } } @@ -8970,7 +8971,7 @@ static int JS_SetPropertyInternalWithIC(JSContext *ctx, JSValue this_obj, offset = get_ic_prop_offset(icu, p->shape); if (likely(offset != INLINE_CACHE_MISS)) { set_value(ctx, &p->prop[offset].u.value, val); - return TRUE; + return true; } slow_path: return JS_SetPropertyInternal2(ctx, this_obj, prop, val, this_obj, @@ -9090,7 +9091,7 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValue this_obj, ta_cvt_fail: if (flags & JS_PROP_REFLECT_DEFINE_PROPERTY) { JS_FreeValue(ctx, JS_GetException(ctx)); - return FALSE; + return false; } return -1; } @@ -9099,14 +9100,14 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValue this_obj, if (typed_array_is_oob(p)) if (flags & JS_PROP_DEFINE_PROPERTY) return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound numeric index"); - return TRUE; // per spec: no OOB exception + return true; // per spec: no OOB exception } p->u.array.u.double_ptr[idx] = d; break; default: goto slow_path; } - return TRUE; + return true; } else { JSAtom atom; int ret; @@ -9283,22 +9284,22 @@ static int JS_CreateProperty(JSContext *ctx, JSObject *p, pr->u.value = JS_UNDEFINED; } } - return TRUE; + return true; } -/* return FALSE if not OK */ -static BOOL check_define_prop_flags(int prop_flags, int flags) +/* return false if not OK */ +static bool check_define_prop_flags(int prop_flags, int flags) { - BOOL has_accessor, is_getset; + bool has_accessor, is_getset; if (!(prop_flags & JS_PROP_CONFIGURABLE)) { if ((flags & (JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE)) == (JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE)) { - return FALSE; + return false; } if ((flags & JS_PROP_HAS_ENUMERABLE) && (flags & JS_PROP_ENUMERABLE) != (prop_flags & JS_PROP_ENUMERABLE)) - return FALSE; + return false; } if (flags & (JS_PROP_HAS_VALUE | JS_PROP_HAS_WRITABLE | JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { @@ -9306,16 +9307,16 @@ static BOOL check_define_prop_flags(int prop_flags, int flags) has_accessor = ((flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) != 0); is_getset = ((prop_flags & JS_PROP_TMASK) == JS_PROP_GETSET); if (has_accessor != is_getset) - return FALSE; + return false; if (!has_accessor && !is_getset && !(prop_flags & JS_PROP_WRITABLE)) { /* not writable: cannot set the writable bit */ if ((flags & (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) == (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) - return FALSE; + return false; } } } - return TRUE; + return true; } /* ensure that the shape can be safely modified */ @@ -9340,7 +9341,7 @@ static int js_shape_prepare_update(JSContext *ctx, JSObject *p, *pprs = get_shape_prop(sh) + idx; } else { js_shape_hash_unlink(ctx->rt, sh); - sh->is_hashed = FALSE; + sh->is_hashed = false; } } return 0; @@ -9362,10 +9363,10 @@ static int js_update_property_flags(JSContext *ctx, JSObject *p, JS_PROP_HAS_GET, JS_PROP_HAS_SET, JS_PROP_HAS_VALUE, JS_PROP_HAS_CONFIGURABLE, JS_PROP_HAS_WRITABLE, JS_PROP_HAS_ENUMERABLE, JS_PROP_THROW, JS_PROP_NO_EXOTIC. - If JS_PROP_THROW is set, return an exception instead of FALSE. + If JS_PROP_THROW is set, return an exception instead of false. if JS_PROP_NO_EXOTIC is set, do not call the exotic define_own_property callback. - return -1 (exception), FALSE or TRUE. + return -1 (exception), false or true. */ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, JSAtom prop, JSValue val, @@ -9389,7 +9390,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, if ((prs->flags & JS_PROP_LENGTH) && (flags & JS_PROP_HAS_VALUE)) { uint32_t array_length; if (JS_ToArrayLengthFree(ctx, &array_length, - js_dup(val), FALSE)) { + js_dup(val), false)) { return -1; } /* this code relies on the fact that Uint32 are never allocated */ @@ -9486,7 +9487,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, if (!js_same_value(ctx, val, pr->u.value)) { goto not_configurable; } else { - return TRUE; + return true; } } } @@ -9521,7 +9522,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, res = set_array_length(ctx, p, js_dup(val), flags); } else { - res = TRUE; + res = true; } /* still need to reset the writable flag if needed. The JS_PROP_LENGTH is kept because the @@ -9557,7 +9558,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, if (js_update_property_flags(ctx, p, &prs, (prs->flags & ~mask) | (flags & mask))) return -1; - return TRUE; + return true; } /* handle modification of fast array elements */ @@ -9581,7 +9582,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, if (flags & JS_PROP_HAS_VALUE) { set_value(ctx, &p->u.array.u.values[idx], js_dup(val)); } - return TRUE; + return true; } } } else if (p->class_id >= JS_CLASS_UINT8C_ARRAY && @@ -9627,7 +9628,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj, if (flags & JS_PROP_HAS_VALUE) { return JS_SetPropertyValue(ctx, this_obj, js_int32(idx), js_dup(val), flags); } - return TRUE; + return true; typed_array_done: ; } } @@ -9643,14 +9644,14 @@ static int JS_DefineAutoInitProperty(JSContext *ctx, JSValue this_obj, JSProperty *pr; if (JS_VALUE_GET_TAG(this_obj) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(this_obj); if (find_own_property(&pr, p, prop)) { /* property already exists */ abort(); - return FALSE; + return false; } /* Specialized CreateProperty */ @@ -9662,7 +9663,7 @@ static int JS_DefineAutoInitProperty(JSContext *ctx, JSValue this_obj, assert(id <= 3); pr->u.init.realm_and_id |= id; pr->u.init.opaque = opaque; - return TRUE; + return true; } /* shortcut to add or redefine a new property value */ @@ -9741,8 +9742,8 @@ static int JS_CreateDataPropertyUint32(JSContext *ctx, JSValue this_obj, } -/* return TRUE if 'obj' has a non empty 'name' string */ -static BOOL js_object_has_name(JSContext *ctx, JSValue obj) +/* return true if 'obj' has a non empty 'name' string */ +static bool js_object_has_name(JSContext *ctx, JSValue obj) { JSProperty *pr; JSShapeProperty *prs; @@ -9751,12 +9752,12 @@ static BOOL js_object_has_name(JSContext *ctx, JSValue obj) prs = find_own_property(&pr, JS_VALUE_GET_OBJ(obj), JS_ATOM_name); if (!prs) - return FALSE; + return false; if ((prs->flags & JS_PROP_TMASK) != JS_PROP_NORMAL) - return TRUE; + return true; val = pr->u.value; if (JS_VALUE_GET_TAG(val) != JS_TAG_STRING) - return TRUE; + return true; p = JS_VALUE_GET_STRING(val); return (p->len != 0); } @@ -9900,7 +9901,7 @@ static int JS_DefineGlobalFunction(JSContext *ctx, JSAtom prop, } static JSValue JS_GetGlobalVar(JSContext *ctx, JSAtom prop, - BOOL throw_ref_error) + bool throw_ref_error) { JSObject *p; JSShapeProperty *prs; @@ -9967,7 +9968,7 @@ static int JS_CheckGlobalVar(JSContext *ctx, JSAtom prop) p = JS_VALUE_GET_OBJ(ctx->global_var_obj); prs = find_own_property1(p, prop); if (prs) { - ret = TRUE; + ret = true; } else { ret = JS_HasProperty(ctx, ctx->global_obj, prop); if (ret < 0) @@ -10013,7 +10014,7 @@ static int JS_SetGlobalVar(JSContext *ctx, JSAtom prop, JSValue val, return JS_SetPropertyInternal(ctx, ctx->global_obj, prop, val, flags); } -/* return -1, FALSE or TRUE. return FALSE if not configurable or +/* return -1, false or true. return false if not configurable or invalid object. return -1 in case of exception. flags can be 0, JS_PROP_THROW or JS_PROP_THROW_STRICT */ int JS_DeleteProperty(JSContext *ctx, JSValue obj, JSAtom prop, int flags) @@ -10028,14 +10029,14 @@ int JS_DeleteProperty(JSContext *ctx, JSValue obj, JSAtom prop, int flags) p = JS_VALUE_GET_OBJ(obj1); res = delete_property(ctx, p, prop); JS_FreeValue(ctx, obj1); - if (res != FALSE) + if (res != false) return res; if ((flags & JS_PROP_THROW) || ((flags & JS_PROP_THROW_STRICT) && is_strict_mode(ctx))) { JS_ThrowTypeError(ctx, "could not delete property"); return -1; } - return FALSE; + return false; } int JS_DeletePropertyInt64(JSContext *ctx, JSValue obj, int64_t idx, int flags) @@ -10055,15 +10056,15 @@ int JS_DeletePropertyInt64(JSContext *ctx, JSValue obj, int64_t idx, int flags) return res; } -BOOL JS_IsFunction(JSContext *ctx, JSValue val) +bool JS_IsFunction(JSContext *ctx, JSValue val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(val); switch(p->class_id) { case JS_CLASS_BYTECODE_FUNCTION: - return TRUE; + return true; case JS_CLASS_PROXY: return p->u.proxy_data->is_func; default: @@ -10071,71 +10072,71 @@ BOOL JS_IsFunction(JSContext *ctx, JSValue val) } } -BOOL JS_IsCFunction(JSContext *ctx, JSValue val, JSCFunction *func, int magic) +bool JS_IsCFunction(JSContext *ctx, JSValue val, JSCFunction *func, int magic) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(val); if (p->class_id == JS_CLASS_C_FUNCTION) return (p->u.cfunc.c_function.generic == func && p->u.cfunc.magic == magic); else - return FALSE; + return false; } -BOOL JS_IsConstructor(JSContext *ctx, JSValue val) +bool JS_IsConstructor(JSContext *ctx, JSValue val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(val); return p->is_constructor; } -BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, BOOL val) +bool JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, bool val) { JSObject *p; if (JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(func_obj); p->is_constructor = val; - return TRUE; + return true; } -JS_BOOL JS_IsRegExp(JSValue val) +bool JS_IsRegExp(JSValue val) { if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_REGEXP; } -JS_BOOL JS_IsMap(JSValue val) +bool JS_IsMap(JSValue val) { if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_MAP; } -BOOL JS_IsError(JSContext *ctx, JSValue val) +bool JS_IsError(JSContext *ctx, JSValue val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(val); return (p->class_id == JS_CLASS_ERROR); } /* used to avoid catching interrupt exceptions */ -BOOL JS_IsUncatchableError(JSContext *ctx, JSValue val) +bool JS_IsUncatchableError(JSContext *ctx, JSValue val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(val); return p->class_id == JS_CLASS_ERROR && p->is_uncatchable_error; } -static void js_set_uncatchable_error(JSContext *ctx, JSValue val, BOOL flag) +static void js_set_uncatchable_error(JSContext *ctx, JSValue val, bool flag) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) @@ -10147,17 +10148,17 @@ static void js_set_uncatchable_error(JSContext *ctx, JSValue val, BOOL flag) void JS_SetUncatchableError(JSContext *ctx, JSValue val) { - js_set_uncatchable_error(ctx, val, TRUE); + js_set_uncatchable_error(ctx, val, true); } void JS_ClearUncatchableError(JSContext *ctx, JSValue val) { - js_set_uncatchable_error(ctx, val, FALSE); + js_set_uncatchable_error(ctx, val, false); } void JS_ResetUncatchableError(JSContext *ctx) { - js_set_uncatchable_error(ctx, ctx->rt->current_exception, FALSE); + js_set_uncatchable_error(ctx, ctx->rt->current_exception, false); } int JS_SetOpaque(JSValue obj, void *opaque) @@ -10221,7 +10222,7 @@ void *JS_GetAnyOpaque(JSValue obj, JSClassID *class_id) static JSValue JS_ToPrimitiveFree(JSContext *ctx, JSValue val, int hint) { int i; - BOOL force_ordinary; + bool force_ordinary; JSAtom method_name; JSValue method, ret; @@ -10303,14 +10304,14 @@ void JS_SetIsHTMLDDA(JSContext *ctx, JSValue obj) if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return; p = JS_VALUE_GET_OBJ(obj); - p->is_HTMLDDA = TRUE; + p->is_HTMLDDA = true; } -static inline BOOL JS_IsHTMLDDA(JSContext *ctx, JSValue obj) +static inline bool JS_IsHTMLDDA(JSContext *ctx, JSValue obj) { JSObject *p; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) - return FALSE; + return false; p = JS_VALUE_GET_OBJ(obj); return p->is_HTMLDDA; } @@ -10329,14 +10330,14 @@ static int JS_ToBoolFree(JSContext *ctx, JSValue val) return -1; case JS_TAG_STRING: { - BOOL ret = JS_VALUE_GET_STRING(val)->len != 0; + bool ret = JS_VALUE_GET_STRING(val)->len != 0; JS_FreeValue(ctx, val); return ret; } case JS_TAG_BIG_INT: { JSBigInt *p = JS_VALUE_GET_PTR(val); - BOOL ret; + bool ret; ret = p->num.expn != BF_EXP_ZERO && p->num.expn != BF_EXP_NAN; JS_FreeValue(ctx, val); return ret; @@ -10344,8 +10345,7 @@ static int JS_ToBoolFree(JSContext *ctx, JSValue val) case JS_TAG_OBJECT: { JSObject *p = JS_VALUE_GET_OBJ(val); - BOOL ret; - ret = !p->is_HTMLDDA; + bool ret = !p->is_HTMLDDA; JS_FreeValue(ctx, val); return ret; } @@ -10356,7 +10356,7 @@ static int JS_ToBoolFree(JSContext *ctx, JSValue val) return !isnan(d) && d != 0; } else { JS_FreeValue(ctx, val); - return TRUE; + return true; } } } @@ -10402,7 +10402,7 @@ static inline int to_digit(int c) } /* XXX: remove */ -static double js_strtod(const char *str, int radix, BOOL is_float) +static double js_strtod(const char *str, int radix, bool is_float) { double d; int c; @@ -10500,7 +10500,7 @@ static JSValue js_atof(JSContext *ctx, const char *p, size_t len, const char *p_start; const char *end = p + len; int sep; - BOOL is_float; + bool is_float; char buf1[64], *buf = buf1; size_t i, j; JSValue val = JS_NAN; @@ -10551,7 +10551,7 @@ static JSValue js_atof(JSContext *ctx, const char *p, size_t len, goto done; } } - is_float = FALSE; + is_float = false; p_start = p; while (to_digit(*p) < radix) { p++; @@ -10560,7 +10560,7 @@ static JSValue js_atof(JSContext *ctx, const char *p, size_t len, } if ((flags & ATOD_ACCEPT_FLOAT) && radix == 10) { if (*p == '.' && (p > p_start || to_digit(p[1]) < radix)) { - is_float = TRUE; + is_float = true; p++; while (to_digit(*p) < radix) { p++; @@ -10574,7 +10574,7 @@ static JSValue js_atof(JSContext *ctx, const char *p, size_t len, i++; } if (is_digit(p[i])) { - is_float = TRUE; + is_float = true; p += i + 1; while (is_digit(*p) || (*p == sep && is_digit(p[1]))) p++; @@ -11114,7 +11114,7 @@ static int JS_ToUint8ClampFree(JSContext *ctx, int32_t *pres, JSValue val) } static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, - JSValue val, BOOL is_array_ctor) + JSValue val, bool is_array_ctor) { uint32_t tag, len; @@ -11135,7 +11135,7 @@ static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, { JSBigInt *p = JS_VALUE_GET_PTR(val); bf_t a; - BOOL res; + bool res; bf_get_int32((int32_t *)&len, &p->num, BF_GET_INT_MOD); bf_init(ctx->bf_ctx, &a); bf_set_ui(&a, len); @@ -11163,7 +11163,7 @@ static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, if (JS_IsException(val)) return -1; /* cannot recurse because val is a number */ - if (JS_ToArrayLengthFree(ctx, &len, val, TRUE)) + if (JS_ToArrayLengthFree(ctx, &len, val, true)) return -1; } else { /* legacy behavior: must do the conversion twice and compare */ @@ -11175,7 +11175,7 @@ static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, if (JS_IsException(val)) return -1; /* cannot recurse because val is a number */ - if (JS_ToArrayLengthFree(ctx, &len1, val, FALSE)) + if (JS_ToArrayLengthFree(ctx, &len1, val, false)) return -1; if (len1 != len) { fail: @@ -11192,7 +11192,7 @@ static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, #define MAX_SAFE_INTEGER (((int64_t)1 << 53) - 1) -static BOOL is_safe_integer(double d) +static bool is_safe_integer(double d) { return isfinite(d) && floor(d) == d && fabs(d) <= (double)MAX_SAFE_INTEGER; @@ -11227,13 +11227,13 @@ static int JS_NumberIsInteger(JSContext *ctx, JSValue val) { double d; if (!JS_IsNumber(val)) - return FALSE; + return false; if (unlikely(JS_ToFloat64(ctx, &d, val))) return -1; return isfinite(d) && floor(d) == d; } -static BOOL JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValue val) +static bool JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValue val) { uint32_t tag; @@ -11258,7 +11258,7 @@ static BOOL JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValue val) return p->num.sign && !bf_is_zero(&p->num); } default: - return FALSE; + return false; } } @@ -11715,7 +11715,7 @@ static JSValue js_dtoa_radix(JSContext *ctx, double d, int radix) return js_new_string8_len(ctx, ptr, ptr2 - ptr); } -JSValue JS_ToStringInternal(JSContext *ctx, JSValue val, BOOL is_ToPropertyKey) +JSValue JS_ToStringInternal(JSContext *ctx, JSValue val, bool is_ToPropertyKey) { uint32_t tag; char buf[32]; @@ -11769,7 +11769,7 @@ JSValue JS_ToStringInternal(JSContext *ctx, JSValue val, BOOL is_ToPropertyKey) JSValue JS_ToString(JSContext *ctx, JSValue val) { - return JS_ToStringInternal(ctx, val, FALSE); + return JS_ToStringInternal(ctx, val, false); } static JSValue JS_ToStringFree(JSContext *ctx, JSValue val) @@ -11789,7 +11789,7 @@ static JSValue JS_ToLocaleStringFree(JSContext *ctx, JSValue val) JSValue JS_ToPropertyKey(JSContext *ctx, JSValue val) { - return JS_ToStringInternal(ctx, val, TRUE); + return JS_ToStringInternal(ctx, val, true); } static JSValue JS_ToStringCheckObject(JSContext *ctx, JSValue val) @@ -11881,7 +11881,7 @@ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p) JSShape *sh; JSShapeProperty *prs; JSProperty *pr; - BOOL is_first = TRUE; + bool is_first = true; /* XXX: should encode atoms with special characters */ sh = p->shape; /* the shape can be NULL while freeing an object */ @@ -11954,7 +11954,7 @@ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p) } else { JS_DumpValue(rt, pr->u.value); } - is_first = FALSE; + is_first = false; } } printf(" }"); @@ -12097,7 +12097,7 @@ static __maybe_unused void JS_DumpValue(JSRuntime *rt, JSValue val) } } -/* return -1 if exception (proxy case) or TRUE/FALSE */ +/* return -1 if exception (proxy case) or true/false */ int JS_IsArray(JSContext *ctx, JSValue val) { JSObject *p; @@ -12108,7 +12108,7 @@ int JS_IsArray(JSContext *ctx, JSValue val) else return p->class_id == JS_CLASS_ARRAY; } else { - return FALSE; + return false; } } @@ -13020,7 +13020,7 @@ static no_inline int js_relational_slow(JSContext *ctx, JSValue *sp, invalid_bigint_string: JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); - res = FALSE; + res = false; goto done; } } @@ -13085,14 +13085,14 @@ static no_inline int js_relational_slow(JSContext *ctx, JSValue *sp, return -1; } -static BOOL tag_is_number(uint32_t tag) +static bool tag_is_number(uint32_t tag) { return (tag == JS_TAG_INT || tag == JS_TAG_BIG_INT || tag == JS_TAG_FLOAT64); } static no_inline __exception int js_eq_slow(JSContext *ctx, JSValue *sp, - BOOL is_neq) + bool is_neq) { JSValue op1, op2; int res; @@ -13131,7 +13131,7 @@ static no_inline __exception int js_eq_slow(JSContext *ctx, JSValue *sp, res = js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT); } else if ((tag1 == JS_TAG_NULL && tag2 == JS_TAG_UNDEFINED) || (tag2 == JS_TAG_NULL && tag1 == JS_TAG_UNDEFINED)) { - res = TRUE; + res = true; } else if ((tag1 == JS_TAG_STRING && tag_is_number(tag2)) || (tag2 == JS_TAG_STRING && tag_is_number(tag1))) { @@ -13147,7 +13147,7 @@ static no_inline __exception int js_eq_slow(JSContext *ctx, JSValue *sp, invalid_bigint_string: JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); - res = FALSE; + res = false; goto done; } } @@ -13191,9 +13191,9 @@ static no_inline __exception int js_eq_slow(JSContext *ctx, JSValue *sp, (tag2 == JS_TAG_NULL || tag2 == JS_TAG_UNDEFINED)) || (JS_IsHTMLDDA(ctx, op2) && (tag1 == JS_TAG_NULL || tag1 == JS_TAG_UNDEFINED))) { - res = TRUE; + res = true; } else { - res = FALSE; + res = false; } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); @@ -13245,10 +13245,10 @@ static no_inline int js_shr_slow(JSContext *ctx, JSValue *sp) } /* XXX: Should take JSValue arguments */ -static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, +static bool js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, JSStrictEqModeEnum eq_mode) { - BOOL res; + bool res; int tag1, tag2; double d1, d2; @@ -13257,7 +13257,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, switch(tag1) { case JS_TAG_BOOL: if (tag1 != tag2) { - res = FALSE; + res = false; } else { res = JS_VALUE_GET_INT(op1) == JS_VALUE_GET_INT(op2); goto done_no_free; @@ -13271,7 +13271,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, { JSString *p1, *p2; if (tag1 != tag2) { - res = FALSE; + res = false; } else { p1 = JS_VALUE_GET_STRING(op1); p2 = JS_VALUE_GET_STRING(op2); @@ -13283,7 +13283,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, { JSAtomStruct *p1, *p2; if (tag1 != tag2) { - res = FALSE; + res = false; } else { p1 = JS_VALUE_GET_PTR(op1); p2 = JS_VALUE_GET_PTR(op2); @@ -13293,7 +13293,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, break; case JS_TAG_OBJECT: if (tag1 != tag2) - res = FALSE; + res = false; else res = JS_VALUE_GET_OBJ(op1) == JS_VALUE_GET_OBJ(op2); break; @@ -13306,7 +13306,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, d2 = JS_VALUE_GET_FLOAT64(op2); goto number_test; } else { - res = FALSE; + res = false; } break; case JS_TAG_FLOAT64: @@ -13316,7 +13316,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, } else if (tag2 == JS_TAG_INT) { d2 = JS_VALUE_GET_INT(op2); } else { - res = FALSE; + res = false; break; } number_test: @@ -13340,7 +13340,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, { bf_t a_s, *a, b_s, *b; if (tag1 != tag2) { - res = FALSE; + res = false; break; } a = JS_ToBigInt1(ctx, &a_s, op1); @@ -13353,7 +13353,7 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, } break; default: - res = FALSE; + res = false; break; } JS_FreeValue(ctx, op1); @@ -13362,25 +13362,25 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, return res; } -static BOOL js_strict_eq(JSContext *ctx, JSValue op1, JSValue op2) +static bool js_strict_eq(JSContext *ctx, JSValue op1, JSValue op2) { return js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT); } -static BOOL js_same_value(JSContext *ctx, JSValue op1, JSValue op2) +static bool js_same_value(JSContext *ctx, JSValue op1, JSValue op2) { return js_strict_eq2(ctx, js_dup(op1), js_dup(op2), JS_EQ_SAME_VALUE); } -static BOOL js_same_value_zero(JSContext *ctx, JSValue op1, JSValue op2) +static bool js_same_value_zero(JSContext *ctx, JSValue op1, JSValue op2) { return js_strict_eq2(ctx, js_dup(op1), js_dup(op2), JS_EQ_SAME_VALUE_ZERO); } static no_inline int js_strict_eq_slow(JSContext *ctx, JSValue *sp, - BOOL is_neq) + bool is_neq) { - BOOL res; + bool res; res = js_strict_eq(ctx, sp[-2], sp[-1]); sp[-2] = js_bool(res ^ is_neq); return 0; @@ -13468,7 +13468,7 @@ static __exception int js_has_unscopable(JSContext *ctx, JSValue obj, static __exception int js_operator_instanceof(JSContext *ctx, JSValue *sp) { JSValue op1, op2; - BOOL ret; + int ret; op1 = sp[-2]; op2 = sp[-1]; @@ -13690,7 +13690,7 @@ static JSValue js_build_mapped_arguments(JSContext *ctx, int argc, for(i = 0; i < arg_count; i++) { JSVarRef *var_ref; - var_ref = get_var_ref(ctx, sf, i, TRUE); + var_ref = get_var_ref(ctx, sf, i, true); if (!var_ref) goto fail; pr = add_property(ctx, p, __JS_AtomFromUInt32(i), JS_PROP_C_W_E | JS_PROP_VARREF); @@ -13768,7 +13768,7 @@ static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj) JS_FreeValue(ctx, obj); return JS_EXCEPTION; } - it->is_array = FALSE; + it->is_array = false; it->obj = obj; it->idx = 0; p = JS_VALUE_GET_OBJ(enum_obj); @@ -13815,7 +13815,7 @@ static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj) goto normal_case; } /* for fast arrays, we only store the number of elements */ - it->is_array = TRUE; + it->is_array = true; it->array_length = p->u.array.count; } else { normal_case: @@ -13947,7 +13947,7 @@ static JSValue JS_GetIterator2(JSContext *ctx, JSValue obj, return enum_obj; } -static JSValue JS_GetIterator(JSContext *ctx, JSValue obj, BOOL is_async) +static JSValue JS_GetIterator(JSContext *ctx, JSValue obj, bool is_async) { JSValue method, ret, sync_iter; @@ -14018,13 +14018,13 @@ static JSValue JS_IteratorNext2(JSContext *ctx, JSValue enum_obj, *pdone = 2; return obj; fail: - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } static JSValue JS_IteratorNext(JSContext *ctx, JSValue enum_obj, JSValue method, - int argc, JSValue *argv, BOOL *pdone) + int argc, JSValue *argv, int *pdone) { JSValue obj, value, done_val; int done; @@ -14049,13 +14049,13 @@ static JSValue JS_IteratorNext(JSContext *ctx, JSValue enum_obj, } fail: JS_FreeValue(ctx, obj); - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } /* return < 0 in case of exception */ static int JS_IteratorClose(JSContext *ctx, JSValue enum_obj, - BOOL is_exception_pending) + bool is_exception_pending) { JSValue method, ret, ex_obj; int res; @@ -14095,7 +14095,7 @@ static int JS_IteratorClose(JSContext *ctx, JSValue enum_obj, /* obj -> enum_rec (3 slots) */ static __exception int js_for_of_start(JSContext *ctx, JSValue *sp, - BOOL is_async) + bool is_async) { JSValue op1, obj, method; op1 = sp[-1]; @@ -14143,10 +14143,10 @@ static __exception int js_for_of_next(JSContext *ctx, JSValue *sp, int offset) } static JSValue JS_IteratorGetCompleteValue(JSContext *ctx, JSValue obj, - BOOL *pdone) + int *pdone) { JSValue done_val, value; - BOOL done; + int done; done_val = JS_GetProperty(ctx, obj, JS_ATOM_done); if (JS_IsException(done_val)) goto fail; @@ -14157,14 +14157,14 @@ static JSValue JS_IteratorGetCompleteValue(JSContext *ctx, JSValue obj, *pdone = done; return value; fail: - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } static __exception int js_iterator_get_value_done(JSContext *ctx, JSValue *sp) { JSValue obj, value; - BOOL done; + int done; obj = sp[-1]; if (!JS_IsObject(obj)) { JS_ThrowTypeError(ctx, "iterator must return an object"); @@ -14181,7 +14181,7 @@ static __exception int js_iterator_get_value_done(JSContext *ctx, JSValue *sp) static JSValue js_create_iterator_result(JSContext *ctx, JSValue val, - BOOL done) + bool done) { JSValue obj; obj = JS_NewObject(ctx); @@ -14204,25 +14204,25 @@ static JSValue js_create_iterator_result(JSContext *ctx, static JSValue js_array_iterator_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic); + int *pdone, int magic); static JSValue js_create_array_iterator(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic); -static BOOL js_is_fast_array(JSContext *ctx, JSValue obj) +static bool js_is_fast_array(JSContext *ctx, JSValue obj) { /* Try and handle fast arrays explicitly */ if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { JSObject *p = JS_VALUE_GET_OBJ(obj); if (p->class_id == JS_CLASS_ARRAY && p->fast_array) { - return TRUE; + return true; } } - return FALSE; + return false; } /* Access an Array's internal JSValue array if available */ -static BOOL js_get_fast_array(JSContext *ctx, JSValue obj, +static bool js_get_fast_array(JSContext *ctx, JSValue obj, JSValue **arrpp, uint32_t *countp) { /* Try and handle fast arrays explicitly */ @@ -14231,10 +14231,10 @@ static BOOL js_get_fast_array(JSContext *ctx, JSValue obj, if (p->class_id == JS_CLASS_ARRAY && p->fast_array) { *countp = p->u.array.count; *arrpp = p->u.array.u.values; - return TRUE; + return true; } } - return FALSE; + return false; } static __exception int js_append_enumerate(JSContext *ctx, JSValue *sp) @@ -14267,7 +14267,7 @@ static __exception int js_append_enumerate(JSContext *ctx, JSValue *sp) JS_ITERATOR_KIND_VALUE); JS_FreeValue(ctx, iterator); - enumobj = JS_GetIterator(ctx, sp[-1], FALSE); + enumobj = JS_GetIterator(ctx, sp[-1], false); if (JS_IsException(enumobj)) return -1; method = JS_GetProperty(ctx, enumobj, JS_ATOM_next); @@ -14296,7 +14296,7 @@ static __exception int js_append_enumerate(JSContext *ctx, JSValue *sp) } else { general_case: for (;;) { - BOOL done; + int done; value = JS_IteratorNext(ctx, enumobj, method, 0, NULL, &done); if (JS_IsException(value)) goto exception; @@ -14315,7 +14315,7 @@ static __exception int js_append_enumerate(JSContext *ctx, JSValue *sp) return 0; exception: - JS_IteratorClose(ctx, enumobj, TRUE); + JS_IteratorClose(ctx, enumobj, true); JS_FreeValue(ctx, enumobj); JS_FreeValue(ctx, method); return -1; @@ -14325,7 +14325,7 @@ static __exception int JS_CopyDataProperties(JSContext *ctx, JSValue target, JSValue source, JSValue excluded, - BOOL setprop) + bool setprop) { JSPropertyEnum *tab_atom; JSValue val; @@ -14334,7 +14334,7 @@ static __exception int JS_CopyDataProperties(JSContext *ctx, JSObject *pexcl = NULL; int ret, gpn_flags; JSPropertyDescriptor desc; - BOOL is_enumerable; + bool is_enumerable; if (JS_VALUE_GET_TAG(source) != JS_TAG_OBJECT) return 0; @@ -14403,7 +14403,7 @@ static JSValue JS_GetActiveFunction(JSContext *ctx) } static JSVarRef *get_var_ref(JSContext *ctx, JSStackFrame *sf, - int var_idx, BOOL is_arg) + int var_idx, bool is_arg) { JSVarRef *var_ref; struct list_head *el; @@ -14420,7 +14420,7 @@ static JSVarRef *get_var_ref(JSContext *ctx, JSStackFrame *sf, if (!var_ref) return NULL; var_ref->header.ref_count = 1; - var_ref->is_detached = FALSE; + var_ref->is_detached = false; var_ref->is_arg = is_arg; var_ref->var_idx = var_idx; list_add_tail(&var_ref->header.link, &sf->var_ref_list); @@ -14543,7 +14543,7 @@ static JSValue js_closure(JSContext *ctx, JSValue bfunc, /* add the 'prototype' property: delay instantiation to avoid creating cycles for every javascript function. The prototype object is created on the fly when first accessed */ - JS_SetConstructorBit(ctx, func_obj, TRUE); + JS_SetConstructorBit(ctx, func_obj, true); JS_DefineAutoInitProperty(ctx, func_obj, JS_ATOM_prototype, JS_AUTOINIT_ID_PROTOTYPE, NULL, JS_PROP_WRITABLE); @@ -14560,7 +14560,7 @@ static JSValue js_closure(JSContext *ctx, JSValue bfunc, static int js_op_define_class(JSContext *ctx, JSValue *sp, JSAtom class_name, int class_flags, JSVarRef **cur_var_refs, - JSStackFrame *sf, BOOL is_computed_name) + JSStackFrame *sf, bool is_computed_name) { JSValue bfunc, parent_class, proto = JS_UNDEFINED; JSValue ctor = JS_UNDEFINED, parent_proto = JS_UNDEFINED; @@ -14606,7 +14606,7 @@ static int js_op_define_class(JSContext *ctx, JSValue *sp, if (JS_IsException(ctor)) goto fail; js_method_set_home_object(ctx, ctor, proto); - JS_SetConstructorBit(ctx, ctor, TRUE); + JS_SetConstructorBit(ctx, ctor, true); JS_DefinePropertyValue(ctx, ctor, JS_ATOM_length, js_int32(b->defined_arg_count), @@ -14667,7 +14667,7 @@ static void close_var_refs(JSRuntime *rt, JSStackFrame *sf) var_ref->value = js_dup(sf->var_buf[var_idx]); var_ref->pvalue = &var_ref->value; /* the reference is no longer to a local variable */ - var_ref->is_detached = TRUE; + var_ref->is_detached = true; add_gc_object(rt, &var_ref->header, JS_GC_OBJ_TYPE_VAR_REF); } } @@ -14684,7 +14684,7 @@ static void close_lexical_var(JSContext *ctx, JSStackFrame *sf, int var_idx) var_ref->pvalue = &var_ref->value; list_del(&var_ref->header.link); /* the reference is no longer to a local variable */ - var_ref->is_detached = TRUE; + var_ref->is_detached = true; add_gc_object(ctx->rt, &var_ref->header, JS_GC_OBJ_TYPE_VAR_REF); } } @@ -14719,7 +14719,7 @@ static JSValue js_call_c_function(JSContext *ctx, JSValue func_obj, rt->current_stack_frame = sf; ctx = p->u.cfunc.realm; /* change the current realm */ - sf->is_strict_mode = FALSE; + sf->is_strict_mode = false; sf->cur_func = func_obj; sf->arg_count = argc; arg_buf = argv; @@ -15438,7 +15438,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, goto done; CASE(OP_check_ctor_return): - /* return TRUE if 'this' should be returned */ + /* return true if 'this' should be returned */ if (!JS_IsObject(sp[-1])) { if (!JS_IsUndefined(sp[-1])) { JS_ThrowTypeError(caller_ctx, "derived class constructor must return an object or undefined"); @@ -15861,7 +15861,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 2; val = *var_refs[idx]->pvalue; if (unlikely(JS_IsUninitialized(val))) { - JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, TRUE); + JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, true); goto exception; } sp[0] = js_dup(val); @@ -15874,7 +15874,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, idx = get_u16(pc); pc += 2; if (unlikely(JS_IsUninitialized(*var_refs[idx]->pvalue))) { - JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, TRUE); + JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, true); goto exception; } set_value(ctx, var_refs[idx]->pvalue, sp[-1]); @@ -15887,7 +15887,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, idx = get_u16(pc); pc += 2; if (unlikely(!JS_IsUninitialized(*var_refs[idx]->pvalue))) { - JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, TRUE); + JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, true); goto exception; } set_value(ctx, var_refs[idx]->pvalue, sp[-1]); @@ -15909,7 +15909,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 2; if (unlikely(JS_IsUninitialized(var_buf[idx]))) { JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx, - FALSE); + false); goto exception; } sp[0] = js_dup(var_buf[idx]); @@ -15923,7 +15923,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 2; if (unlikely(JS_IsUninitialized(var_buf[idx]))) { JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx, - FALSE); + false); goto exception; } set_value(ctx, &var_buf[idx], sp[-1]); @@ -16142,7 +16142,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, BREAK; CASE(OP_for_of_start): sf->cur_pc = pc; - if (js_for_of_start(ctx, sp, FALSE)) + if (js_for_of_start(ctx, sp, false)) goto exception; sp += 1; *sp++ = JS_NewCatchOffset(ctx, 0); @@ -16159,7 +16159,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, BREAK; CASE(OP_for_await_of_start): sf->cur_pc = pc; - if (js_for_of_start(ctx, sp, TRUE)) + if (js_for_of_start(ctx, sp, true)) goto exception; sp += 1; *sp++ = JS_NewCatchOffset(ctx, 0); @@ -16184,7 +16184,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, sp--; if (!JS_IsUndefined(sp[-1])) { sf->cur_pc = pc; - if (JS_IteratorClose(ctx, sp[-1], FALSE)) + if (JS_IteratorClose(ctx, sp[-1], false)) goto exception; JS_FreeValue(ctx, sp[-1]); } @@ -16225,7 +16225,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, /* stack: iter_obj next catch_offset val */ { JSValue method, ret; - BOOL ret_flag; + bool ret_flag; int flags; flags = *pc++; sf->cur_pc = pc; @@ -16234,7 +16234,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, if (JS_IsException(method)) goto exception; if (JS_IsUndefined(method) || JS_IsNull(method)) { - ret_flag = TRUE; + ret_flag = true; } else { if (flags & 2) { /* no argument */ @@ -16248,7 +16248,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret; - ret_flag = FALSE; + ret_flag = false; } sp[0] = js_bool(ret_flag); sp += 1; @@ -16279,7 +16279,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 4; sf->cur_pc = pc; icu = (JSInlineCacheUpdate){ic, INLINE_CACHE_MISS}; - val = JS_GetPropertyInternal2(ctx, sp[-1], atom, sp[-1], &icu, FALSE); + val = JS_GetPropertyInternal2(ctx, sp[-1], atom, sp[-1], &icu, false); if (unlikely(JS_IsException(val))) goto exception; if (icu.offset != INLINE_CACHE_MISS) { @@ -16303,7 +16303,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 4; sf->cur_pc = pc; icu = (JSInlineCacheUpdate){ic, ic_offset}; - val = JS_GetPropertyInternalWithIC(ctx, sp[-1], atom, sp[-1], &icu, FALSE); + val = JS_GetPropertyInternalWithIC(ctx, sp[-1], atom, sp[-1], &icu, false); if (unlikely(JS_IsException(val))) goto exception; assert(icu.offset == ic_offset); @@ -16321,7 +16321,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 4; sf->cur_pc = pc; icu = (JSInlineCacheUpdate){ic, INLINE_CACHE_MISS}; - val = JS_GetPropertyInternal2(ctx, sp[-1], atom, sp[-1], &icu, FALSE); + val = JS_GetPropertyInternal2(ctx, sp[-1], atom, sp[-1], &icu, false); if (unlikely(JS_IsException(val))) goto exception; if (icu.offset != INLINE_CACHE_MISS) { @@ -16344,7 +16344,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, pc += 4; sf->cur_pc = pc; icu = (JSInlineCacheUpdate){ic, ic_offset}; - val = JS_GetPropertyInternalWithIC(ctx, sp[-1], atom, sp[-1], &icu, FALSE); + val = JS_GetPropertyInternalWithIC(ctx, sp[-1], atom, sp[-1], &icu, false); if (unlikely(JS_IsException(val))) goto exception; assert(icu.offset == ic_offset); @@ -16490,7 +16490,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, JSValue proto; proto = sp[-1]; if (JS_IsObject(proto) || JS_IsNull(proto)) { - if (JS_SetPrototypeInternal(ctx, sp[-2], proto, TRUE) < 0) + if (JS_SetPrototypeInternal(ctx, sp[-2], proto, true) < 0) goto exception; } JS_FreeValue(ctx, proto); @@ -16507,7 +16507,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, JSValue obj; JSAtom atom; int flags, ret, op_flags; - BOOL is_computed; + bool is_computed; #define OP_DEFINE_METHOD_METHOD 0 #define OP_DEFINE_METHOD_GETTER 1 #define OP_DEFINE_METHOD_SETTER 2 @@ -16631,7 +16631,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, atom = JS_ValueToAtom(ctx, sp[-1]); if (unlikely(atom == JS_ATOM_NULL)) goto exception; - val = JS_GetPropertyInternal2(ctx, sp[-2], atom, sp[-3], NULL, FALSE); + val = JS_GetPropertyInternal2(ctx, sp[-2], atom, sp[-3], NULL, false); JS_FreeAtom(ctx, atom); if (unlikely(JS_IsException(val))) goto exception; @@ -17469,7 +17469,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj, /* enumerator: close it with a throw */ JS_FreeValue(ctx, sp[-1]); /* drop the next method */ sp--; - JS_IteratorClose(ctx, sp[-1], TRUE); + JS_IteratorClose(ctx, sp[-1], true); } else { *sp++ = rt->current_exception; rt->current_exception = JS_UNINITIALIZED; @@ -17823,13 +17823,13 @@ static void js_generator_mark(JSRuntime *rt, JSValue val, static JSValue js_generator_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSGeneratorData *s = JS_GetOpaque(this_val, JS_CLASS_GENERATOR); JSStackFrame *sf; JSValue ret, func_ret; - *pdone = TRUE; + *pdone = true; if (!s) return JS_ThrowTypeError(ctx, "not a generator"); sf = &s->func_state.frame; @@ -17850,13 +17850,13 @@ static JSValue js_generator_next(JSContext *ctx, JSValue this_val, if (magic == GEN_MAGIC_THROW && s->state == JS_GENERATOR_STATE_SUSPENDED_YIELD) { JS_Throw(ctx, ret); - s->func_state.throw_flag = TRUE; + s->func_state.throw_flag = true; } else { sf->cur_sp[-1] = ret; sf->cur_sp[0] = js_int32(magic); sf->cur_sp++; exec_no_arg: - s->func_state.throw_flag = FALSE; + s->func_state.throw_flag = false; } s->state = JS_GENERATOR_STATE_EXECUTING; func_ret = async_func_resume(ctx, &s->func_state); @@ -17875,7 +17875,7 @@ static JSValue js_generator_next(JSContext *ctx, JSValue this_val, /* return (value, done) object */ *pdone = 2; } else { - *pdone = FALSE; + *pdone = false; } } else { /* end of iterator */ @@ -17948,7 +17948,7 @@ static void js_async_function_terminate(JSRuntime *rt, JSAsyncFunctionData *s) { if (s->is_active) { async_func_free(rt, &s->func_state); - s->is_active = FALSE; + s->is_active = false; } } @@ -18075,7 +18075,7 @@ static JSValue js_async_function_resolve_call(JSContext *ctx, { JSObject *p = JS_VALUE_GET_OBJ(func_obj); JSAsyncFunctionData *s = p->u.async_function_data; - BOOL is_reject = p->class_id - JS_CLASS_ASYNC_FUNCTION_RESOLVE; + bool is_reject = p->class_id - JS_CLASS_ASYNC_FUNCTION_RESOLVE; JSValue arg; if (argc > 0) @@ -18105,7 +18105,7 @@ static JSValue js_async_function_call(JSContext *ctx, JSValue func_obj, return JS_EXCEPTION; s->header.ref_count = 1; add_gc_object(ctx->rt, &s->header, JS_GC_OBJ_TYPE_ASYNC_FUNCTION); - s->is_active = FALSE; + s->is_active = false; s->resolving_funcs[0] = JS_UNDEFINED; s->resolving_funcs[1] = JS_UNDEFINED; @@ -18119,7 +18119,7 @@ static JSValue js_async_function_call(JSContext *ctx, JSValue func_obj, js_async_function_free(ctx->rt, s); return JS_EXCEPTION; } - s->is_active = TRUE; + s->is_active = true; js_async_function_resume(ctx, s); @@ -18215,7 +18215,7 @@ static JSValue js_async_generator_resolve_function(JSContext *ctx, static int js_async_generator_resolve_function_create(JSContext *ctx, JSValue generator, JSValue *resolving_funcs, - BOOL is_resume_next) + bool is_resume_next) { int i; JSValue func; @@ -18246,7 +18246,7 @@ static int js_async_generator_await(JSContext *ctx, goto fail; if (js_async_generator_resolve_function_create(ctx, JS_MKPTR(JS_TAG_OBJECT, s->generator), - resolving_funcs, FALSE)) { + resolving_funcs, false)) { JS_FreeValue(ctx, promise); goto fail; } @@ -18291,7 +18291,7 @@ static void js_async_generator_resolve_or_reject(JSContext *ctx, static void js_async_generator_resolve(JSContext *ctx, JSAsyncGeneratorData *s, JSValue value, - BOOL done) + bool done) { JSValue result; result = js_create_iterator_result(ctx, js_dup(value), done); @@ -18339,7 +18339,7 @@ static int js_async_generator_completed_return(JSContext *ctx, if (js_async_generator_resolve_function_create(ctx, JS_MKPTR(JS_TAG_OBJECT, s->generator), resolving_funcs1, - TRUE)) { + true)) { JS_FreeValue(ctx, promise); return -1; } @@ -18379,7 +18379,7 @@ static void js_async_generator_resume_next(JSContext *ctx, break; case JS_ASYNC_GENERATOR_STATE_COMPLETED: if (next->completion_type == GEN_MAGIC_NEXT) { - js_async_generator_resolve(ctx, s, JS_UNDEFINED, TRUE); + js_async_generator_resolve(ctx, s, JS_UNDEFINED, true); } else if (next->completion_type == GEN_MAGIC_RETURN) { s->state = JS_ASYNC_GENERATOR_STATE_AWAITING_RETURN; js_async_generator_completed_return(ctx, s, next->result); @@ -18393,7 +18393,7 @@ static void js_async_generator_resume_next(JSContext *ctx, if (next->completion_type == GEN_MAGIC_THROW && s->state == JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD) { JS_Throw(ctx, value); - s->func_state.throw_flag = TRUE; + s->func_state.throw_flag = true; } else { /* 'yield' returns a value. 'yield *' also returns a value in case the 'throw' method is called */ @@ -18402,7 +18402,7 @@ static void js_async_generator_resume_next(JSContext *ctx, js_int32(next->completion_type); s->func_state.frame.cur_sp++; exec_no_arg: - s->func_state.throw_flag = FALSE; + s->func_state.throw_flag = false; } s->state = JS_ASYNC_GENERATOR_STATE_EXECUTING; resume_exec: @@ -18424,7 +18424,7 @@ static void js_async_generator_resume_next(JSContext *ctx, s->state = JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD_STAR; else s->state = JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD; - js_async_generator_resolve(ctx, s, value, FALSE); + js_async_generator_resolve(ctx, s, value, false); JS_FreeValue(ctx, value); break; case FUNC_RET_AWAIT: @@ -18432,7 +18432,7 @@ static void js_async_generator_resume_next(JSContext *ctx, JS_FreeValue(ctx, value); if (ret < 0) { /* exception: throw it */ - s->func_state.throw_flag = TRUE; + s->func_state.throw_flag = true; goto resume_exec; } goto done; @@ -18445,7 +18445,7 @@ static void js_async_generator_resume_next(JSContext *ctx, value = s->func_state.frame.cur_sp[-1]; s->func_state.frame.cur_sp[-1] = JS_UNDEFINED; js_async_generator_complete(ctx, s); - js_async_generator_resolve(ctx, s, value, TRUE); + js_async_generator_resolve(ctx, s, value, true); JS_FreeValue(ctx, value); } break; @@ -18461,7 +18461,7 @@ static JSValue js_async_generator_resolve_function(JSContext *ctx, int argc, JSValue *argv, int magic, JSValue *func_data) { - BOOL is_reject = magic & 1; + bool is_reject = magic & 1; JSAsyncGeneratorData *s = JS_GetOpaque(func_data[0], JS_CLASS_ASYNC_GENERATOR); JSValue arg = argv[0]; @@ -18475,7 +18475,7 @@ static JSValue js_async_generator_resolve_function(JSContext *ctx, if (is_reject) { js_async_generator_reject(ctx, s, arg); } else { - js_async_generator_resolve(ctx, s, arg, TRUE); + js_async_generator_resolve(ctx, s, arg, true); } } else { /* restart function execution after await() */ @@ -18758,29 +18758,29 @@ typedef struct JSFunctionDef { struct list_head child_list; /* list of JSFunctionDef.link */ struct list_head link; - BOOL is_eval; /* TRUE if eval code */ - int eval_type; /* only valid if is_eval = TRUE */ - BOOL is_global_var; /* TRUE if variables are not defined locally: + bool is_eval; /* true if eval code */ + int eval_type; /* only valid if is_eval = true */ + bool is_global_var; /* true if variables are not defined locally: eval global, eval module or non strict eval */ - BOOL is_func_expr; /* TRUE if function expression */ - BOOL has_home_object; /* TRUE if the home object is available */ - BOOL has_prototype; /* true if a prototype field is necessary */ - BOOL has_simple_parameter_list; - BOOL has_parameter_expressions; /* if true, an argument scope is created */ - BOOL has_use_strict; /* to reject directive in special cases */ - BOOL has_eval_call; /* true if the function contains a call to eval() */ - BOOL has_arguments_binding; /* true if the 'arguments' binding is + bool is_func_expr; /* true if function expression */ + bool has_home_object; /* true if the home object is available */ + bool has_prototype; /* true if a prototype field is necessary */ + bool has_simple_parameter_list; + bool has_parameter_expressions; /* if true, an argument scope is created */ + bool has_use_strict; /* to reject directive in special cases */ + bool has_eval_call; /* true if the function contains a call to eval() */ + bool has_arguments_binding; /* true if the 'arguments' binding is available in the function */ - BOOL has_this_binding; /* true if the 'this' and new.target binding are + bool has_this_binding; /* true if the 'this' and new.target binding are available in the function */ - BOOL new_target_allowed; /* true if the 'new.target' does not + bool new_target_allowed; /* true if the 'new.target' does not throw a syntax error */ - BOOL super_call_allowed; /* true if super() is allowed */ - BOOL super_allowed; /* true if super. or super[] is allowed */ - BOOL arguments_allowed; /* true if the 'arguments' identifier is allowed */ - BOOL is_derived_class_constructor; - BOOL in_function_body; - BOOL backtrace_barrier; + bool super_call_allowed; /* true if super() is allowed */ + bool super_allowed; /* true if super. or super[] is allowed */ + bool arguments_allowed; /* true if the 'arguments' identifier is allowed */ + bool is_derived_class_constructor; + bool in_function_body; + bool backtrace_barrier; JSFunctionKindEnum func_kind : 8; JSParseFunctionEnum func_type : 7; uint8_t is_strict_mode : 1; @@ -18806,7 +18806,7 @@ typedef struct JSFunctionDef { int new_target_var_idx; /* variable containg the 'new.target' value, -1 if none */ int this_active_func_var_idx; /* variable containg the 'this.active_func' value, -1 if none */ int home_object_var_idx; - BOOL need_home_object; + bool need_home_object; int scope_level; /* index into fd->scopes if the current lexical scope */ int scope_first; /* index into vd->vars of first lexically scoped variable */ @@ -18822,7 +18822,7 @@ typedef struct JSFunctionDef { DynBuf byte_code; int last_opcode_pos; /* -1 if no last opcode */ - BOOL use_short_opcodes; /* true if short opcodes are used in byte_code */ + bool use_short_opcodes; /* true if short opcodes are used in byte_code */ LabelSlot *label_slots; int label_size; /* allocated size for label_slots[] */ @@ -18860,7 +18860,7 @@ typedef struct JSFunctionDef { int source_len; JSModuleDef *module; /* != NULL when parsing a module */ - BOOL has_await; /* TRUE if await is used (used in module eval) */ + bool has_await; /* true if await is used (used in module eval) */ JSInlineCache *ic; /* inline cache for field op */ } JSFunctionDef; @@ -18879,8 +18879,8 @@ typedef struct JSToken { } num; struct { JSAtom atom; - BOOL has_escape; - BOOL is_reserved; + bool has_escape; + bool is_reserved; } ident; struct { JSValue body; @@ -18897,7 +18897,7 @@ typedef struct JSParseState { int col_num; /* column number of current offset */ const char *filename; JSToken token; - BOOL got_lf; /* true if got line feed before the current token */ + bool got_lf; /* true if got line feed before the current token */ const uint8_t *last_ptr; const uint8_t *buf_start; const uint8_t *buf_ptr; @@ -18907,8 +18907,8 @@ typedef struct JSParseState { /* current function code */ JSFunctionDef *cur_func; - BOOL is_module; /* parsing a module */ - BOOL allow_html_comments; + bool is_module; /* parsing a module */ + bool allow_html_comments; } JSParseState; typedef struct JSOpCode { @@ -19041,7 +19041,7 @@ int __attribute__((format(printf, 2, 3))) js_parse_error(JSParseState *s, const int backtrace_flags; va_start(ap, fmt); - JS_ThrowError2(ctx, JS_SYNTAX_ERROR, fmt, ap, FALSE); + JS_ThrowError2(ctx, JS_SYNTAX_ERROR, fmt, ap, false); va_end(ap); backtrace_flags = 0; if (s->cur_func && s->cur_func->backtrace_barrier) @@ -19167,7 +19167,7 @@ static __exception int js_parse_template_part(JSParseState *s, } static __exception int js_parse_string(JSParseState *s, int sep, - BOOL do_throw, const uint8_t *p, + bool do_throw, const uint8_t *p, JSToken *token, const uint8_t **pp) { const uint8_t *p_next; @@ -19257,7 +19257,7 @@ static __exception int js_parse_string(JSParseState *s, int sep, if (c == CP_LS || c == CP_PS) continue; } else { - ret = lre_parse_escape(&p, TRUE); + ret = lre_parse_escape(&p, true); if (ret == -1) { if (do_throw) { js_parse_error(s, "Invalid %s escape sequence", @@ -19300,7 +19300,7 @@ static __exception int js_parse_string(JSParseState *s, int sep, return -1; } -static inline BOOL token_is_pseudo_keyword(JSParseState *s, JSAtom atom) { +static inline bool token_is_pseudo_keyword(JSParseState *s, JSAtom atom) { return s->token.val == TOK_IDENT && s->token.u.ident.atom == atom && !s->token.u.ident.has_escape; } @@ -19308,14 +19308,14 @@ static inline BOOL token_is_pseudo_keyword(JSParseState *s, JSAtom atom) { static __exception int js_parse_regexp(JSParseState *s) { const uint8_t *p, *p_next; - BOOL in_class; + bool in_class; StringBuffer b_s, *b = &b_s; StringBuffer b2_s, *b2 = &b2_s; uint32_t c; p = s->buf_ptr; p++; - in_class = FALSE; + in_class = false; if (string_buffer_init(s->ctx, b, 32)) return -1; if (string_buffer_init(s->ctx, b2, 1)) @@ -19333,10 +19333,10 @@ static __exception int js_parse_regexp(JSParseState *s) if (!in_class) break; } else if (c == '[') { - in_class = TRUE; + in_class = true; } else if (c == ']') { /* XXX: incorrect as the first character in a class */ - in_class = FALSE; + in_class = false; } else if (c == '\\') { if (string_buffer_putc8(b, c)) goto fail; @@ -19442,7 +19442,7 @@ static void update_token_ident(JSParseState *s) ((s->cur_func->parent->func_kind & JS_FUNC_ASYNC) || s->cur_func->parent->func_type == JS_PARSE_FUNC_CLASS_STATIC_INIT))))) { if (s->token.u.ident.has_escape) { - s->token.u.ident.is_reserved = TRUE; + s->token.u.ident.is_reserved = true; s->token.val = TOK_IDENT; } else { /* The keywords atoms are pre allocated */ @@ -19459,14 +19459,14 @@ static void reparse_ident_token(JSParseState *s) (s->token.val >= TOK_FIRST_KEYWORD && s->token.val <= TOK_LAST_KEYWORD)) { s->token.val = TOK_IDENT; - s->token.u.ident.is_reserved = FALSE; + s->token.u.ident.is_reserved = false; update_token_ident(s); } } /* 'c' is the first character. Return JS_ATOM_NULL in case of error */ static JSAtom parse_ident(JSParseState *s, const uint8_t **pp, - BOOL *pident_has_escape, int c, BOOL is_private) + bool *pident_has_escape, int c, bool is_private) { const uint8_t *p, *p_next; char ident_buf[128], *buf; @@ -19488,8 +19488,8 @@ static JSAtom parse_ident(JSParseState *s, const uint8_t **pp, c = *p; p_next = p + 1; if (c == '\\' && *p_next == 'u') { - c = lre_parse_escape(&p_next, TRUE); - *pident_has_escape = TRUE; + c = lre_parse_escape(&p_next, true); + *pident_has_escape = true; } else if (c >= 0x80) { c = utf8_decode(p, &p_next); /* no need to test for invalid UTF-8, 0xFFFD is not ident_next */ @@ -19516,7 +19516,7 @@ static __exception int next_token(JSParseState *s) { const uint8_t *p, *p_next; int c; - BOOL ident_has_escape; + bool ident_has_escape; JSAtom atom; int flags, radix; @@ -19528,7 +19528,7 @@ static __exception int next_token(JSParseState *s) free_token(s, &s->token); p = s->last_ptr = s->buf_ptr; - s->got_lf = FALSE; + s->got_lf = false; s->last_line_num = s->token.line_num; s->last_col_num = s->token.col_num; redo: @@ -19551,7 +19551,7 @@ static __exception int next_token(JSParseState *s) break; case '\'': case '\"': - if (js_parse_string(s, c, TRUE, p + 1, &s->token, &p)) + if (js_parse_string(s, c, true, p + 1, &s->token, &p)) goto fail; break; case '\r': /* accept DOS and MAC newline sequences */ @@ -19564,7 +19564,7 @@ static __exception int next_token(JSParseState *s) line_terminator: s->eol = &p[-1]; s->mark = p; - s->got_lf = TRUE; + s->got_lf = true; s->line_num++; goto redo; case '\f': @@ -19588,17 +19588,17 @@ static __exception int next_token(JSParseState *s) } if (*p == '\n') { s->line_num++; - s->got_lf = TRUE; /* considered as LF for ASI */ + s->got_lf = true; /* considered as LF for ASI */ s->eol = p++; s->mark = p; } else if (*p == '\r') { - s->got_lf = TRUE; /* considered as LF for ASI */ + s->got_lf = true; /* considered as LF for ASI */ p++; } else if (*p >= 0x80) { c = utf8_decode(p, &p); /* ignore invalid UTF-8 in comments */ if (c == CP_LS || c == CP_PS) { - s->got_lf = TRUE; /* considered as LF for ASI */ + s->got_lf = true; /* considered as LF for ASI */ } } else { p++; @@ -19639,11 +19639,11 @@ static __exception int next_token(JSParseState *s) case '\\': if (p[1] == 'u') { const uint8_t *p1 = p + 1; - int c1 = lre_parse_escape(&p1, TRUE); + int c1 = lre_parse_escape(&p1, true); if (c1 >= 0 && lre_js_is_ident_first(c1)) { c = c1; p = p1; - ident_has_escape = TRUE; + ident_has_escape = true; goto has_ident; } else { /* XXX: syntax error? */ @@ -19669,14 +19669,14 @@ static __exception int next_token(JSParseState *s) /* identifier */ s->mark = p; p++; - ident_has_escape = FALSE; + ident_has_escape = false; has_ident: - atom = parse_ident(s, &p, &ident_has_escape, c, FALSE); + atom = parse_ident(s, &p, &ident_has_escape, c, false); if (atom == JS_ATOM_NULL) goto fail; s->token.u.ident.atom = atom; s->token.u.ident.has_escape = ident_has_escape; - s->token.u.ident.is_reserved = FALSE; + s->token.u.ident.is_reserved = false; s->token.val = TOK_IDENT; update_token_ident(s); break; @@ -19687,7 +19687,7 @@ static __exception int next_token(JSParseState *s) c = *p; p_next = p + 1; if (c == '\\' && *p_next == 'u') { - c = lre_parse_escape(&p_next, TRUE); + c = lre_parse_escape(&p_next, true); } else if (c >= 0x80) { c = utf8_decode(p, &p_next); if (p_next == p + 1) @@ -19698,8 +19698,8 @@ static __exception int next_token(JSParseState *s) goto fail; } p = p_next; - ident_has_escape = FALSE; /* not used */ - atom = parse_ident(s, &p, &ident_has_escape, c, TRUE); + ident_has_escape = false; /* not used */ + atom = parse_ident(s, &p, &ident_has_escape, c, true); if (atom == JS_ATOM_NULL) goto fail; s->token.u.ident.atom = atom; @@ -19970,7 +19970,7 @@ static __exception int next_token(JSParseState *s) s->mark = p; goto redo; } else if (lre_js_is_ident_first(c)) { - ident_has_escape = FALSE; + ident_has_escape = false; goto has_ident; } else { js_parse_error(s, "unexpected character"); @@ -20243,8 +20243,8 @@ static __exception int json_next_token(JSParseState *s) if (atom == JS_ATOM_NULL) goto fail; s->token.u.ident.atom = atom; - s->token.u.ident.has_escape = FALSE; - s->token.u.ident.is_reserved = FALSE; + s->token.u.ident.has_escape = false; + s->token.u.ident.is_reserved = false; s->token.val = TOK_IDENT; break; case '-': @@ -20299,7 +20299,7 @@ static __exception int json_next_token(JSParseState *s) /* only used for ':' and '=>', 'let' or 'function' look-ahead. *pp is only set if TOK_IMPORT is returned */ /* XXX: handle all unicode cases */ -static int simple_next_token(const uint8_t **pp, BOOL no_line_terminator) +static int simple_next_token(const uint8_t **pp, bool no_line_terminator) { const uint8_t *p; uint32_t c; @@ -20378,7 +20378,7 @@ static int simple_next_token(const uint8_t **pp, BOOL no_line_terminator) } } -static int peek_token(JSParseState *s, BOOL no_line_terminator) +static int peek_token(JSParseState *s, bool no_line_terminator) { const uint8_t *p = s->buf_ptr; return simple_next_token(&p, no_line_terminator); @@ -20414,7 +20414,7 @@ static inline int get_prev_opcode(JSFunctionDef *fd) { return fd->byte_code.buf[fd->last_opcode_pos]; } -static BOOL js_is_live_code(JSParseState *s) { +static bool js_is_live_code(JSParseState *s) { switch (get_prev_opcode(s->cur_func)) { case OP_tail_call: case OP_tail_call_method: @@ -20427,9 +20427,9 @@ static BOOL js_is_live_code(JSParseState *s) { case OP_goto8: case OP_goto16: case OP_ret: - return FALSE; + return false; default: - return TRUE; + return true; } } @@ -20586,7 +20586,7 @@ static int cpool_add(JSParseState *s, JSValue val) } static __exception int emit_push_const(JSParseState *s, JSValue val, - BOOL as_atom) + bool as_atom) { int idx; @@ -20742,15 +20742,15 @@ static int find_var_in_scope(JSContext *ctx, JSFunctionDef *fd, /* return true if scope == parent_scope or if scope is a child of parent_scope */ -static BOOL is_child_scope(JSContext *ctx, JSFunctionDef *fd, +static bool is_child_scope(JSContext *ctx, JSFunctionDef *fd, int scope, int parent_scope) { while (scope >= 0) { if (scope == parent_scope) - return TRUE; + return true; scope = fd->scopes[scope].parent; } - return FALSE; + return false; } /* find a 'var' declaration in the same scope or a child scope */ @@ -20792,7 +20792,7 @@ static JSGlobalVar *find_lexical_global_var(JSFunctionDef *fd, JSAtom name) } static int find_lexical_decl(JSContext *ctx, JSFunctionDef *fd, JSAtom name, - int scope_idx, BOOL check_catch_var) + int scope_idx, bool check_catch_var) { while (scope_idx >= 0) { JSVarDef *vd = &fd->vars[scope_idx]; @@ -20923,7 +20923,7 @@ static int add_func_var(JSContext *ctx, JSFunctionDef *fd, JSAtom name) fd->func_var_idx = idx; fd->vars[idx].var_kind = JS_VAR_FUNCTION_NAME; if (fd->is_strict_mode) - fd->vars[idx].is_const = TRUE; + fd->vars[idx].is_const = true; } return idx; } @@ -20954,7 +20954,7 @@ static int add_arguments_arg(JSContext *ctx, JSFunctionDef *fd) fd->vars[idx].scope_next = fd->scopes[ARG_SCOPE_INDEX].first; fd->scopes[ARG_SCOPE_INDEX].first = idx; fd->vars[idx].scope_level = ARG_SCOPE_INDEX; - fd->vars[idx].is_lexical = TRUE; + fd->vars[idx].is_lexical = true; fd->arguments_arg_idx = idx; } @@ -20995,9 +20995,9 @@ static JSGlobalVar *add_global_var(JSContext *ctx, JSFunctionDef *s, return NULL; hf = &s->global_vars[s->global_var_count++]; hf->cpool_idx = -1; - hf->force_init = FALSE; - hf->is_lexical = FALSE; - hf->is_const = FALSE; + hf->force_init = false; + hf->is_lexical = false; + hf->is_const = false; hf->scope_level = s->scope_level; hf->var_name = JS_DupAtom(ctx, name); return hf; @@ -21029,7 +21029,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name, case JS_VAR_DEF_CONST: case JS_VAR_DEF_FUNCTION_DECL: case JS_VAR_DEF_NEW_FUNCTION_DECL: - idx = find_lexical_decl(ctx, fd, name, fd->scope_first, TRUE); + idx = find_lexical_decl(ctx, fd, name, fd->scope_first, true); if (idx >= 0) { if (idx < GLOBAL_VAR_OFFSET) { if (fd->vars[idx].scope_level == fd->scope_level) { @@ -21080,7 +21080,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name, hf = add_global_var(s->ctx, fd, name); if (!hf) return -1; - hf->is_lexical = TRUE; + hf->is_lexical = true; hf->is_const = (var_def_type == JS_VAR_DEF_CONST); idx = GLOBAL_VAR_OFFSET; } else { @@ -21106,7 +21106,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name, case JS_VAR_DEF_VAR: if (find_lexical_decl(ctx, fd, name, fd->scope_first, - FALSE) >= 0) { + false) >= 0) { invalid_lexical_redefinition: /* error to redefine a var that inside a lexical scope */ return js_parse_error(s, "invalid redefinition of lexical identifier"); @@ -21143,7 +21143,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name, /* add a private field variable in the current scope */ static int add_private_class_field(JSParseState *s, JSFunctionDef *fd, - JSAtom name, JSVarKindEnum var_kind, BOOL is_static) + JSAtom name, JSVarKindEnum var_kind, bool is_static) { JSContext *ctx = s->ctx; JSVarDef *vd; @@ -21200,7 +21200,7 @@ static int seal_template_obj(JSContext *ctx, JSValue obj) prs->flags & ~(JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE))) return -1; } - p->extensible = FALSE; + p->extensible = false; return 0; } @@ -21246,7 +21246,7 @@ static __exception int js_parse_template(JSParseState *s, int call, int *argc) /* re-parse the string with escape sequences but do not throw a syntax error if it contains invalid sequences */ - if (js_parse_string(s, '`', FALSE, p, &cooked, &p)) { + if (js_parse_string(s, '`', false, p, &cooked, &p)) { cooked.u.str.str = JS_UNDEFINED; } if (JS_DefinePropertyValueUint32(ctx, template_object, depth, @@ -21261,7 +21261,7 @@ static __exception int js_parse_template(JSParseState *s, int call, int *argc) */ JS_FreeValue(ctx, s->token.u.str.str); s->token.u.str.str = JS_UNDEFINED; - if (js_parse_string(s, '`', TRUE, p, &cooked, &p)) + if (js_parse_string(s, '`', true, p, &cooked, &p)) return -1; str = JS_VALUE_GET_STRING(cooked.u.str.str); if (str->len != 0 || depth == 0) { @@ -21295,7 +21295,7 @@ static __exception int js_parse_template(JSParseState *s, int call, int *argc) free_token(s, &s->token); /* Resume TOK_TEMPLATE parsing (s->token.line_num and * s->token.ptr are OK) */ - s->got_lf = FALSE; + s->got_lf = false; s->last_line_num = s->token.line_num; s->last_col_num = s->token.col_num; if (js_parse_template_part(s, s->buf_ptr)) @@ -21328,7 +21328,7 @@ static __exception int js_parse_template(JSParseState *s, int call, int *argc) #define PROP_TYPE_PRIVATE (1 << 4) -static BOOL token_is_ident(int tok) +static bool token_is_ident(int tok) { /* Accept keywords and reserved words as property names */ return (tok == TOK_IDENT || @@ -21339,11 +21339,11 @@ static BOOL token_is_ident(int tok) /* if the property is an expression, name = JS_ATOM_NULL */ static int __exception js_parse_property_name(JSParseState *s, JSAtom *pname, - BOOL allow_method, BOOL allow_var, - BOOL allow_private) + bool allow_method, bool allow_var, + bool allow_private) { int is_private = 0; - BOOL is_non_reserved_ident; + bool is_non_reserved_ident; JSAtom name; int prop_type; @@ -21358,7 +21358,7 @@ static int __exception js_parse_property_name(JSParseState *s, if (s->token.val == ':' || s->token.val == ',' || s->token.val == '}' || s->token.val == '(' || s->token.val == '=' || s->token.val == ';') { - is_non_reserved_ident = TRUE; + is_non_reserved_ident = true; goto ident_found; } prop_type = PROP_TYPE_GET + (name == JS_ATOM_set); @@ -21368,14 +21368,14 @@ static int __exception js_parse_property_name(JSParseState *s, goto fail; prop_type = PROP_TYPE_STAR; } else if (token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) != '\n') { + peek_token(s, true) != '\n') { name = JS_DupAtom(s->ctx, s->token.u.ident.atom); if (next_token(s)) goto fail1; if (s->token.val == ':' || s->token.val == ',' || s->token.val == '}' || s->token.val == '(' || s->token.val == '=' || s->token.val == ';') { - is_non_reserved_ident = TRUE; + is_non_reserved_ident = true; goto ident_found; } JS_FreeAtom(s->ctx, name); @@ -21456,7 +21456,7 @@ typedef struct JSParsePos { int last_col_num; int line_num; int col_num; - BOOL got_lf; + bool got_lf; const uint8_t *ptr; const uint8_t *eol; const uint8_t *mark; @@ -21488,8 +21488,8 @@ static __exception int js_parse_seek_token(JSParseState *s, const JSParsePos *sp return next_token(s); } -/* return TRUE if a regexp literal is allowed after this token */ -static BOOL is_regexp_allowed(int tok) +/* return true if a regexp literal is allowed after this token */ +static bool is_regexp_allowed(int tok) { switch (tok) { case TOK_NUMBER: @@ -21505,9 +21505,9 @@ static BOOL is_regexp_allowed(int tok) case ']': case '}': /* XXX: regexp may occur after */ case TOK_IDENT: - return FALSE; + return false; default: - return TRUE; + return true; } } @@ -21518,7 +21518,7 @@ static BOOL is_regexp_allowed(int tok) /* XXX: improve speed with early bailout */ /* XXX: no longer works if regexps are present. Could use previous regexp parsing heuristics to handle most cases */ -static int js_parse_skip_parens_token(JSParseState *s, int *pbits, BOOL no_line_terminator) +static int js_parse_skip_parens_token(JSParseState *s, int *pbits, bool no_line_terminator) { char state[256]; size_t level = 0; @@ -21555,7 +21555,7 @@ static int js_parse_skip_parens_token(JSParseState *s, int *pbits, BOOL no_line_ free_token(s, &s->token); /* Resume TOK_TEMPLATE parsing (s->token.line_num and * s->token.ptr are OK) */ - s->got_lf = FALSE; + s->got_lf = false; s->last_line_num = s->token.line_num; s->last_col_num = s->token.col_num; if (js_parse_template_part(s, s->buf_ptr)) @@ -21690,13 +21690,13 @@ static __exception int js_parse_object_literal(JSParseState *s) JSAtom name = JS_ATOM_NULL; const uint8_t *start_ptr; int start_line, start_col, prop_type; - BOOL has_proto; + bool has_proto; if (next_token(s)) goto fail; /* XXX: add an initial length that will be patched back */ emit_op(s, OP_object); - has_proto = FALSE; + has_proto = false; while (s->token.val != '}') { /* specific case for getter/setter */ start_ptr = s->token.ptr; @@ -21716,7 +21716,7 @@ static __exception int js_parse_object_literal(JSParseState *s) goto next; } - prop_type = js_parse_property_name(s, &name, TRUE, TRUE, FALSE); + prop_type = js_parse_property_name(s, &name, true, true, false); if (prop_type < 0) goto fail; @@ -21728,7 +21728,7 @@ static __exception int js_parse_object_literal(JSParseState *s) emit_op(s, OP_define_field); emit_atom(s, name); } else if (s->token.val == '(') { - BOOL is_getset = (prop_type == PROP_TYPE_GET || + bool is_getset = (prop_type == PROP_TYPE_GET || prop_type == PROP_TYPE_SET); JSParseFunctionEnum func_type; JSFunctionKindEnum func_kind; @@ -21777,7 +21777,7 @@ static __exception int js_parse_object_literal(JSParseState *s) goto fail; } emit_op(s, OP_set_proto); - has_proto = TRUE; + has_proto = true; } else { set_object_name(s, name); emit_op(s, OP_define_field); @@ -21869,9 +21869,9 @@ static JSAtom get_private_setter_name(JSContext *ctx, JSAtom name) typedef struct { JSFunctionDef *fields_init_fd; int computed_fields_count; - BOOL need_brand; + bool need_brand; int brand_push_pos; - BOOL is_static; + bool is_static; } ClassFieldsDef; static __exception int emit_class_init_start(JSParseState *s, @@ -21924,42 +21924,42 @@ static void emit_class_init_end(JSParseState *s, ClassFieldsDef *cf) emit_op(s, OP_set_home_object); } -static void emit_return(JSParseState *s, BOOL hasval); +static void emit_return(JSParseState *s, bool hasval); static JSFunctionDef *js_new_function_def(JSContext *ctx, JSFunctionDef *parent, - BOOL is_eval, - BOOL is_func_expr, + bool is_eval, + bool is_func_expr, const char *filename, int line_num, int col_num); static __exception int js_parse_class_default_ctor(JSParseState *s, - BOOL has_super, + bool has_super, JSFunctionDef **pfd) { JSParseFunctionEnum func_type; JSFunctionDef *fd = s->cur_func; - fd = js_new_function_def(s->ctx, fd, FALSE, FALSE, s->filename, + fd = js_new_function_def(s->ctx, fd, false, false, s->filename, s->token.line_num, s->token.col_num); if (!fd) return -1; s->cur_func = fd; - fd->has_home_object = TRUE; - fd->super_allowed = TRUE; - fd->has_prototype = FALSE; - fd->has_this_binding = TRUE; - fd->new_target_allowed = TRUE; + fd->has_home_object = true; + fd->super_allowed = true; + fd->has_prototype = false; + fd->has_this_binding = true; + fd->new_target_allowed = true; push_scope(s); /* enter body scope */ fd->body_scope = fd->scope_level; if (has_super) { - fd->is_derived_class_constructor = TRUE; - fd->super_call_allowed = TRUE; - fd->arguments_allowed = TRUE; - fd->has_arguments_binding = TRUE; + fd->is_derived_class_constructor = true; + fd->super_call_allowed = true; + fd->arguments_allowed = true; + fd->has_arguments_binding = true; func_type = JS_PARSE_FUNC_DERIVED_CLASS_CONSTRUCTOR; emit_op(s, OP_init_ctor); // TODO(bnoordhuis) roll into OP_init_ctor @@ -21976,7 +21976,7 @@ static __exception int js_parse_class_default_ctor(JSParseState *s, fd->func_kind = JS_FUNC_NORMAL; fd->func_type = func_type; - emit_return(s, FALSE); + emit_return(s, false); s->cur_func = fd->parent; if (pfd) @@ -21991,7 +21991,7 @@ static __exception int js_parse_class_default_ctor(JSParseState *s, } -static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, +static __exception int js_parse_class(JSParseState *s, bool is_class_expr, JSParseExportEnum export_flag) { JSContext *ctx = s->ctx; @@ -22001,14 +22001,14 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, JSFunctionDef *method_fd, *ctor_fd; int class_name_var_idx, prop_type, ctor_cpool_offset; int class_flags = 0, i, define_class_offset; - BOOL is_static, is_private, is_strict_mode; + bool is_static, is_private, is_strict_mode; const uint8_t *class_start_ptr = s->token.ptr; const uint8_t *start_ptr; ClassFieldsDef class_fields[2]; /* classes are parsed and executed in strict mode */ is_strict_mode = fd->is_strict_mode; - fd->is_strict_mode = TRUE; + fd->is_strict_mode = true; if (next_token(s)) goto fail; if (s->token.val == TOK_IDENT) { @@ -22078,7 +22078,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, ClassFieldsDef *cf = &class_fields[i]; cf->fields_init_fd = NULL; cf->computed_fields_count = 0; - cf->need_brand = FALSE; + cf->need_brand = false; cf->is_static = i; } @@ -22089,11 +22089,11 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, goto fail; continue; } - is_static = FALSE; + is_static = false; if (s->token.val == TOK_STATIC) { - int next = peek_token(s, TRUE); + int next = peek_token(s, true); if (!(next == ';' || next == '}' || next == '(' || next == '=')) - is_static = TRUE; + is_static = true; } prop_type = -1; if (is_static) { @@ -22141,7 +22141,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, } /* allow "static" field name */ if (s->token.val == ';' || s->token.val == '=') { - is_static = FALSE; + is_static = false; name = JS_DupAtom(ctx, JS_ATOM_static); prop_type = PROP_TYPE_IDENT; } @@ -22150,7 +22150,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, emit_op(s, OP_swap); start_ptr = s->token.ptr; if (prop_type < 0) { - prop_type = js_parse_property_name(s, &name, TRUE, FALSE, TRUE); + prop_type = js_parse_property_name(s, &name, true, false, true); if (prop_type < 0) goto fail; } @@ -22165,7 +22165,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, goto fail; } if (prop_type == PROP_TYPE_GET || prop_type == PROP_TYPE_SET) { - BOOL is_set = prop_type - PROP_TYPE_GET; + bool is_set = prop_type - PROP_TYPE_GET; JSFunctionDef *method_fd; if (is_private) { @@ -22188,7 +22188,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, JS_VAR_PRIVATE_GETTER + is_set, is_static) < 0) goto fail; } - class_fields[is_static].need_brand = TRUE; + class_fields[is_static].need_brand = true; } if (js_parse_function_decl2(s, JS_PARSE_FUNC_GETTER + is_set, @@ -22199,7 +22199,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, JS_PARSE_EXPORT_NONE, &method_fd)) goto fail; if (is_private) { - method_fd->need_home_object = TRUE; /* needed for brand check */ + method_fd->need_home_object = true; /* needed for brand check */ emit_op(s, OP_set_home_object); /* XXX: missing function name */ emit_op(s, OP_scope_put_var_init); @@ -22345,7 +22345,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, func_type = JS_PARSE_FUNC_CLASS_CONSTRUCTOR; } if (is_private) { - class_fields[is_static].need_brand = TRUE; + class_fields[is_static].need_brand = true; } if (js_parse_function_decl2(s, func_type, func_kind, JS_ATOM_NULL, start_ptr, @@ -22357,7 +22357,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, func_type == JS_PARSE_FUNC_CLASS_CONSTRUCTOR) { ctor_fd = method_fd; } else if (is_private) { - method_fd->need_home_object = TRUE; /* needed for brand check */ + method_fd->need_home_object = true; /* needed for brand check */ if (find_private_class_field(ctx, fd, name, fd->scope_level) >= 0) { private_field_already_defined: @@ -22521,7 +22521,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr, static __exception int js_parse_array_literal(JSParseState *s) { uint32_t idx; - BOOL need_length; + bool need_length; if (next_token(s)) return -1; @@ -22545,17 +22545,17 @@ static __exception int js_parse_array_literal(JSParseState *s) emit_u16(s, idx); /* larger arrays and holes are handled with explicit indices */ - need_length = FALSE; + need_length = false; while (s->token.val != ']' && idx < 0x7fffffff) { if (s->token.val == TOK_ELLIPSIS) break; - need_length = TRUE; + need_length = true; if (s->token.val != ',') { if (js_parse_assign_expr(s)) return -1; emit_op(s, OP_define_field); emit_u32(s, __JS_AtomFromUInt32(idx)); - need_length = FALSE; + need_length = false; } idx++; /* accept trailing comma */ @@ -22591,13 +22591,13 @@ static __exception int js_parse_array_literal(JSParseState *s) return -1; emit_op(s, OP_append); } else { - need_length = TRUE; + need_length = true; if (s->token.val != ',') { if (js_parse_assign_expr(s)) return -1; /* a idx val */ emit_op(s, OP_define_array_el); - need_length = FALSE; + need_length = false; } emit_op(s, OP_inc); } @@ -22621,7 +22621,7 @@ static __exception int js_parse_array_literal(JSParseState *s) } /* XXX: remove */ -static BOOL has_with_scope(JSFunctionDef *s, int scope_level) +static bool has_with_scope(JSFunctionDef *s, int scope_level) { /* check if scope chain contains a with statement */ while (s) { @@ -22630,18 +22630,18 @@ static BOOL has_with_scope(JSFunctionDef *s, int scope_level) JSVarDef *vd = &s->vars[scope_idx]; if (vd->var_name == JS_ATOM__with_) - return TRUE; + return true; scope_idx = vd->scope_next; } /* check parent scopes */ scope_level = s->parent_scope_level; s = s->parent; } - return FALSE; + return false; } static __exception int get_lvalue(JSParseState *s, int *popcode, int *pscope, - JSAtom *pname, int *plabel, int *pdepth, BOOL keep, + JSAtom *pname, int *plabel, int *pdepth, bool keep, int tok) { JSFunctionDef *fd; @@ -22778,7 +22778,7 @@ typedef enum { OP_scope_get_var which is never generated by get_lvalue(). */ static void put_lvalue(JSParseState *s, int opcode, int scope, JSAtom name, int label, PutLValueEnum special, - BOOL is_let) + bool is_let) { switch(opcode) { case OP_get_field: @@ -23016,19 +23016,19 @@ static JSAtom js_parse_destructuring_var(JSParseState *s, int tok, int is_arg) present at the top level. */ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, int hasval, int has_ellipsis, - BOOL allow_initializer) + bool allow_initializer) { int label_parse, label_assign, label_done, label_lvalue, depth_lvalue; int start_addr, assign_addr; JSAtom prop_name, var_name; int opcode, scope, tok1, skip_bits; - BOOL has_initializer; + bool has_initializer; label_lvalue = -1; if (has_ellipsis < 0) { /* pre-parse destructuration target for spread detection */ - js_parse_skip_parens_token(s, &skip_bits, FALSE); + js_parse_skip_parens_token(s, &skip_bits, false); has_ellipsis = skip_bits & SKIP_HAS_ELLIPSIS; } @@ -23082,7 +23082,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, return -1; if (get_lvalue(s, &opcode, &scope, &var_name, - &label_lvalue, &depth_lvalue, FALSE, '{')) + &label_lvalue, &depth_lvalue, false, '{')) return -1; } if (s->token.val != '}') { @@ -23094,7 +23094,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, emit_u8(s, 0 | ((depth_lvalue + 1) << 2) | ((depth_lvalue + 2) << 5)); goto set_val; } - prop_type = js_parse_property_name(s, &prop_name, FALSE, TRUE, FALSE); + prop_type = js_parse_property_name(s, &prop_name, false, true, false); if (prop_type < 0) return -1; var_name = JS_ATOM_NULL; @@ -23106,7 +23106,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, if (next_token(s)) goto prop_error; if ((s->token.val == '[' || s->token.val == '{') - && ((tok1 = js_parse_skip_parens_token(s, &skip_bits, FALSE)) == ',' || + && ((tok1 = js_parse_skip_parens_token(s, &skip_bits, false)) == ',' || tok1 == '=' || tok1 == '}')) { if (prop_name == JS_ATOM_NULL) { /* computed property name on stack */ @@ -23135,7 +23135,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, emit_u32(s, prop_name); emit_ic(s, prop_name); } - if (js_parse_destructuring_element(s, tok, is_arg, TRUE, -1, TRUE) < 0) + if (js_parse_destructuring_element(s, tok, is_arg, true, -1, true) < 0) return -1; if (s->token.val == '}') break; @@ -23176,7 +23176,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, goto prop_error; lvalue: if (get_lvalue(s, &opcode, &scope, &var_name, - &label_lvalue, &depth_lvalue, FALSE, '{')) + &label_lvalue, &depth_lvalue, false, '{')) goto prop_error; /* swap ref and lvalue object if any */ if (prop_name == JS_ATOM_NULL) { @@ -23296,7 +23296,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, if (next_token(s)) return -1; } else if (s->token.val == '[') { - BOOL has_spread; + bool has_spread; int enum_depth; BlockEnv block_env; @@ -23306,9 +23306,9 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, 'yield' triggers a 'return' */ push_break_entry(s->cur_func, &block_env, JS_ATOM_NULL, -1, -1, 2); - block_env.has_iterator = TRUE; + block_env.has_iterator = true; emit_op(s, OP_for_of_start); - has_spread = FALSE; + has_spread = false; while (s->token.val != ']') { /* get the next value */ if (s->token.val == TOK_ELLIPSIS) { @@ -23316,7 +23316,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, return -1; if (s->token.val == ',' || s->token.val == ']') return js_parse_error(s, "missing binding pattern..."); - has_spread = TRUE; + has_spread = true; } if (s->token.val == ',') { /* do nothing, skip the value, has_spread is false */ @@ -23325,7 +23325,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, emit_op(s, OP_drop); emit_op(s, OP_drop); } else if ((s->token.val == '[' || s->token.val == '{') - && ((tok1 = js_parse_skip_parens_token(s, &skip_bits, FALSE)) == ',' || + && ((tok1 = js_parse_skip_parens_token(s, &skip_bits, false)) == ',' || tok1 == '=' || tok1 == ']')) { if (has_spread) { if (tok1 == '=') @@ -23336,7 +23336,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, emit_u8(s, 0); emit_op(s, OP_drop); } - if (js_parse_destructuring_element(s, tok, is_arg, TRUE, skip_bits & SKIP_HAS_ELLIPSIS, TRUE) < 0) + if (js_parse_destructuring_element(s, tok, is_arg, true, skip_bits & SKIP_HAS_ELLIPSIS, true) < 0) return -1; } else { var_name = JS_ATOM_NULL; @@ -23353,7 +23353,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, if (js_parse_left_hand_side_expr(s)) return -1; if (get_lvalue(s, &opcode, &scope, &var_name, - &label_lvalue, &enum_depth, FALSE, '[')) { + &label_lvalue, &enum_depth, false, '[')) { return -1; } } @@ -23413,7 +23413,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, return -1; emit_goto(s, OP_goto, label_assign); emit_label(s, label_done); - has_initializer = TRUE; + has_initializer = true; } else { /* normally hasval is true except if js_parse_skip_parens_token() was wrong in the parsing */ @@ -23426,7 +23426,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg, memset(s->cur_func->byte_code.buf + start_addr, OP_nop, assign_addr - start_addr); s->cur_func->label_slots[label_parse].ref_count--; - has_initializer = FALSE; + has_initializer = false; } return has_initializer; @@ -23466,7 +23466,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) { FuncCallType call_type; int optional_chaining_label; - BOOL accept_lparen = (parse_flags & PF_POSTFIX_CALL) != 0; + bool accept_lparen = (parse_flags & PF_POSTFIX_CALL) != 0; call_type = FUNC_CALL_NORMAL; switch(s->token.val) { @@ -23551,7 +23551,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) return -1; break; case TOK_CLASS: - if (js_parse_class(s, TRUE, JS_PARSE_EXPORT_NONE)) + if (js_parse_class(s, true, JS_PARSE_EXPORT_NONE)) return -1; break; case TOK_NULL: @@ -23583,7 +23583,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) return js_parse_error_reserved_identifier(s); } if (token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) != '\n') { + peek_token(s, true) != '\n') { const uint8_t *source_ptr; int source_line_num; int source_col_num; @@ -23626,8 +23626,8 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) case '[': { int skip_bits; - if (js_parse_skip_parens_token(s, &skip_bits, FALSE) == '=') { - if (js_parse_destructuring_element(s, 0, 0, FALSE, skip_bits & SKIP_HAS_ELLIPSIS, TRUE) < 0) + if (js_parse_skip_parens_token(s, &skip_bits, false) == '=') { + if (js_parse_destructuring_element(s, 0, 0, false, skip_bits & SKIP_HAS_ELLIPSIS, true) < 0) return -1; } else { if (s->token.val == '{') { @@ -23659,7 +23659,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) emit_source_loc(s); if (js_parse_postfix_expr(s, 0)) return -1; - accept_lparen = TRUE; + accept_lparen = true; if (s->token.val != '(') { /* new operator on an object */ emit_op(s, OP_dup); @@ -23725,13 +23725,13 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) optional_chaining_label = -1; for(;;) { JSFunctionDef *fd = s->cur_func; - BOOL has_optional_chain = FALSE; + bool has_optional_chain = false; if (s->token.val == TOK_QUESTION_MARK_DOT) { /* optional chaining */ if (next_token(s)) return -1; - has_optional_chain = TRUE; + has_optional_chain = true; if (s->token.val == '(' && accept_lparen) { goto parse_func_call; } else if (s->token.val == '[') { @@ -23939,7 +23939,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) case OP_eval: emit_op(s, OP_apply_eval); emit_u16(s, fd->scope_level); - fd->has_eval_call = TRUE; + fd->has_eval_call = true; break; default: if (call_type == FUNC_CALL_SUPER_CTOR) { @@ -23982,7 +23982,7 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags) emit_op(s, OP_eval); emit_u16(s, arg_count); emit_u16(s, fd->scope_level); - fd->has_eval_call = TRUE; + fd->has_eval_call = true; break; default: if (call_type == FUNC_CALL_SUPER_CTOR) { @@ -24229,11 +24229,11 @@ static __exception int js_parse_unary(JSParseState *s, int parse_flags) return -1; if (js_parse_unary(s, 0)) return -1; - if (get_lvalue(s, &opcode, &scope, &name, &label, NULL, TRUE, op)) + if (get_lvalue(s, &opcode, &scope, &name, &label, NULL, true, op)) return -1; emit_op(s, OP_dec + op - TOK_DEC); put_lvalue(s, opcode, scope, name, label, PUT_LVALUE_KEEP_TOP, - FALSE); + false); } break; case TOK_TYPEOF: @@ -24267,7 +24267,7 @@ static __exception int js_parse_unary(JSParseState *s, int parse_flags) return -1; if (js_parse_unary(s, PF_POW_FORBIDDEN)) return -1; - s->cur_func->has_await = TRUE; + s->cur_func->has_await = true; emit_op(s, OP_await); parse_flags = 0; break; @@ -24279,11 +24279,11 @@ static __exception int js_parse_unary(JSParseState *s, int parse_flags) int opcode, op, scope, label; JSAtom name; op = s->token.val; - if (get_lvalue(s, &opcode, &scope, &name, &label, NULL, TRUE, op)) + if (get_lvalue(s, &opcode, &scope, &name, &label, NULL, true, op)) return -1; emit_op(s, OP_post_dec + op - TOK_DEC); put_lvalue(s, opcode, scope, name, label, PUT_LVALUE_KEEP_SECOND, - FALSE); + false); if (next_token(s)) return -1; } @@ -24318,7 +24318,7 @@ static __exception int js_parse_expr_binary(JSParseState *s, int level, return js_parse_unary(s, PF_POW_ALLOWED); } else if (s->token.val == TOK_PRIVATE_NAME && (parse_flags & PF_IN_ACCEPTED) && level == 4 && - peek_token(s, FALSE) == TOK_IN) { + peek_token(s, false) == TOK_IN) { JSAtom atom; atom = JS_DupAtom(s->ctx, s->token.u.ident.atom); if (next_token(s)) @@ -24578,7 +24578,7 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) JSAtom name; if (s->token.val == TOK_YIELD) { - BOOL is_star = FALSE, is_async; + bool is_star = false, is_async; if (!(s->cur_func->func_kind & JS_FUNC_GENERATOR)) return js_parse_error(s, "unexpected 'yield' keyword"); @@ -24592,7 +24592,7 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) s->token.val != ']' && s->token.val != '}' && s->token.val != ',' && s->token.val != ':' && !s->got_lf) { if (s->token.val == '*') { - is_star = TRUE; + is_star = true; if (next_token(s)) return -1; } @@ -24673,7 +24673,7 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) emit_op(s, OP_nip); emit_op(s, OP_nip); emit_op(s, OP_nip); - emit_return(s, TRUE); + emit_return(s, true); /* throw handling */ emit_label(s, label_throw); @@ -24716,12 +24716,12 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) emit_op(s, OP_await); emit_op(s, OP_yield); label_next = emit_goto(s, OP_if_false, -1); - emit_return(s, TRUE); + emit_return(s, true); emit_label(s, label_next); } return 0; } else if (s->token.val == '(' && - js_parse_skip_parens_token(s, NULL, TRUE) == TOK_ARROW) { + js_parse_skip_parens_token(s, NULL, true) == TOK_ARROW) { return js_parse_function_decl(s, JS_PARSE_FUNC_ARROW, JS_FUNC_NORMAL, JS_ATOM_NULL, s->token.ptr, s->token.line_num, @@ -24732,7 +24732,7 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) JSParsePos pos; /* fast test */ - tok = peek_token(s, TRUE); + tok = peek_token(s, true); if (tok == TOK_FUNCTION || tok == '\n') goto next; @@ -24743,9 +24743,9 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) if (next_token(s)) return -1; if ((s->token.val == '(' && - js_parse_skip_parens_token(s, NULL, TRUE) == TOK_ARROW) || + js_parse_skip_parens_token(s, NULL, true) == TOK_ARROW) || (s->token.val == TOK_IDENT && !s->token.u.ident.is_reserved && - peek_token(s, TRUE) == TOK_ARROW)) { + peek_token(s, true) == TOK_ARROW)) { return js_parse_function_decl(s, JS_PARSE_FUNC_ARROW, JS_FUNC_ASYNC, JS_ATOM_NULL, source_ptr, source_line_num, @@ -24756,7 +24756,7 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) return -1; } } else if (s->token.val == TOK_IDENT && - peek_token(s, TRUE) == TOK_ARROW) { + peek_token(s, true) == TOK_ARROW) { return js_parse_function_decl(s, JS_PARSE_FUNC_ARROW, JS_FUNC_NORMAL, JS_ATOM_NULL, s->token.ptr, s->token.line_num, @@ -24819,14 +24819,14 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) } else { emit_op(s, op - TOK_MUL_ASSIGN + OP_mul); } - put_lvalue(s, opcode, scope, name, label, PUT_LVALUE_KEEP_TOP, FALSE); + put_lvalue(s, opcode, scope, name, label, PUT_LVALUE_KEEP_TOP, false); } else if (op >= TOK_LAND_ASSIGN && op <= TOK_DOUBLE_QUESTION_MARK_ASSIGN) { int label, label1, depth_lvalue, label2; if (next_token(s)) return -1; if (get_lvalue(s, &opcode, &scope, &name, &label, - &depth_lvalue, TRUE, op) < 0) + &depth_lvalue, true, op) < 0) return -1; emit_op(s, OP_dup); @@ -24862,7 +24862,7 @@ static __exception int js_parse_assign_expr2(JSParseState *s, int parse_flags) /* XXX: we disable the OP_put_ref_value optimization by not using put_lvalue() otherwise depth_lvalue is not correct */ put_lvalue(s, opcode, scope, name, label, PUT_LVALUE_NOKEEP_DEPTH, - FALSE); + false); label2 = emit_goto(s, OP_goto, -1); emit_label(s, label1); @@ -24886,7 +24886,7 @@ static __exception int js_parse_assign_expr(JSParseState *s) /* allowed parse_flags: PF_IN_ACCEPTED */ static __exception int js_parse_expr2(JSParseState *s, int parse_flags) { - BOOL comma = FALSE; + bool comma = false; for(;;) { if (js_parse_assign_expr2(s, parse_flags)) return -1; @@ -24900,7 +24900,7 @@ static __exception int js_parse_expr2(JSParseState *s, int parse_flags) } if (s->token.val != ',') break; - comma = TRUE; + comma = true; if (next_token(s)) return -1; emit_op(s, OP_drop); @@ -24926,8 +24926,8 @@ static void push_break_entry(JSFunctionDef *fd, BlockEnv *be, be->drop_count = drop_count; be->label_finally = -1; be->scope_level = fd->scope_level; - be->has_iterator = FALSE; - be->is_regular_stmt = FALSE; + be->has_iterator = false; + be->is_regular_stmt = false; } static void pop_break_entry(JSFunctionDef *fd) @@ -24987,7 +24987,7 @@ static __exception int emit_break(JSParseState *s, JSAtom name, int is_cont) } /* execute the finally blocks before return */ -static void emit_return(JSParseState *s, BOOL hasval) +static void emit_return(JSParseState *s, bool hasval) { BlockEnv *top; @@ -24995,7 +24995,7 @@ static void emit_return(JSParseState *s, BOOL hasval) if (!hasval) { /* no value: direct return in case of async generator */ emit_op(s, OP_undefined); - hasval = TRUE; + hasval = true; } else if (s->cur_func->func_kind == JS_FUNC_ASYNC_GENERATOR) { /* the await must be done before handling the "finally" in case it raises an exception */ @@ -25008,7 +25008,7 @@ static void emit_return(JSParseState *s, BOOL hasval) if (top->has_iterator || top->label_finally != -1) { if (!hasval) { emit_op(s, OP_undefined); - hasval = TRUE; + hasval = true; } /* Remove the stack elements up to and including the catch offset. When 'yield' is used in an expression we have @@ -25112,7 +25112,7 @@ static __exception int js_parse_block(JSParseState *s) /* allowed parse_flags: PF_IN_ACCEPTED */ static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok, - BOOL export_flag) + bool export_flag) { JSContext *ctx = s->ctx; JSFunctionDef *fd = s->cur_func; @@ -25149,7 +25149,7 @@ static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok, emit_op(s, OP_scope_get_var); emit_atom(s, name); emit_u16(s, fd->scope_level); - if (get_lvalue(s, &opcode, &scope, &name1, &label, NULL, FALSE, '=') < 0) + if (get_lvalue(s, &opcode, &scope, &name1, &label, NULL, false, '=') < 0) goto var_error; if (js_parse_assign_expr2(s, parse_flags)) { JS_FreeAtom(ctx, name1); @@ -25157,7 +25157,7 @@ static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok, } set_object_name(s, name); put_lvalue(s, opcode, scope, name1, label, - PUT_LVALUE_NOKEEP, FALSE); + PUT_LVALUE_NOKEEP, false); } else { if (js_parse_assign_expr2(s, parse_flags)) goto var_error; @@ -25184,9 +25184,9 @@ static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok, } else { int skip_bits; if ((s->token.val == '[' || s->token.val == '{') - && js_parse_skip_parens_token(s, &skip_bits, FALSE) == '=') { + && js_parse_skip_parens_token(s, &skip_bits, false) == '=') { emit_op(s, OP_undefined); - if (js_parse_destructuring_element(s, tok, 0, TRUE, skip_bits & SKIP_HAS_ELLIPSIS, TRUE) < 0) + if (js_parse_destructuring_element(s, tok, 0, true, skip_bits & SKIP_HAS_ELLIPSIS, true) < 0) return -1; } else { return js_parse_error(s, "variable name expected"); @@ -25205,16 +25205,16 @@ static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok, } /* test if the current token is a label. Use simplistic look-ahead scanner */ -static BOOL is_label(JSParseState *s) +static bool is_label(JSParseState *s) { return (s->token.val == TOK_IDENT && !s->token.u.ident.is_reserved && - peek_token(s, FALSE) == ':'); + peek_token(s, false) == ':'); } /* test if the current token is a let keyword. Use simplistic look-ahead scanner */ static int is_let(JSParseState *s, int decl_mask) { - int res = FALSE; + int res = false; if (token_is_pseudo_keyword(s, JS_ATOM_let)) { JSParsePos pos; @@ -25227,7 +25227,7 @@ static int is_let(JSParseState *s, int decl_mask) if (s->token.val == '[') { /* let [ is a syntax restriction: it never introduces an ExpressionStatement */ - res = TRUE; + res = true; break; } if (s->token.val == '{' || @@ -25239,7 +25239,7 @@ static int is_let(JSParseState *s, int decl_mask) /* XXX: should also check that `{` introduces a BindingPattern, but Firefox does not and rejects eval("let=1;let\n{if(1)2;}") */ if (s->last_line_num == s->token.line_num || (decl_mask & DECL_MASK_OTHER)) { - res = TRUE; + res = true; break; } break; @@ -25256,20 +25256,20 @@ static int is_let(JSParseState *s, int decl_mask) /* XXX: handle IteratorClose when exiting the loop before the enumeration is done */ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, - BOOL is_async) + bool is_async) { JSContext *ctx = s->ctx; JSFunctionDef *fd = s->cur_func; JSAtom var_name; - BOOL has_initializer, is_for_of, has_destructuring; + bool has_initializer, is_for_of, has_destructuring; int tok, tok1, opcode, scope, block_scope_level; int label_next, label_expr, label_cont, label_body, label_break; int pos_next, pos_expr; BlockEnv break_entry; - has_initializer = FALSE; - has_destructuring = FALSE; - is_for_of = FALSE; + has_initializer = false; + has_destructuring = false; + is_for_of = false; block_scope_level = fd->scope_level; label_cont = new_label(s); label_body = new_label(s); @@ -25294,10 +25294,10 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, tok = s->token.val; switch (is_let(s, DECL_MASK_OTHER)) { - case TRUE: + case true: tok = TOK_LET; break; - case FALSE: + case false: break; default: return -1; @@ -25308,9 +25308,9 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, if (!(s->token.val == TOK_IDENT && !s->token.u.ident.is_reserved)) { if (s->token.val == '[' || s->token.val == '{') { - if (js_parse_destructuring_element(s, tok, 0, TRUE, -1, FALSE) < 0) + if (js_parse_destructuring_element(s, tok, 0, true, -1, false) < 0) return -1; - has_destructuring = TRUE; + has_destructuring = true; } else { return js_parse_error(s, "variable name expected"); } @@ -25330,23 +25330,23 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, emit_atom(s, var_name); emit_u16(s, fd->scope_level); } - } else if (!is_async && token_is_pseudo_keyword(s, JS_ATOM_async) && peek_token(s, FALSE) == TOK_OF) { + } else if (!is_async && token_is_pseudo_keyword(s, JS_ATOM_async) && peek_token(s, false) == TOK_OF) { return js_parse_error(s, "'for of' expression cannot start with 'async'"); } else { int skip_bits; if ((s->token.val == '[' || s->token.val == '{') - && ((tok1 = js_parse_skip_parens_token(s, &skip_bits, FALSE)) == TOK_IN || tok1 == TOK_OF)) { - if (js_parse_destructuring_element(s, 0, 0, TRUE, skip_bits & SKIP_HAS_ELLIPSIS, TRUE) < 0) + && ((tok1 = js_parse_skip_parens_token(s, &skip_bits, false)) == TOK_IN || tok1 == TOK_OF)) { + if (js_parse_destructuring_element(s, 0, 0, true, skip_bits & SKIP_HAS_ELLIPSIS, true) < 0) return -1; } else { int lvalue_label; if (js_parse_left_hand_side_expr(s)) return -1; if (get_lvalue(s, &opcode, &scope, &var_name, &lvalue_label, - NULL, FALSE, TOK_FOR)) + NULL, false, TOK_FOR)) return -1; put_lvalue(s, opcode, scope, var_name, lvalue_label, - PUT_LVALUE_NOKEEP_BOTTOM, FALSE); + PUT_LVALUE_NOKEEP_BOTTOM, false); } var_name = JS_ATOM_NULL; } @@ -25356,7 +25356,7 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, emit_label(s, label_expr); if (s->token.val == '=') { /* XXX: potential scoping issue if inside `with` statement */ - has_initializer = TRUE; + has_initializer = true; /* parse and evaluate initializer prior to evaluating the object (only used with "for in" with a non lexical variable in non strict mode */ @@ -25373,8 +25373,8 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, JS_FreeAtom(ctx, var_name); if (token_is_pseudo_keyword(s, JS_ATOM_of)) { - is_for_of = TRUE; - break_entry.has_iterator = TRUE; + is_for_of = true; + break_entry.has_iterator = true; break_entry.drop_count += 2; if (has_initializer) goto initializer_error; @@ -25558,9 +25558,9 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, if (s->token.val != ';' && s->token.val != '}' && !s->got_lf) { if (js_parse_expr(s)) goto fail; - emit_return(s, TRUE); + emit_return(s, true); } else { - emit_return(s, FALSE); + emit_return(s, false); } if (js_parse_expect_semi(s)) goto fail; @@ -25589,7 +25589,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, case TOK_VAR: if (next_token(s)) goto fail; - if (js_parse_var(s, TRUE, tok, FALSE)) + if (js_parse_var(s, true, tok, false)) goto fail; if (js_parse_expect_semi(s)) goto fail; @@ -25703,25 +25703,25 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, int pos_cont, pos_body, block_scope_level; BlockEnv break_entry; int tok, bits; - BOOL is_async; + bool is_async; if (next_token(s)) goto fail; set_eval_ret_undefined(s); bits = 0; - is_async = FALSE; + is_async = false; if (s->token.val == '(') { - js_parse_skip_parens_token(s, &bits, FALSE); + js_parse_skip_parens_token(s, &bits, false); } else if (s->token.val == TOK_AWAIT) { if (!(s->cur_func->func_kind & JS_FUNC_ASYNC)) { js_parse_error(s, "for await is only valid in asynchronous functions"); goto fail; } - is_async = TRUE; + is_async = true; if (next_token(s)) goto fail; - s->cur_func->has_await = TRUE; + s->cur_func->has_await = true; } if (js_parse_expect(s, '(')) goto fail; @@ -25741,10 +25741,10 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, tok = s->token.val; if (tok != ';') { switch (is_let(s, DECL_MASK_OTHER)) { - case TRUE: + case true: tok = TOK_LET; break; - case FALSE: + case false: break; default: goto fail; @@ -25752,10 +25752,10 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, if (tok == TOK_VAR || tok == TOK_LET || tok == TOK_CONST) { if (next_token(s)) goto fail; - if (js_parse_var(s, FALSE, tok, FALSE)) + if (js_parse_var(s, false, tok, false)) goto fail; } else { - if (js_parse_expr2(s, FALSE)) + if (js_parse_expr2(s, false)) goto fail; emit_op(s, OP_drop); } @@ -26014,7 +26014,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, if (!(s->token.val == TOK_IDENT && !s->token.u.ident.is_reserved)) { if (s->token.val == '[' || s->token.val == '{') { /* XXX: TOK_LET is not completely correct */ - if (js_parse_destructuring_element(s, TOK_LET, 0, TRUE, -1, TRUE) < 0) + if (js_parse_destructuring_element(s, TOK_LET, 0, true, -1, true) < 0) goto fail; } else { js_parse_error(s, "identifier expected"); @@ -26156,7 +26156,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, /* ES6 Annex B.3.2 and B.3.3 semantics */ if (!(decl_mask & DECL_MASK_FUNC)) goto func_decl_error; - if (!(decl_mask & DECL_MASK_OTHER) && peek_token(s, FALSE) == '*') + if (!(decl_mask & DECL_MASK_OTHER) && peek_token(s, false) == '*') goto func_decl_error; goto parse_func_var; case TOK_IDENT: @@ -26166,16 +26166,16 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, } /* Determine if `let` introduces a Declaration or an ExpressionStatement */ switch (is_let(s, decl_mask)) { - case TRUE: + case true: tok = TOK_LET; goto haslet; - case FALSE: + case false: break; default: goto fail; } if (token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) == TOK_FUNCTION) { + peek_token(s, true) == TOK_FUNCTION) { if (!(decl_mask & DECL_MASK_OTHER)) { func_decl_error: js_parse_error(s, "function declarations can't appear in single-statement context"); @@ -26197,7 +26197,7 @@ static __exception int js_parse_statement_or_decl(JSParseState *s, js_parse_error(s, "class declarations can't appear in single-statement context"); goto fail; } - if (js_parse_class(s, FALSE, JS_PARSE_EXPORT_NONE)) + if (js_parse_class(s, false, JS_PARSE_EXPORT_NONE)) return -1; break; @@ -26836,7 +26836,7 @@ static int find_exported_name(GetExportNamesState *s, JSAtom name) static __exception int get_exported_names(JSContext *ctx, GetExportNamesState *s, - JSModuleDef *m, BOOL from_star) + JSModuleDef *m, bool from_star) { ExportedNameEntry *en; int i, j; @@ -26877,7 +26877,7 @@ static __exception int get_exported_names(JSContext *ctx, JSStarExportEntry *se = &m->star_export_entries[i]; JSModuleDef *m1; m1 = m->req_module_entries[se->req_module_idx].module; - if (get_exported_names(ctx, s, m1, TRUE)) + if (get_exported_names(ctx, s, m1, true)) return -1; } return 0; @@ -26937,7 +26937,7 @@ static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m) p = JS_VALUE_GET_OBJ(obj); memset(s, 0, sizeof(*s)); - ret = get_exported_names(ctx, s, m, FALSE); + ret = get_exported_names(ctx, s, m, false); js_free(ctx, s->modules); if (ret) goto fail; @@ -27023,7 +27023,7 @@ static JSValue js_build_module_ns(JSContext *ctx, JSModuleDef *m) JS_AtomToString(ctx, JS_ATOM_Module), 0); - p->extensible = FALSE; + p->extensible = false; return obj; fail: js_free(ctx, s->exported_names); @@ -27067,7 +27067,7 @@ static int js_resolve_module(JSContext *ctx, JSModuleDef *m) printf("resolving module '%s':\n", JS_AtomGetStr(ctx, buf1, sizeof(buf1), m->module_name)); } #endif - m->resolved = TRUE; + m->resolved = true; /* resolve each requested module */ for(i = 0; i < m->req_module_entries_count; i++) { JSReqModuleEntry *rme = &m->req_module_entries[i]; @@ -27084,7 +27084,7 @@ static int js_resolve_module(JSContext *ctx, JSModuleDef *m) return 0; } -static JSVarRef *js_create_module_var(JSContext *ctx, BOOL is_lexical) +static JSVarRef *js_create_module_var(JSContext *ctx, bool is_lexical) { JSVarRef *var_ref; var_ref = js_malloc(ctx, sizeof(JSVarRef)); @@ -27096,7 +27096,7 @@ static JSVarRef *js_create_module_var(JSContext *ctx, BOOL is_lexical) else var_ref->value = JS_UNDEFINED; var_ref->pvalue = &var_ref->value; - var_ref->is_detached = TRUE; + var_ref->is_detached = true; add_gc_object(ctx->rt, &var_ref->header, JS_GC_OBJ_TYPE_VAR_REF); return var_ref; } @@ -27156,7 +27156,7 @@ static int js_create_module_bytecode_function(JSContext *ctx, JSModuleDef *m) /* must be done before js_link_module() because of cyclic references */ static int js_create_module_function(JSContext *ctx, JSModuleDef *m) { - BOOL is_c_module; + bool is_c_module; int i; JSVarRef *var_ref; @@ -27170,7 +27170,7 @@ static int js_create_module_function(JSContext *ctx, JSModuleDef *m) for(i = 0; i < m->export_entries_count; i++) { JSExportEntry *me = &m->export_entries[i]; if (me->export_type == JS_EXPORT_TYPE_LOCAL) { - var_ref = js_create_module_var(ctx, FALSE); + var_ref = js_create_module_var(ctx, false); if (!var_ref) return -1; me->u.local.var_ref = var_ref; @@ -27180,7 +27180,7 @@ static int js_create_module_function(JSContext *ctx, JSModuleDef *m) if (js_create_module_bytecode_function(ctx, m)) return -1; } - m->func_created = TRUE; + m->func_created = true; /* do it on the dependencies */ @@ -27204,7 +27204,7 @@ static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m, JSModuleDef *m1; JSVarRef **var_refs, *var_ref; JSObject *p; - BOOL is_c_module; + bool is_c_module; JSValue ret_val; if (js_check_stack_overflow(ctx->rt, 0)) { @@ -27331,7 +27331,7 @@ static int js_inner_module_linking(JSContext *ctx, JSModuleDef *m, val = JS_GetModuleNamespace(ctx, m2); if (JS_IsException(val)) goto fail; - var_ref = js_create_module_var(ctx, TRUE); + var_ref = js_create_module_var(ctx, true); if (!var_ref) { JS_FreeValue(ctx, val); goto fail; @@ -27694,14 +27694,14 @@ typedef struct { } ExecModuleList; /* XXX: slow. Could use a linked list instead of ExecModuleList */ -static BOOL find_in_exec_module_list(ExecModuleList *exec_list, JSModuleDef *m) +static bool find_in_exec_module_list(ExecModuleList *exec_list, JSModuleDef *m) { int i; for(i = 0; i < exec_list->count; i++) { if (exec_list->tab[i] == m) - return TRUE; + return true; } - return FALSE; + return false; } static int gather_available_ancestors(JSContext *ctx, JSModuleDef *module, @@ -27768,7 +27768,7 @@ static JSValue js_async_module_execution_rejected(JSContext *ctx, JSValueConst t assert(!module->eval_has_exception); assert(module->async_evaluation); - module->eval_has_exception = TRUE; + module->eval_has_exception = true; module->eval_exception = JS_DupValue(ctx, error); module->status = JS_MODULE_STATUS_EVALUATED; @@ -27804,7 +27804,7 @@ static JSValue js_async_module_execution_fulfilled(JSContext *ctx, JSValueConst assert(module->status == JS_MODULE_STATUS_EVALUATING_ASYNC); assert(!module->eval_has_exception); assert(module->async_evaluation); - module->async_evaluation = FALSE; + module->async_evaluation = false; js_set_module_evaluated(ctx, module); exec_list->tab = NULL; @@ -27977,12 +27977,12 @@ static int js_inner_module_evaluation(JSContext *ctx, JSModuleDef *m, if (m->pending_async_dependencies > 0) { assert(!m->async_evaluation); - m->async_evaluation = TRUE; + m->async_evaluation = true; m->async_evaluation_timestamp = ctx->rt->module_async_evaluation_next_timestamp++; } else if (m->has_tla) { assert(!m->async_evaluation); - m->async_evaluation = TRUE; + m->async_evaluation = true; m->async_evaluation_timestamp = ctx->rt->module_async_evaluation_next_timestamp++; js_execute_async_module(ctx, m); @@ -28039,7 +28039,7 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m) m1 = stack_top; assert(m1->status == JS_MODULE_STATUS_EVALUATING); m1->status = JS_MODULE_STATUS_EVALUATED; - m1->eval_has_exception = TRUE; + m1->eval_has_exception = true; m1->eval_exception = JS_DupValue(ctx, result); m1->cycle_root = m; /* spec bug: should be present */ stack_top = m1->stack_prev; @@ -28104,10 +28104,10 @@ static __exception int js_parse_export(JSParseState *s) tok = s->token.val; if (tok == TOK_CLASS) { - return js_parse_class(s, FALSE, JS_PARSE_EXPORT_NAMED); + return js_parse_class(s, false, JS_PARSE_EXPORT_NAMED); } else if (tok == TOK_FUNCTION || (token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) == TOK_FUNCTION)) { + peek_token(s, true) == TOK_FUNCTION)) { return js_parse_function_decl2(s, JS_PARSE_FUNC_STATEMENT, JS_FUNC_NORMAL, JS_ATOM_NULL, s->token.ptr, @@ -28216,10 +28216,10 @@ static __exception int js_parse_export(JSParseState *s) break; case TOK_DEFAULT: if (s->token.val == TOK_CLASS) { - return js_parse_class(s, FALSE, JS_PARSE_EXPORT_DEFAULT); + return js_parse_class(s, false, JS_PARSE_EXPORT_DEFAULT); } else if (s->token.val == TOK_FUNCTION || (token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) == TOK_FUNCTION)) { + peek_token(s, true) == TOK_FUNCTION)) { return js_parse_function_decl2(s, JS_PARSE_FUNC_STATEMENT, JS_FUNC_NORMAL, JS_ATOM_NULL, s->token.ptr, @@ -28249,7 +28249,7 @@ static __exception int js_parse_export(JSParseState *s) case TOK_VAR: case TOK_LET: case TOK_CONST: - return js_parse_var(s, TRUE, tok, TRUE); + return js_parse_var(s, true, tok, true); default: return js_parse_error(s, "invalid export syntax"); } @@ -28257,9 +28257,9 @@ static __exception int js_parse_export(JSParseState *s) } static int add_closure_var(JSContext *ctx, JSFunctionDef *s, - BOOL is_local, BOOL is_arg, + bool is_local, bool is_arg, int var_idx, JSAtom var_name, - BOOL is_const, BOOL is_lexical, + bool is_const, bool is_lexical, JSVarKindEnum var_kind); static int add_import(JSParseState *s, JSModuleDef *m, @@ -28268,7 +28268,7 @@ static int add_import(JSParseState *s, JSModuleDef *m, JSContext *ctx = s->ctx; int i, var_idx; JSImportEntry *mi; - BOOL is_local; + bool is_local; if (local_name == JS_ATOM_arguments || local_name == JS_ATOM_eval) return js_parse_error(s, "invalid import binding"); @@ -28281,9 +28281,9 @@ static int add_import(JSParseState *s, JSModuleDef *m, } is_local = (import_name == JS_ATOM__star_); - var_idx = add_closure_var(ctx, s->cur_func, is_local, FALSE, + var_idx = add_closure_var(ctx, s->cur_func, is_local, false, m->import_entries_count, - local_name, TRUE, TRUE, JS_VAR_NORMAL); + local_name, true, true, JS_VAR_NORMAL); if (var_idx < 0) return -1; if (js_resize_array(ctx, (void **)&m->import_entries, @@ -28419,7 +28419,7 @@ static __exception int js_parse_source_element(JSParseState *s) if (s->token.val == TOK_FUNCTION || (token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) == TOK_FUNCTION)) { + peek_token(s, true) == TOK_FUNCTION)) { if (js_parse_function_decl(s, JS_PARSE_FUNC_STATEMENT, JS_FUNC_NORMAL, JS_ATOM_NULL, s->token.ptr, @@ -28430,7 +28430,7 @@ static __exception int js_parse_source_element(JSParseState *s) if (js_parse_export(s)) return -1; } else if (s->token.val == TOK_IMPORT && fd->module && - ((tok = peek_token(s, FALSE)) != '(' && tok != '.')) { + ((tok = peek_token(s, false)) != '(' && tok != '.')) { /* the peek_token is needed to avoid confusion with ImportCall (dynamic import) or import.meta */ if (js_parse_import(s)) @@ -28445,8 +28445,8 @@ static __exception int js_parse_source_element(JSParseState *s) /* `filename` may be pure ASCII or UTF-8 encoded */ static JSFunctionDef *js_new_function_def(JSContext *ctx, JSFunctionDef *parent, - BOOL is_eval, - BOOL is_func_expr, + bool is_eval, + bool is_func_expr, const char *filename, int line_num, int col_num) @@ -28509,7 +28509,7 @@ static JSFunctionDef *js_new_function_def(JSContext *ctx, static void free_bytecode_atoms(JSRuntime *rt, const uint8_t *bc_buf, int bc_len, - BOOL use_short_opcodes) + bool use_short_opcodes) { int pos, len, op; JSAtom atom; @@ -28644,7 +28644,7 @@ static void dump_byte_code(JSContext *ctx, int pass, const JSOpCode *oi; int pos, pos_next, op, size, idx, addr, line, line1, in_source; uint8_t *bits = js_mallocz(ctx, len * sizeof(*bits)); - BOOL use_short_opcodes = (b != NULL); + bool use_short_opcodes = (b != NULL); if (start_pos != 0 || bits == NULL) goto no_labels; @@ -29058,9 +29058,9 @@ static __maybe_unused void js_dump_function_bytecode(JSContext *ctx, JSFunctionB #endif static int add_closure_var(JSContext *ctx, JSFunctionDef *s, - BOOL is_local, BOOL is_arg, + bool is_local, bool is_arg, int var_idx, JSAtom var_name, - BOOL is_const, BOOL is_lexical, + bool is_const, bool is_lexical, JSVarKindEnum var_kind) { JSClosureVar *cv; @@ -29101,12 +29101,12 @@ static int find_closure_var(JSContext *ctx, JSFunctionDef *s, } /* 'fd' must be a parent of 's'. Create in 's' a closure referencing a - local variable (is_local = TRUE) or a closure (is_local = FALSE) in + local variable (is_local = true) or a closure (is_local = false) in 'fd' */ static int get_closure_var2(JSContext *ctx, JSFunctionDef *s, - JSFunctionDef *fd, BOOL is_local, - BOOL is_arg, int var_idx, JSAtom var_name, - BOOL is_const, BOOL is_lexical, + JSFunctionDef *fd, bool is_local, + bool is_arg, int var_idx, JSAtom var_name, + bool is_const, bool is_lexical, JSVarKindEnum var_kind) { int i; @@ -29117,7 +29117,7 @@ static int get_closure_var2(JSContext *ctx, JSFunctionDef *s, is_const, is_lexical, var_kind); if (var_idx < 0) return -1; - is_local = FALSE; + is_local = false; } for(i = 0; i < s->closure_var_count; i++) { JSClosureVar *cv = &s->closure_var[i]; @@ -29130,12 +29130,12 @@ static int get_closure_var2(JSContext *ctx, JSFunctionDef *s, } static int get_closure_var(JSContext *ctx, JSFunctionDef *s, - JSFunctionDef *fd, BOOL is_arg, + JSFunctionDef *fd, bool is_arg, int var_idx, JSAtom var_name, - BOOL is_const, BOOL is_lexical, + bool is_const, bool is_lexical, JSVarKindEnum var_kind) { - return get_closure_var2(ctx, s, fd, TRUE, is_arg, + return get_closure_var2(ctx, s, fd, true, is_arg, var_idx, var_name, is_const, is_lexical, var_kind); } @@ -29148,7 +29148,7 @@ static int get_with_scope_opcode(int op) return OP_with_get_var + (op - OP_scope_get_var); } -static BOOL can_opt_put_ref_value(const uint8_t *bc_buf, int pos) +static bool can_opt_put_ref_value(const uint8_t *bc_buf, int pos) { int opcode = bc_buf[pos]; return (bc_buf[pos + 1] == OP_put_ref_value && @@ -29158,7 +29158,7 @@ static BOOL can_opt_put_ref_value(const uint8_t *bc_buf, int pos) opcode == OP_rot3l)); } -static BOOL can_opt_put_global_ref_value(const uint8_t *bc_buf, int pos) +static bool can_opt_put_global_ref_value(const uint8_t *bc_buf, int pos) { int opcode = bc_buf[pos]; return (bc_buf[pos + 1] == OP_put_ref_value && @@ -29218,7 +29218,7 @@ static int optimize_scope_make_global_ref(JSContext *ctx, JSFunctionDef *s, JSAtom var_name) { int label_pos, end_pos, pos, op; - BOOL is_strict_mode = s->is_strict_mode; + bool is_strict_mode = s->is_strict_mode; /* replace the reference get/put with normal variable accesses */ @@ -29336,7 +29336,7 @@ static int resolve_pseudo_var(JSContext *ctx, JSFunctionDef *s, the case, handle it and jump to 'label_done' */ static void var_object_test(JSContext *ctx, JSFunctionDef *s, JSAtom var_name, int op, DynBuf *bc, - int *plabel_done, BOOL is_with) + int *plabel_done, bool is_with) { dbuf_putc(bc, get_with_scope_opcode(op)); dbuf_put_u32(bc, JS_DupAtom(ctx, var_name)); @@ -29357,7 +29357,7 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, int label_done; JSFunctionDef *fd; JSVarDef *vd; - BOOL is_pseudo_var, is_arg_scope; + bool is_pseudo_var, is_arg_scope; label_done = -1; @@ -29540,7 +29540,7 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, break; } else if (vd->var_name == JS_ATOM__with_ && !is_pseudo_var) { vd->is_captured = 1; - idx = get_closure_var(ctx, s, fd, FALSE, idx, vd->var_name, FALSE, FALSE, JS_VAR_NORMAL); + idx = get_closure_var(ctx, s, fd, false, idx, vd->var_name, false, false, JS_VAR_NORMAL); if (idx >= 0) { dbuf_putc(bc, OP_get_var_ref); dbuf_put_u16(bc, idx); @@ -29577,9 +29577,9 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, if (!is_arg_scope && fd->var_object_idx >= 0 && !is_pseudo_var) { vd = &fd->vars[fd->var_object_idx]; vd->is_captured = 1; - idx = get_closure_var(ctx, s, fd, FALSE, + idx = get_closure_var(ctx, s, fd, false, fd->var_object_idx, vd->var_name, - FALSE, FALSE, JS_VAR_NORMAL); + false, false, JS_VAR_NORMAL); dbuf_putc(bc, OP_get_var_ref); dbuf_put_u16(bc, idx); var_object_test(ctx, s, var_name, op, bc, &label_done, 0); @@ -29589,9 +29589,9 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, if (fd->arg_var_object_idx >= 0 && !is_pseudo_var) { vd = &fd->vars[fd->arg_var_object_idx]; vd->is_captured = 1; - idx = get_closure_var(ctx, s, fd, FALSE, + idx = get_closure_var(ctx, s, fd, false, fd->arg_var_object_idx, vd->var_name, - FALSE, FALSE, JS_VAR_NORMAL); + false, false, JS_VAR_NORMAL); dbuf_putc(bc, OP_get_var_ref); dbuf_put_u16(bc, idx); var_object_test(ctx, s, var_name, op, bc, &label_done, 0); @@ -29612,7 +29612,7 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, if (var_name == cv->var_name) { if (fd != s) { idx = get_closure_var2(ctx, s, fd, - FALSE, + false, cv->is_arg, idx1, cv->var_name, cv->is_const, cv->is_lexical, cv->var_kind); @@ -29626,9 +29626,9 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, int is_with = (cv->var_name == JS_ATOM__with_); if (fd != s) { idx = get_closure_var2(ctx, s, fd, - FALSE, + false, cv->is_arg, idx1, - cv->var_name, FALSE, FALSE, + cv->var_name, false, false, JS_VAR_NORMAL); } else { idx = idx1; @@ -29645,12 +29645,12 @@ static int resolve_scope_var(JSContext *ctx, JSFunctionDef *s, if (var_idx & ARGUMENT_VAR_OFFSET) { fd->args[var_idx - ARGUMENT_VAR_OFFSET].is_captured = 1; idx = get_closure_var(ctx, s, fd, - TRUE, var_idx - ARGUMENT_VAR_OFFSET, - var_name, FALSE, FALSE, JS_VAR_NORMAL); + true, var_idx - ARGUMENT_VAR_OFFSET, + var_name, false, false, JS_VAR_NORMAL); } else { fd->vars[var_idx].is_captured = 1; idx = get_closure_var(ctx, s, fd, - FALSE, var_idx, + false, var_idx, var_name, fd->vars[var_idx].is_const, fd->vars[var_idx].is_lexical, @@ -29795,7 +29795,7 @@ static int find_private_class_field_all(JSContext *ctx, JSFunctionDef *fd, return -1; } -static void get_loc_or_ref(DynBuf *bc, BOOL is_ref, int idx) +static void get_loc_or_ref(DynBuf *bc, bool is_ref, int idx) { /* if the field is not initialized, the error is catched when accessing it */ @@ -29807,23 +29807,23 @@ static void get_loc_or_ref(DynBuf *bc, BOOL is_ref, int idx) } static int resolve_scope_private_field1(JSContext *ctx, - BOOL *pis_ref, int *pvar_kind, + bool *pis_ref, int *pvar_kind, JSFunctionDef *s, JSAtom var_name, int scope_level) { int idx, var_kind; JSFunctionDef *fd; - BOOL is_ref; + bool is_ref; fd = s; - is_ref = FALSE; + is_ref = false; for(;;) { idx = find_private_class_field_all(ctx, fd, var_name, scope_level); if (idx >= 0) { var_kind = fd->vars[idx].var_kind; if (is_ref) { - idx = get_closure_var(ctx, s, fd, FALSE, idx, var_name, - TRUE, TRUE, JS_VAR_NORMAL); + idx = get_closure_var(ctx, s, fd, false, idx, var_name, + true, true, JS_VAR_NORMAL); if (idx < 0) return -1; } @@ -29837,10 +29837,10 @@ static int resolve_scope_private_field1(JSContext *ctx, JSClosureVar *cv = &fd->closure_var[idx]; if (cv->var_name == var_name) { var_kind = cv->var_kind; - is_ref = TRUE; + is_ref = true; if (fd != s) { idx = get_closure_var2(ctx, s, fd, - FALSE, + false, cv->is_arg, idx, cv->var_name, cv->is_const, cv->is_lexical, @@ -29860,7 +29860,7 @@ static int resolve_scope_private_field1(JSContext *ctx, } else { fd = fd->parent; } - is_ref = TRUE; + is_ref = true; } done: *pis_ref = is_ref; @@ -29874,7 +29874,7 @@ static int resolve_scope_private_field(JSContext *ctx, JSFunctionDef *s, DynBuf *bc) { int idx, var_kind; - BOOL is_ref; + bool is_ref; idx = resolve_scope_private_field1(ctx, &is_ref, &var_kind, s, var_name, scope_level); @@ -29983,7 +29983,7 @@ static void mark_eval_captured_variables(JSContext *ctx, JSFunctionDef *s, } /* XXX: should handle the argument scope generically */ -static BOOL is_var_in_arg_scope(const JSVarDef *vd) +static bool is_var_in_arg_scope(const JSVarDef *vd) { return (vd->var_name == JS_ATOM_home_object || vd->var_name == JS_ATOM_this_active_func || @@ -29998,7 +29998,7 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) JSFunctionDef *fd; JSVarDef *vd; int i, scope_level, scope_idx; - BOOL has_arguments_binding, has_this_binding, is_arg_scope; + bool has_arguments_binding, has_this_binding, is_arg_scope; /* in non strict mode, variables are created in the caller's environment object */ @@ -30058,12 +30058,12 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) fd->this_active_func_var_idx = add_var(ctx, fd, JS_ATOM_this_active_func); if (fd->has_home_object && fd->home_object_var_idx < 0) fd->home_object_var_idx = add_var(ctx, fd, JS_ATOM_home_object); - has_this_binding = TRUE; + has_this_binding = true; } /* add 'arguments' if it was not previously added */ if (!has_arguments_binding && fd->has_arguments_binding) { add_arguments_var(ctx, fd); - has_arguments_binding = TRUE; + has_arguments_binding = true; } /* add function name */ if (fd->is_func_expr && fd->func_name != JS_ATOM_NULL) @@ -30074,7 +30074,7 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) while (scope_idx >= 0) { vd = &fd->vars[scope_idx]; vd->is_captured = 1; - get_closure_var(ctx, s, fd, FALSE, scope_idx, + get_closure_var(ctx, s, fd, false, scope_idx, vd->var_name, vd->is_const, vd->is_lexical, vd->var_kind); scope_idx = vd->scope_next; } @@ -30086,7 +30086,7 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) vd = &fd->args[i]; if (vd->var_name != JS_ATOM_NULL) { get_closure_var(ctx, s, fd, - TRUE, i, vd->var_name, FALSE, + true, i, vd->var_name, false, vd->is_lexical, JS_VAR_NORMAL); } } @@ -30097,7 +30097,7 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) vd->var_name != JS_ATOM__ret_ && vd->var_name != JS_ATOM_NULL) { get_closure_var(ctx, s, fd, - FALSE, i, vd->var_name, FALSE, + false, i, vd->var_name, false, vd->is_lexical, JS_VAR_NORMAL); } } @@ -30107,7 +30107,7 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) /* do not close top level last result */ if (vd->scope_level == 0 && is_var_in_arg_scope(vd)) { get_closure_var(ctx, s, fd, - FALSE, i, vd->var_name, FALSE, + false, i, vd->var_name, false, vd->is_lexical, JS_VAR_NORMAL); } } @@ -30119,7 +30119,7 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) for (idx = 0; idx < fd->closure_var_count; idx++) { JSClosureVar *cv = &fd->closure_var[idx]; get_closure_var2(ctx, s, fd, - FALSE, cv->is_arg, + false, cv->is_arg, idx, cv->var_name, cv->is_const, cv->is_lexical, cv->var_kind); } @@ -30130,8 +30130,8 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s) static void set_closure_from_var(JSContext *ctx, JSClosureVar *cv, JSVarDef *vd, int var_idx) { - cv->is_local = TRUE; - cv->is_arg = FALSE; + cv->is_local = true; + cv->is_arg = false; cv->is_const = vd->is_const; cv->is_lexical = vd->is_lexical; cv->var_kind = vd->var_kind; @@ -30146,7 +30146,7 @@ static __exception int add_closure_variables(JSContext *ctx, JSFunctionDef *s, { int i, count; JSVarDef *vd; - BOOL is_arg_scope; + bool is_arg_scope; count = b->arg_count + b->var_count + b->closure_var_count; s->closure_var = NULL; @@ -30172,10 +30172,10 @@ static __exception int add_closure_variables(JSContext *ctx, JSFunctionDef *s, for(i = 0; i < b->arg_count; i++) { JSClosureVar *cv = &s->closure_var[s->closure_var_count++]; vd = &b->vardefs[i]; - cv->is_local = TRUE; - cv->is_arg = TRUE; - cv->is_const = FALSE; - cv->is_lexical = FALSE; + cv->is_local = true; + cv->is_arg = true; + cv->is_const = false; + cv->is_lexical = false; cv->var_kind = JS_VAR_NORMAL; cv->var_idx = i; cv->var_name = JS_DupAtom(ctx, vd->var_name); @@ -30201,7 +30201,7 @@ static __exception int add_closure_variables(JSContext *ctx, JSFunctionDef *s, for(i = 0; i < b->closure_var_count; i++) { JSClosureVar *cv0 = &b->closure_var[i]; JSClosureVar *cv = &s->closure_var[s->closure_var_count++]; - cv->is_local = FALSE; + cv->is_local = false; cv->is_arg = cv0->is_arg; cv->is_const = cv0->is_const; cv->is_lexical = cv0->is_lexical; @@ -30229,12 +30229,12 @@ typedef struct CodeContext { #define M3(op1, op2, op3) ((uint32_t)(op1) | ((uint32_t)(op2) << 8) | ((uint32_t)(op3) << 16)) #define M4(op1, op2, op3, op4) ((uint32_t)(op1) | ((uint32_t)(op2) << 8) | ((uint32_t)(op3) << 16) | ((uint32_t)(op4) << 24)) -static BOOL code_match(CodeContext *s, int pos, ...) +static bool code_match(CodeContext *s, int pos, ...) { const uint8_t *tab = s->bc_buf; int op, len, op1, line_num, col_num, pos_next; va_list ap; - BOOL ret = FALSE; + bool ret = false; line_num = -1; col_num = -1; @@ -30246,7 +30246,7 @@ static BOOL code_match(CodeContext *s, int pos, ...) s->pos = pos; s->line_num = line_num; s->col_num = col_num; - ret = TRUE; + ret = true; break; } for (;;) { @@ -30399,7 +30399,7 @@ static void instantiate_hoisted_definitions(JSContext *ctx, JSFunctionDef *s, Dy for(i = 0; i < s->global_var_count; i++) { JSGlobalVar *hf = &s->global_vars[i]; int has_closure = 0; - BOOL force_init = hf->force_init; + bool force_init = hf->force_init; /* we are in an eval, so the closure contains all the enclosing variables */ /* If the outer function has a variable environment, @@ -30408,7 +30408,7 @@ static void instantiate_hoisted_definitions(JSContext *ctx, JSFunctionDef *s, Dy JSClosureVar *cv = &s->closure_var[idx]; if (cv->var_name == hf->var_name) { has_closure = 2; - force_init = FALSE; + force_init = false; break; } if (cv->var_name == JS_ATOM__var_ || @@ -30416,7 +30416,7 @@ static void instantiate_hoisted_definitions(JSContext *ctx, JSFunctionDef *s, Dy dbuf_putc(bc, OP_get_var_ref); dbuf_put_u16(bc, idx); has_closure = 1; - force_init = TRUE; + force_init = true; break; } } @@ -30994,7 +30994,7 @@ static RelocEntry *add_reloc(JSContext *ctx, LabelSlot *ls, uint32_t addr, int s return re; } -static BOOL code_has_label(CodeContext *s, int pos, int label) +static bool code_has_label(CodeContext *s, int pos, int label) { while (pos < s->bc_len) { int op = s->bc_buf[pos]; @@ -31005,18 +31005,18 @@ static BOOL code_has_label(CodeContext *s, int pos, int label) if (op == OP_label) { int lab = get_u32(s->bc_buf + pos + 1); if (lab == label) - return TRUE; + return true; pos += 5; continue; } if (op == OP_goto) { int lab = get_u32(s->bc_buf + pos + 1); if (lab == label) - return TRUE; + return true; } break; } - return FALSE; + return false; } /* return the target label, following the OP_goto jumps @@ -32003,7 +32003,7 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s) /* set the new byte code */ dbuf_free(&s->byte_code); s->byte_code = bc_out; - s->use_short_opcodes = TRUE; + s->use_short_opcodes = true; if (dbuf_error(&s->byte_code)) { JS_ThrowOutOfMemory(ctx); return -1; @@ -32278,7 +32278,7 @@ static int add_module_variables(JSContext *ctx, JSFunctionDef *fd) for(i = 0; i < fd->global_var_count; i++) { hf = &fd->global_vars[i]; - if (add_closure_var(ctx, fd, TRUE, FALSE, i, hf->var_name, hf->is_const, + if (add_closure_var(ctx, fd, true, false, i, hf->var_name, hf->is_const, hf->is_lexical, JS_VAR_NORMAL) < 0) return -1; } @@ -32513,7 +32513,7 @@ static void free_function_bytecode(JSRuntime *rt, JSFunctionBytecode *b) { int i; - free_bytecode_atoms(rt, b->byte_code_buf, b->byte_code_len, TRUE); + free_bytecode_atoms(rt, b->byte_code_buf, b->byte_code_len, true); if (b->ic) free_ic(rt, b->ic); @@ -32550,7 +32550,7 @@ static __exception int js_parse_directives(JSParseState *s) { char str[20]; JSParsePos pos; - BOOL has_semi; + bool has_semi; if (s->token.val != TOK_STRING) return 0; @@ -32565,16 +32565,16 @@ static __exception int js_parse_directives(JSParseState *s) if (next_token(s)) return -1; - has_semi = FALSE; + has_semi = false; switch (s->token.val) { case ';': if (next_token(s)) return -1; - has_semi = TRUE; + has_semi = true; break; case '}': case TOK_EOF: - has_semi = TRUE; + has_semi = true; break; case TOK_NUMBER: case TOK_STRING: @@ -32617,7 +32617,7 @@ static __exception int js_parse_directives(JSParseState *s) case TOK_STATIC: /* automatic insertion of ';' */ if (s->got_lf) - has_semi = TRUE; + has_semi = true; break; default: break; @@ -32625,14 +32625,14 @@ static __exception int js_parse_directives(JSParseState *s) if (!has_semi) break; if (!strcmp(str, "use strict")) { - s->cur_func->has_use_strict = TRUE; - s->cur_func->is_strict_mode = TRUE; + s->cur_func->has_use_strict = true; + s->cur_func->is_strict_mode = true; } } return js_parse_seek_token(s, &pos); } -static BOOL js_invalid_strict_name(JSAtom name) { +static bool js_invalid_strict_name(JSAtom name) { switch (name) { case JS_ATOM_eval: case JS_ATOM_arguments: @@ -32645,9 +32645,9 @@ static BOOL js_invalid_strict_name(JSAtom name) { case JS_ATOM_public: case JS_ATOM_static: case JS_ATOM_yield: - return TRUE; + return true; default: - return FALSE; + return false; } } @@ -32705,21 +32705,21 @@ static JSFunctionDef *js_parse_function_class_fields_init(JSParseState *s) { JSFunctionDef *fd; - fd = js_new_function_def(s->ctx, s->cur_func, FALSE, FALSE, + fd = js_new_function_def(s->ctx, s->cur_func, false, false, s->filename, 0, 0); if (!fd) return NULL; fd->func_name = JS_ATOM_NULL; - fd->has_prototype = FALSE; - fd->has_home_object = TRUE; - - fd->has_arguments_binding = FALSE; - fd->has_this_binding = TRUE; - fd->is_derived_class_constructor = FALSE; - fd->new_target_allowed = TRUE; - fd->super_call_allowed = FALSE; + fd->has_prototype = false; + fd->has_home_object = true; + + fd->has_arguments_binding = false; + fd->has_this_binding = true; + fd->is_derived_class_constructor = false; + fd->new_target_allowed = true; + fd->super_call_allowed = false; fd->super_allowed = fd->has_home_object; - fd->arguments_allowed = FALSE; + fd->arguments_allowed = false; fd->func_kind = JS_FUNC_NORMAL; fd->func_type = JS_PARSE_FUNC_METHOD; @@ -32740,10 +32740,10 @@ static __exception int js_parse_function_decl2(JSParseState *s, { JSContext *ctx = s->ctx; JSFunctionDef *fd = s->cur_func; - BOOL is_expr; + bool is_expr; int func_idx, lexical_func_idx = -1; - BOOL has_opt_arg; - BOOL create_func_var = FALSE; + bool has_opt_arg; + bool create_func_var = false; is_expr = (func_type != JS_PARSE_FUNC_STATEMENT && func_type != JS_PARSE_FUNC_VAR); @@ -32753,7 +32753,7 @@ static __exception int js_parse_function_decl2(JSParseState *s, func_type == JS_PARSE_FUNC_EXPR) { if (func_kind == JS_FUNC_NORMAL && token_is_pseudo_keyword(s, JS_ATOM_async) && - peek_token(s, TRUE) != '\n') { + peek_token(s, true) != '\n') { if (next_token(s)) return -1; func_kind = JS_FUNC_ASYNC; @@ -32812,10 +32812,10 @@ static __exception int js_parse_function_decl2(JSParseState *s, if (func_type == JS_PARSE_FUNC_VAR) { if (!fd->is_strict_mode && func_kind == JS_FUNC_NORMAL - && find_lexical_decl(ctx, fd, func_name, fd->scope_first, FALSE) < 0 + && find_lexical_decl(ctx, fd, func_name, fd->scope_first, false) < 0 && !((func_idx = find_var(ctx, fd, func_name)) >= 0 && (func_idx & ARGUMENT_VAR_OFFSET)) && !(func_name == JS_ATOM_arguments && fd->has_arguments_binding)) { - create_func_var = TRUE; + create_func_var = true; } /* Create the lexical name here so that the function closure contains it */ @@ -32848,7 +32848,7 @@ static __exception int js_parse_function_decl2(JSParseState *s, } } - fd = js_new_function_def(ctx, fd, FALSE, is_expr, s->filename, + fd = js_new_function_def(ctx, fd, false, is_expr, s->filename, function_line_num, function_col_num); if (!fd) { JS_FreeAtom(ctx, func_name); @@ -32878,18 +32878,18 @@ static __exception int js_parse_function_decl2(JSParseState *s, fd->super_allowed = fd->parent->super_allowed; fd->arguments_allowed = fd->parent->arguments_allowed; } else if (func_type == JS_PARSE_FUNC_CLASS_STATIC_INIT) { - fd->new_target_allowed = TRUE; // although new.target === undefined - fd->super_call_allowed = FALSE; - fd->super_allowed = TRUE; - fd->arguments_allowed = FALSE; + fd->new_target_allowed = true; // although new.target === undefined + fd->super_call_allowed = false; + fd->super_allowed = true; + fd->arguments_allowed = false; } else { - fd->new_target_allowed = TRUE; + fd->new_target_allowed = true; fd->super_call_allowed = fd->is_derived_class_constructor; fd->super_allowed = fd->has_home_object; - fd->arguments_allowed = TRUE; + fd->arguments_allowed = true; } - /* fd->in_function_body == FALSE prevents yield/await during the parsing + /* fd->in_function_body == false prevents yield/await during the parsing of the arguments in generator/async functions. They are parsed as regular identifiers for other function kinds. */ fd->func_kind = func_kind; @@ -32906,9 +32906,9 @@ static __exception int js_parse_function_decl2(JSParseState *s, } /* parse arguments */ - fd->has_simple_parameter_list = TRUE; - fd->has_parameter_expressions = FALSE; - has_opt_arg = FALSE; + fd->has_simple_parameter_list = true; + fd->has_parameter_expressions = false; + has_opt_arg = false; if (func_type == JS_PARSE_FUNC_ARROW && s->token.val == TOK_IDENT) { JSAtom name; if (s->token.u.ident.is_reserved) { @@ -32924,9 +32924,9 @@ static __exception int js_parse_function_decl2(JSParseState *s, int skip_bits; /* if there is an '=' inside the parameter list, we consider there is a parameter expression inside */ - js_parse_skip_parens_token(s, &skip_bits, FALSE); + js_parse_skip_parens_token(s, &skip_bits, false); if (skip_bits & SKIP_HAS_ASSIGNMENT) - fd->has_parameter_expressions = TRUE; + fd->has_parameter_expressions = true; if (next_token(s)) goto fail; } else { @@ -32942,17 +32942,17 @@ static __exception int js_parse_function_decl2(JSParseState *s, while (s->token.val != ')') { JSAtom name; - BOOL rest = FALSE; + bool rest = false; int idx, has_initializer; if (s->token.val == TOK_ELLIPSIS) { - fd->has_simple_parameter_list = FALSE; - rest = TRUE; + fd->has_simple_parameter_list = false; + rest = true; if (next_token(s)) goto fail; } if (s->token.val == '[' || s->token.val == '{') { - fd->has_simple_parameter_list = FALSE; + fd->has_simple_parameter_list = false; if (rest) { emit_op(s, OP_rest); emit_u16(s, fd->arg_count); @@ -32962,11 +32962,11 @@ static __exception int js_parse_function_decl2(JSParseState *s, emit_op(s, OP_get_arg); emit_u16(s, idx); } - has_initializer = js_parse_destructuring_element(s, fd->has_parameter_expressions ? TOK_LET : TOK_VAR, 1, TRUE, -1, TRUE); + has_initializer = js_parse_destructuring_element(s, fd->has_parameter_expressions ? TOK_LET : TOK_VAR, 1, true, -1, true); if (has_initializer < 0) goto fail; if (has_initializer) - has_opt_arg = TRUE; + has_opt_arg = true; if (!has_opt_arg) fd->defined_arg_count++; } else if (s->token.val == TOK_IDENT) { @@ -33002,13 +33002,13 @@ static __exception int js_parse_function_decl2(JSParseState *s, } emit_op(s, OP_put_arg); emit_u16(s, idx); - fd->has_simple_parameter_list = FALSE; - has_opt_arg = TRUE; + fd->has_simple_parameter_list = false; + has_opt_arg = true; } else if (s->token.val == '=') { int label; - fd->has_simple_parameter_list = FALSE; - has_opt_arg = TRUE; + fd->has_simple_parameter_list = false; + has_opt_arg = true; if (next_token(s)) goto fail; @@ -33109,7 +33109,7 @@ static __exception int js_parse_function_decl2(JSParseState *s, /* in generators, yield expression is forbidden during the parsing of the arguments */ - fd->in_function_body = TRUE; + fd->in_function_body = true; push_scope(s); /* enter body scope */ fd->body_scope = fd->scope_level; @@ -33171,7 +33171,7 @@ static __exception int js_parse_function_decl2(JSParseState *s, /* in case there is no return, add one */ if (js_is_live_code(s)) { - emit_return(s, FALSE); + emit_return(s, false); } done: s->cur_func = fd->parent; @@ -33349,9 +33349,9 @@ static __exception int js_parse_program(JSParseState *s) emit_op(s, OP_get_loc); emit_u16(s, fd->eval_ret_idx); } - emit_return(s, TRUE); + emit_return(s, true); } else { - emit_return(s, FALSE); + emit_return(s, false); } return 0; @@ -33426,7 +33426,7 @@ static JSValue __JS_EvalInternal(JSContext *ctx, JSValue this_obj, JSFunctionBytecode *b; JSFunctionDef *fd; JSModuleDef *m; - BOOL is_strict_mode; + bool is_strict_mode; js_parse_init(ctx, s, input, input_len, filename); skip_shebang(&s->buf_ptr, s->buf_end); @@ -33455,10 +33455,10 @@ static JSValue __JS_EvalInternal(JSContext *ctx, JSValue this_obj, m = js_new_module_def(ctx, module_name); if (!m) return JS_EXCEPTION; - is_strict_mode = TRUE; + is_strict_mode = true; } } - fd = js_new_function_def(ctx, NULL, TRUE, FALSE, filename, 1, 1); + fd = js_new_function_def(ctx, NULL, true, false, filename, 1, 1); if (!fd) goto fail1; s->cur_func = fd; @@ -33471,10 +33471,10 @@ static JSValue __JS_EvalInternal(JSContext *ctx, JSValue this_obj, fd->super_allowed = b->super_allowed; fd->arguments_allowed = b->arguments_allowed; } else { - fd->new_target_allowed = FALSE; - fd->super_call_allowed = FALSE; - fd->super_allowed = FALSE; - fd->arguments_allowed = TRUE; + fd->new_target_allowed = false; + fd->super_call_allowed = false; + fd->super_allowed = false; + fd->arguments_allowed = true; } fd->is_strict_mode = is_strict_mode; fd->func_name = JS_DupAtom(ctx, JS_ATOM__eval_); @@ -33484,7 +33484,7 @@ static JSValue __JS_EvalInternal(JSContext *ctx, JSValue this_obj, } fd->module = m; if (m != NULL || (flags & JS_EVAL_FLAG_ASYNC)) { - fd->in_function_body = TRUE; + fd->in_function_body = true; fd->func_kind = JS_FUNC_ASYNC; } s->is_module = (m != NULL); @@ -33728,11 +33728,11 @@ typedef enum BCTagEnum { typedef struct BCWriterState { JSContext *ctx; DynBuf dbuf; - BOOL allow_bytecode : 8; - BOOL allow_sab : 8; - BOOL allow_reference : 8; - BOOL allow_source : 1; - BOOL allow_debug : 1; + bool allow_bytecode; + bool allow_sab; + bool allow_reference; + bool allow_source; + bool allow_debug; uint32_t first_atom; uint32_t *atom_to_idx; int atom_to_idx_size; @@ -33742,7 +33742,7 @@ typedef struct BCWriterState { uint8_t **sab_tab; int sab_tab_len; int sab_tab_size; - /* list of referenced objects (used if allow_reference = TRUE) */ + /* list of referenced objects (used if allow_reference = true) */ JSObjectList object_list; } BCWriterState; @@ -33932,7 +33932,7 @@ static void bc_byte_swap(uint8_t *bc_buf, int bc_len) } } -static BOOL is_ic_op(uint8_t op) +static bool is_ic_op(uint8_t op) { return op >= OP_get_field_ic && op <= OP_put_field_ic; } @@ -34229,16 +34229,16 @@ static int JS_WriteArray(BCWriterState *s, JSValue obj) uint32_t i, len; JSValue val; int ret; - BOOL is_template; + bool is_template; if (s->allow_bytecode && !p->extensible) { /* not extensible array: we consider it is a template when we are saving bytecode */ bc_put_u8(s, BC_TAG_TEMPLATE_OBJECT); - is_template = TRUE; + is_template = true; } else { bc_put_u8(s, BC_TAG_ARRAY); - is_template = FALSE; + is_template = false; } if (js_get_length32(s->ctx, &len, obj)) goto fail1; @@ -34357,12 +34357,12 @@ static int JS_WriteRegExp(BCWriterState *s, JSRegExp regexp) JS_WriteString(s, regexp.pattern); if (is_be()) - lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/FALSE); + lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/false); JS_WriteString(s, bc); if (is_be()) - lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/TRUE); + lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/true); return 0; } @@ -34630,9 +34630,9 @@ typedef struct BCReaderState { uint32_t idx_to_atom_count; JSAtom *idx_to_atom; int error_state; - BOOL allow_sab : 8; - BOOL allow_bytecode : 8; - BOOL allow_reference : 8; + bool allow_sab; + bool allow_bytecode; + bool allow_reference; /* object references */ JSObject **objects; int objects_count; @@ -34834,7 +34834,7 @@ static JSString *JS_ReadString(BCReaderState *s) { uint32_t len; size_t size; - BOOL is_wide_char; + bool is_wide_char; JSString *p; if (bc_get_leb128(s, &len)) @@ -35427,7 +35427,7 @@ static JSValue JS_ReadArray(BCReaderState *s, int tag) uint32_t len, i; JSValue val; int ret, prop_flags; - BOOL is_template; + bool is_template; obj = JS_NewArray(ctx); if (BC_add_object_ref(s, obj)) @@ -35539,7 +35539,7 @@ static JSValue JS_ReadArrayBuffer(BCReaderState *s) JS_CLASS_ARRAY_BUFFER, (uint8_t*)s->ptr, js_array_buffer_free, NULL, - /*alloc_flag*/TRUE); + /*alloc_flag*/true); if (JS_IsException(obj)) goto fail; if (BC_add_object_ref(s, obj)) @@ -35583,7 +35583,7 @@ static JSValue JS_ReadSharedArrayBuffer(BCReaderState *s) byte_length, pmax_byte_length, JS_CLASS_SHARED_ARRAY_BUFFER, data_ptr, - NULL, NULL, FALSE); + NULL, NULL, false); if (JS_IsException(obj)) goto fail; if (BC_add_object_ref(s, obj)) @@ -35617,7 +35617,7 @@ static JSValue JS_ReadRegExp(BCReaderState *s) } if (is_be()) - lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/TRUE); + lre_byte_swap(bc->u.str8, bc->len, /*is_byte_swapped*/true); return js_regexp_constructor_internal(ctx, JS_UNDEFINED, JS_MKPTR(JS_TAG_STRING, pattern), @@ -36224,7 +36224,7 @@ static JSValue js_global_isNaN(JSContext *ctx, JSValue this_val, static JSValue js_global_isFinite(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { - BOOL res; + bool res; double d; if (unlikely(JS_ToFloat64(ctx, &d, argv[0]))) return JS_EXCEPTION; @@ -36519,7 +36519,7 @@ static JSValue js_object_setPrototypeOf(JSContext *ctx, JSValue this_val, { JSValue obj; obj = argv[0]; - if (JS_SetPrototypeInternal(ctx, obj, argv[1], TRUE) < 0) + if (JS_SetPrototypeInternal(ctx, obj, argv[1], true) < 0) return JS_EXCEPTION; return js_dup(obj); } @@ -36831,7 +36831,7 @@ static JSValue js_object_groupBy(JSContext *ctx, JSValue this_val, JSValue cb, res, iter, next, groups, k, v, prop; JSValue args[2]; int64_t idx; - BOOL done; + int done; // "is function?" check must be observed before argv[0] is accessed cb = argv[1]; @@ -36841,7 +36841,7 @@ static JSValue js_object_groupBy(JSContext *ctx, JSValue this_val, // TODO(bnoordhuis) add fast path for arrays but as groupBy() is // defined in terms of iterators, the fast path must check that // this[Symbol.iterator] is the built-in array iterator - iter = JS_GetIterator(ctx, argv[0], /*is_async*/FALSE); + iter = JS_GetIterator(ctx, argv[0], /*is_async*/false); if (JS_IsException(iter)) return JS_EXCEPTION; @@ -36973,7 +36973,7 @@ static JSValue js_object_hasOwnProperty(JSContext *ctx, JSValue this_val, JSValue obj; JSAtom atom; JSObject *p; - BOOL ret; + int ret; atom = JS_ValueToAtom(ctx, argv[0]); /* must be done first */ if (unlikely(atom == JS_ATOM_NULL)) @@ -36999,7 +36999,7 @@ static JSValue js_object_hasOwn(JSContext *ctx, JSValue this_val, JSValue obj; JSAtom atom; JSObject *p; - BOOL ret; + int ret; obj = JS_ToObject(ctx, argv[0]); if (JS_IsException(obj)) @@ -37102,7 +37102,7 @@ static JSValue js_object_assign(JSContext *ctx, JSValue this_val, s = JS_ToObject(ctx, argv[i]); if (JS_IsException(s)) goto exception; - if (JS_CopyDataProperties(ctx, obj, s, JS_UNDEFINED, TRUE)) + if (JS_CopyDataProperties(ctx, obj, s, JS_UNDEFINED, true)) goto exception; JS_FreeValue(ctx, s); } @@ -37198,7 +37198,7 @@ static JSValue js_object_isSealed(JSContext *ctx, JSValue this_val, js_free_desc(ctx, &desc); if ((desc.flags & JS_PROP_CONFIGURABLE) || (is_frozen && (desc.flags & JS_PROP_WRITABLE))) { - res = FALSE; + res = false; goto done; } } @@ -37237,7 +37237,7 @@ static JSValue js_object_fromEntries(JSContext *ctx, JSValue this_val, { JSValue obj, iter, next_method = JS_UNDEFINED; JSValue iterable; - BOOL done; + int done; /* RequireObjectCoercible() not necessary because it is tested in JS_GetIterator() by JS_GetProperty() */ @@ -37247,7 +37247,7 @@ static JSValue js_object_fromEntries(JSContext *ctx, JSValue this_val, if (JS_IsException(obj)) return obj; - iter = JS_GetIterator(ctx, iterable, FALSE); + iter = JS_GetIterator(ctx, iterable, false); if (JS_IsException(iter)) goto fail; next_method = JS_GetProperty(ctx, iter, JS_ATOM_next); @@ -37292,7 +37292,7 @@ static JSValue js_object_fromEntries(JSContext *ctx, JSValue this_val, fail: if (JS_IsObject(iter)) { /* close the iterator object, preserving pending exception */ - JS_IteratorClose(ctx, iter, TRUE); + JS_IteratorClose(ctx, iter, true); } JS_FreeValue(ctx, next_method); JS_FreeValue(ctx, iter); @@ -37354,7 +37354,7 @@ static JSValue js_object_set___proto__(JSContext *ctx, JSValue this_val, return JS_ThrowTypeErrorNotAnObject(ctx); if (!JS_IsObject(proto) && !JS_IsNull(proto)) return JS_UNDEFINED; - if (JS_SetPrototypeInternal(ctx, this_val, proto, TRUE) < 0) + if (JS_SetPrototypeInternal(ctx, this_val, proto, true) < 0) return JS_EXCEPTION; else return JS_UNDEFINED; @@ -37379,11 +37379,11 @@ static JSValue js_object_isPrototypeOf(JSContext *ctx, JSValue this_val, if (JS_IsException(v1)) goto exception; if (JS_IsNull(v1)) { - res = FALSE; + res = false; break; } if (JS_VALUE_GET_OBJ(obj) == JS_VALUE_GET_OBJ(v1)) { - res = TRUE; + res = true; break; } /* avoid infinite loop (possible with proxies) */ @@ -37581,7 +37581,7 @@ static JSValue js_function_constructor(JSContext *ctx, JSValue new_target, goto fail1; proto = js_dup(realm->class_proto[func_kind_to_class_id[func_kind]]); } - ret = JS_SetPrototypeInternal(ctx, obj, proto, TRUE); + ret = JS_SetPrototypeInternal(ctx, obj, proto, true); JS_FreeValue(ctx, proto); if (ret < 0) goto fail1; @@ -37876,9 +37876,9 @@ static JSValue iterator_to_array(JSContext *ctx, JSValue items) JSValue iter, next_method = JS_UNDEFINED; JSValue v, r = JS_UNDEFINED; int64_t k; - BOOL done; + int done; - iter = JS_GetIterator(ctx, items, FALSE); + iter = JS_GetIterator(ctx, items, false); if (JS_IsException(iter)) goto exception; next_method = JS_GetProperty(ctx, iter, JS_ATOM_next); @@ -37902,7 +37902,7 @@ static JSValue iterator_to_array(JSContext *ctx, JSValue items) JS_FreeValue(ctx, iter); return r; exception_close: - JS_IteratorClose(ctx, iter, TRUE); + JS_IteratorClose(ctx, iter, true); exception: JS_FreeValue(ctx, r); r = JS_EXCEPTION; @@ -37914,8 +37914,7 @@ static JSValue js_error_constructor(JSContext *ctx, JSValue new_target, { JSValue obj, msg, proto, cause; JSValue message; - int opts; - BOOL present; + int present, opts; if (JS_IsUndefined(new_target)) new_target = JS_GetActiveFunction(ctx); @@ -38187,7 +38186,7 @@ static JSValue js_array_constructor(JSContext *ctx, JSValue new_target, return obj; if (argc == 1 && JS_IsNumber(argv[0])) { uint32_t len; - if (JS_ToArrayLengthFree(ctx, &len, js_dup(argv[0]), TRUE)) + if (JS_ToArrayLengthFree(ctx, &len, js_dup(argv[0]), true)) goto fail; if (JS_SetProperty(ctx, obj, JS_ATOM_length, js_uint32(len)) < 0) goto fail; @@ -38214,7 +38213,7 @@ static JSValue js_array_from(JSContext *ctx, JSValue this_val, int64_t k, len; int done, mapping; - mapping = FALSE; + mapping = false; mapfn = JS_UNDEFINED; this_arg = JS_UNDEFINED; r = JS_UNDEFINED; @@ -38244,7 +38243,7 @@ static JSValue js_array_from(JSContext *ctx, JSValue this_val, if (JS_IsException(r)) goto exception; stack[0] = js_dup(items); - if (js_for_of_start(ctx, &stack[1], FALSE)) + if (js_for_of_start(ctx, &stack[1], false)) goto exception; for (k = 0;; k++) { v = JS_IteratorNext(ctx, stack[0], stack[1], 0, NULL, &done); @@ -38305,7 +38304,7 @@ static JSValue js_array_from(JSContext *ctx, JSValue this_val, exception_close: if (!JS_IsUndefined(stack[0])) - JS_IteratorClose(ctx, stack[0], TRUE); + JS_IteratorClose(ctx, stack[0], true); exception: JS_FreeValue(ctx, r); r = JS_EXCEPTION; @@ -38419,7 +38418,7 @@ static int JS_isConcatSpreadable(JSContext *ctx, JSValue obj) JSValue val; if (!JS_IsObject(obj)) - return FALSE; + return false; val = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_isConcatSpreadable); if (JS_IsException(val)) return -1; @@ -38712,7 +38711,7 @@ static JSValue js_array_every(JSContext *ctx, JSValue this_val, val = JS_GetPropertyInt64(ctx, obj, k); if (JS_IsException(val)) goto exception; - present = TRUE; + present = true; } else { present = JS_TryGetPropertyInt64(ctx, obj, k, &val); if (present < 0) @@ -38853,7 +38852,7 @@ static JSValue js_array_reduce(JSContext *ctx, JSValue this_val, val = JS_GetPropertyInt64(ctx, obj, k1); if (JS_IsException(val)) goto exception; - present = TRUE; + present = true; } else { present = JS_TryGetPropertyInt64(ctx, obj, k1, &val); if (present < 0) @@ -38933,7 +38932,7 @@ static JSValue js_array_includes(JSContext *ctx, JSValue this_val, if (js_get_length64(ctx, &len, obj)) goto exception; - res = TRUE; + res = true; if (len > 0) { n = 0; if (argc > 1) { @@ -38958,7 +38957,7 @@ static JSValue js_array_includes(JSContext *ctx, JSValue this_val, } } } - res = FALSE; + res = false; done: JS_FreeValue(ctx, obj); return js_bool(res); @@ -40098,7 +40097,7 @@ static JSValue js_create_array_iterator(JSContext *ctx, JSValue this_val, static JSValue js_array_iterator_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSArrayIteratorData *it; uint32_t len, idx; @@ -40121,7 +40120,7 @@ static JSValue js_array_iterator_next(JSContext *ctx, JSValue this_val, } else { if (js_get_length32(ctx, &len, it->obj)) { fail1: - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } } @@ -40130,11 +40129,11 @@ static JSValue js_array_iterator_next(JSContext *ctx, JSValue this_val, JS_FreeValue(ctx, it->obj); it->obj = JS_UNDEFINED; done: - *pdone = TRUE; + *pdone = true; return JS_UNDEFINED; } it->idx = idx + 1; - *pdone = FALSE; + *pdone = false; if (it->kind == JS_ITERATOR_KIND_KEY) { return js_uint32(idx); } else { @@ -40186,7 +40185,7 @@ static void js_iterator_wrap_mark(JSRuntime *rt, JSValue val, static JSValue js_iterator_wrap_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSIteratorWrapData *it; JSValue method, ret; @@ -40199,7 +40198,7 @@ static JSValue js_iterator_wrap_next(JSContext *ctx, JSValue this_val, if (JS_IsException(method)) return JS_EXCEPTION; if (JS_IsNull(method) || JS_IsUndefined(method)) { - *pdone = TRUE; + *pdone = true; return JS_UNDEFINED; } ret = JS_IteratorNext2(ctx, it->wrapped_iter, method, argc, argv, pdone); @@ -40391,7 +40390,7 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValue this_val, JSValue item, method, ret, func, index_val, r; JSValue args[2]; int64_t idx; - BOOL done; + int done; if (check_iterator(ctx, this_val) < 0) return JS_EXCEPTION; @@ -40423,7 +40422,7 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValue this_val, if (JS_IsException(ret)) goto fail; if (!JS_ToBoolFree(ctx, ret)) { - if (JS_IteratorClose(ctx, this_val, FALSE) < 0) + if (JS_IteratorClose(ctx, this_val, false) < 0) r = JS_EXCEPTION; else r = JS_FALSE; @@ -40453,7 +40452,7 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValue this_val, goto fail; } if (JS_ToBoolFree(ctx, ret)) { - if (JS_IteratorClose(ctx, this_val, FALSE) < 0) { + if (JS_IteratorClose(ctx, this_val, false) < 0) { JS_FreeValue(ctx, item); r = JS_EXCEPTION; } else { @@ -40508,7 +40507,7 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValue this_val, if (JS_IsException(ret)) goto fail; if (JS_ToBoolFree(ctx, ret)) { - if (JS_IteratorClose(ctx, this_val, FALSE) < 0) + if (JS_IteratorClose(ctx, this_val, false) < 0) r = JS_EXCEPTION; else r = JS_TRUE; @@ -40529,7 +40528,7 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValue this_val, JS_FreeValue(ctx, method); return r; fail: - JS_IteratorClose(ctx, this_val, TRUE); + JS_IteratorClose(ctx, this_val, true); JS_FreeValue(ctx, func); JS_FreeValue(ctx, method); return JS_EXCEPTION; @@ -40541,7 +40540,7 @@ static JSValue js_iterator_proto_reduce(JSContext *ctx, JSValue this_val, JSValue item, method, ret, func, index_val, acc; JSValue args[3]; int64_t idx; - BOOL done; + int done; if (check_iterator(ctx, this_val) < 0) return JS_EXCEPTION; @@ -40590,7 +40589,7 @@ static JSValue js_iterator_proto_reduce(JSContext *ctx, JSValue this_val, JS_FreeValue(ctx, method); return acc; exception: - JS_IteratorClose(ctx, this_val, TRUE); + JS_IteratorClose(ctx, this_val, true); JS_FreeValue(ctx, acc); JS_FreeValue(ctx, func); JS_FreeValue(ctx, method); @@ -40602,7 +40601,7 @@ static JSValue js_iterator_proto_toArray(JSContext *ctx, JSValue this_val, { JSValue item, method, result; int64_t idx; - BOOL done; + int done; result = JS_UNDEFINED; if (check_iterator(ctx, this_val) < 0) @@ -40693,12 +40692,12 @@ static void js_iterator_helper_mark(JSRuntime *rt, JSValue val, static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSIteratorHelperData *it; JSValue ret; - *pdone = FALSE; + *pdone = false; it = JS_GetOpaque2(ctx, this_val, JS_CLASS_ITERATOR_HELPER); if (!it) @@ -40706,7 +40705,7 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, if (it->executing) return JS_ThrowTypeError(ctx, "cannot invoke a running iterator"); if (it->done) { - *pdone = TRUE; + *pdone = true; return JS_UNDEFINED; } @@ -40732,7 +40731,7 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, } JS_FreeValue(ctx, item); if (magic == GEN_MAGIC_RETURN) - *pdone = TRUE; + *pdone = true; if (*pdone) { JS_FreeValue(ctx, method); ret = JS_UNDEFINED; @@ -40844,7 +40843,7 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, method = JS_GetProperty(ctx, it->inner, JS_ATOM_return); if (JS_IsException(method)) { inner_fail: - JS_IteratorClose(ctx, it->inner, FALSE); + JS_IteratorClose(ctx, it->inner, false); JS_FreeValue(ctx, it->inner); it->inner = JS_UNDEFINED; goto fail; @@ -40859,8 +40858,8 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, } if (*pdone) { inner_end: - *pdone = FALSE; // The outer iterator must continue. - JS_IteratorClose(ctx, it->inner, FALSE); + *pdone = false; // The outer iterator must continue. + JS_IteratorClose(ctx, it->inner, false); JS_FreeValue(ctx, it->inner); it->inner = JS_UNDEFINED; goto flat_map_again; @@ -40917,8 +40916,8 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, goto done; } - *pdone = TRUE; - if (JS_IteratorClose(ctx, it->obj, FALSE)) + *pdone = true; + if (JS_IteratorClose(ctx, it->obj, false)) ret = JS_EXCEPTION; else ret = JS_UNDEFINED; @@ -40935,7 +40934,7 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, return ret; fail: /* close the iterator object, preserving pending exception */ - JS_IteratorClose(ctx, it->obj, TRUE); + JS_IteratorClose(ctx, it->obj, true); ret = JS_EXCEPTION; goto done; } @@ -41375,11 +41374,11 @@ static int js_string_get_own_property(JSContext *ctx, desc->getter = JS_UNDEFINED; desc->setter = JS_UNDEFINED; } - return TRUE; + return true; } } } - return FALSE; + return false; } static int js_string_define_own_property(JSContext *ctx, @@ -41414,7 +41413,7 @@ static int js_string_define_own_property(JSContext *ctx, return JS_ThrowTypeErrorOrFalse(ctx, flags, "property is not configurable"); } } - return TRUE; + return true; } else { def: return JS_DefineProperty(ctx, this_obj, prop, val, getter, setter, @@ -41430,10 +41429,10 @@ static int js_string_delete_property(JSContext *ctx, if (__JS_AtomIsTaggedInt(prop)) { idx = __JS_AtomToUInt32(prop); if (idx < js_string_obj_get_length(ctx, obj)) { - return FALSE; + return false; } } - return TRUE; + return true; } static const JSClassExoticMethods js_string_exotic_methods = { @@ -41793,7 +41792,7 @@ static int string_indexof(JSString *p1, JSString *p2, int from) return -1; } -static int64_t string_advance_index(JSString *p, int64_t index, BOOL unicode) +static int64_t string_advance_index(JSString *p, int64_t index, bool unicode) { if (!unicode || index >= p->len || !p->is_wide_char) { index++; @@ -41945,7 +41944,7 @@ static JSValue js_string_indexOf(JSContext *ctx, JSValue this_val, return JS_EXCEPTION; } -/* return < 0 if exception or TRUE/FALSE */ +/* return < 0 if exception or true/false */ static int js_is_regexp(JSContext *ctx, JSValue obj); static JSValue js_string_includes(JSContext *ctx, JSValue this_val, @@ -42210,7 +42209,7 @@ static JSValue js_string_replace(JSContext *ctx, JSValue this_val, JSString *sp, *searchp; StringBuffer b_s, *b = &b_s; int pos, functionalReplace, endOfLastMatch; - BOOL is_first; + bool is_first; if (JS_IsUndefined(O) || JS_IsNull(O)) return JS_ThrowTypeError(ctx, "cannot convert to object"); @@ -42252,7 +42251,7 @@ static JSValue js_string_replace(JSContext *ctx, JSValue this_val, sp = JS_VALUE_GET_STRING(str); searchp = JS_VALUE_GET_STRING(search_str); endOfLastMatch = 0; - is_first = TRUE; + is_first = true; for(;;) { if (unlikely(searchp->len == 0)) { if (is_first) @@ -42294,7 +42293,7 @@ static JSValue js_string_replace(JSContext *ctx, JSValue this_val, string_buffer_concat(b, sp, endOfLastMatch, pos); string_buffer_concat_value_free(b, repl_str); endOfLastMatch = pos + searchp->len; - is_first = FALSE; + is_first = false; if (!is_replaceAll) break; } @@ -42658,7 +42657,7 @@ static int string_prevc(JSString *p, int *pidx) return c; } -static BOOL test_final_sigma(JSString *p, int sigma_pos) +static bool test_final_sigma(JSString *p, int sigma_pos) { int k, c1; @@ -42671,14 +42670,14 @@ static BOOL test_final_sigma(JSString *p, int sigma_pos) break; } if (!lre_is_cased(c1)) - return FALSE; + return false; /* after C: skip case ignorable chars and check there is no cased letter */ k = sigma_pos + 1; for(;;) { if (k >= p->len) - return TRUE; + return true; c1 = string_getc(p, &k); if (!lre_is_case_ignorable(c1)) break; @@ -42858,9 +42857,9 @@ static JSValue js_string_normalize(JSContext *ctx, JSValue this_val, if (p[0] != 'N' || p[1] != 'F') goto bad_form; p += 2; - is_compat = FALSE; + is_compat = false; if (*p == 'K') { - is_compat = TRUE; + is_compat = true; p++; } if (*p == 'C' || *p == 'D') { @@ -42899,7 +42898,7 @@ static JSValue js_string_toString(JSContext *ctx, JSValue this_val, static JSValue js_string_iterator_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSArrayIteratorData *it; uint32_t idx, c, start; @@ -42907,7 +42906,7 @@ static JSValue js_string_iterator_next(JSContext *ctx, JSValue this_val, it = JS_GetOpaque2(ctx, this_val, JS_CLASS_STRING_ITERATOR); if (!it) { - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } if (JS_IsUndefined(it->obj)) @@ -42918,14 +42917,14 @@ static JSValue js_string_iterator_next(JSContext *ctx, JSValue this_val, JS_FreeValue(ctx, it->obj); it->obj = JS_UNDEFINED; done: - *pdone = TRUE; + *pdone = true; return JS_UNDEFINED; } start = idx; c = string_getc(p, (int *)&idx); it->idx = idx; - *pdone = FALSE; + *pdone = false; if (c <= 0xffff) { return js_new_string_char(ctx, c); } else { @@ -43105,7 +43104,7 @@ static double js_fmax(double a, double b) static JSValue js_math_min_max(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic) { - BOOL is_max = magic; + bool is_max = magic; double r, a; int i; uint32_t tag; @@ -43261,11 +43260,11 @@ static JSValue js_math_sumPrecise(JSContext *ctx, JSValue this_val, { JSValue iter, next, item, ret; bf_t a, b; - BOOL done; + int done; double d; int r; - iter = JS_GetIterator(ctx, argv[0], /*async*/FALSE); + iter = JS_GetIterator(ctx, argv[0], /*async*/false); if (JS_IsException(iter)) return JS_EXCEPTION; bf_init(ctx->bf_ctx, &a); @@ -43274,7 +43273,7 @@ static JSValue js_math_sumPrecise(JSContext *ctx, JSValue this_val, next = JS_GetProperty(ctx, iter, JS_ATOM_next); if (JS_IsException(next)) goto fail; - bf_set_zero(&a, /*is_neg*/TRUE); + bf_set_zero(&a, /*is_neg*/true); for (;;) { item = JS_IteratorNext(ctx, iter, next, 0, NULL, &done); if (JS_IsException(item)) @@ -43604,7 +43603,7 @@ static JSValue js_regexp_constructor_internal(JSContext *ctx, JSValue ctor, return obj; } -static JSRegExp *js_get_regexp(JSContext *ctx, JSValue obj, BOOL throw_error) +static JSRegExp *js_get_regexp(JSContext *ctx, JSValue obj, bool throw_error) { if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { JSObject *p = JS_VALUE_GET_OBJ(obj); @@ -43617,19 +43616,19 @@ static JSRegExp *js_get_regexp(JSContext *ctx, JSValue obj, BOOL throw_error) return NULL; } -/* return < 0 if exception or TRUE/FALSE */ +/* return < 0 if exception or true/false */ static int js_is_regexp(JSContext *ctx, JSValue obj) { JSValue m; if (!JS_IsObject(obj)) - return FALSE; + return false; m = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_match); if (JS_IsException(m)) return -1; if (!JS_IsUndefined(m)) return JS_ToBoolFree(ctx, m); - return js_get_regexp(ctx, obj, FALSE) != NULL; + return js_get_regexp(ctx, obj, false) != NULL; } static JSValue js_regexp_constructor(JSContext *ctx, JSValue new_target, @@ -43650,7 +43649,7 @@ static JSValue js_regexp_constructor(JSContext *ctx, JSValue new_target, new_target = JS_GetActiveFunction(ctx); if (pat_is_regexp && JS_IsUndefined(flags1)) { JSValue ctor; - BOOL res; + bool res; ctor = JS_GetProperty(ctx, pat, JS_ATOM_constructor); if (JS_IsException(ctor)) return ctor; @@ -43660,7 +43659,7 @@ static JSValue js_regexp_constructor(JSContext *ctx, JSValue new_target, return js_dup(pat); } } - re = js_get_regexp(ctx, pat, FALSE); + re = js_get_regexp(ctx, pat, false); if (re) { pattern = js_dup(JS_MKPTR(JS_TAG_STRING, re->pattern)); if (JS_IsUndefined(flags1)) { @@ -43717,12 +43716,12 @@ static JSValue js_regexp_compile(JSContext *ctx, JSValue this_val, JSValue pattern1, flags1; JSValue bc, pattern; - re = js_get_regexp(ctx, this_val, TRUE); + re = js_get_regexp(ctx, this_val, true); if (!re) return JS_EXCEPTION; pattern1 = argv[0]; flags1 = argv[1]; - re1 = js_get_regexp(ctx, pattern1, FALSE); + re1 = js_get_regexp(ctx, pattern1, false); if (re1) { if (!JS_IsUndefined(flags1)) return JS_ThrowTypeError(ctx, "flags must be undefined"); @@ -43767,7 +43766,7 @@ static JSValue js_regexp_get_source(JSContext *ctx, JSValue this_val) if (js_same_value(ctx, this_val, ctx->class_proto[JS_CLASS_REGEXP])) goto empty_regex; - re = js_get_regexp(ctx, this_val, TRUE); + re = js_get_regexp(ctx, this_val, true); if (!re) return JS_EXCEPTION; @@ -43828,7 +43827,7 @@ static JSValue js_regexp_get_flag(JSContext *ctx, JSValue this_val, int mask) if (JS_VALUE_GET_TAG(this_val) != JS_TAG_OBJECT) return JS_ThrowTypeErrorNotAnObject(ctx); - re = js_get_regexp(ctx, this_val, FALSE); + re = js_get_regexp(ctx, this_val, false); if (!re) { if (js_same_value(ctx, this_val, ctx->class_proto[JS_CLASS_REGEXP])) return JS_UNDEFINED; @@ -43921,7 +43920,7 @@ static JSValue js_regexp_toString(JSContext *ctx, JSValue this_val, return JS_EXCEPTION; } -BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size) +bool lre_check_stack_overflow(void *opaque, size_t alloca_size) { JSContext *ctx = opaque; return js_check_stack_overflow(ctx->rt, alloca_size); @@ -43984,7 +43983,7 @@ static JSValue js_regexp_escape(JSContext *ctx, JSValue this_val, static JSValue js_regexp_exec(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { - JSRegExp *re = js_get_regexp(ctx, this_val, TRUE); + JSRegExp *re = js_get_regexp(ctx, this_val, true); JSString *str; JSValue t, ret, str_val, obj, val, groups; JSValue indices, indices_groups; @@ -44183,7 +44182,7 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValue this_val, /* delete portions of a string that match a given regex */ static JSValue JS_RegExpDelete(JSContext *ctx, JSValue this_val, JSValue arg) { - JSRegExp *re = js_get_regexp(ctx, this_val, TRUE); + JSRegExp *re = js_get_regexp(ctx, this_val, true); JSString *str; JSValue str_val, val; uint8_t *re_bytecode; @@ -44301,7 +44300,7 @@ static JSValue js_regexp_test(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { JSValue val; - BOOL ret; + bool ret; val = JS_RegExpExec(ctx, this_val, argv[0]); if (JS_IsException(val)) @@ -44399,9 +44398,9 @@ static JSValue js_regexp_Symbol_match(JSContext *ctx, JSValue this_val, typedef struct JSRegExpStringIteratorData { JSValue iterating_regexp; JSValue iterated_string; - BOOL global; - BOOL unicode; - BOOL done; + bool global; + bool unicode; + int done; } JSRegExpStringIteratorData; static void js_regexp_string_iterator_finalizer(JSRuntime *rt, JSValue val) @@ -44429,7 +44428,7 @@ static void js_regexp_string_iterator_mark(JSRuntime *rt, JSValue val, static JSValue js_regexp_string_iterator_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSRegExpStringIteratorData *it; JSValue R, S; @@ -44440,7 +44439,7 @@ static JSValue js_regexp_string_iterator_next(JSContext *ctx, if (!it) goto exception; if (it->done) { - *pdone = TRUE; + *pdone = true; return JS_UNDEFINED; } R = it->iterating_regexp; @@ -44449,8 +44448,8 @@ static JSValue js_regexp_string_iterator_next(JSContext *ctx, if (JS_IsException(match)) goto exception; if (JS_IsNull(match)) { - it->done = TRUE; - *pdone = TRUE; + it->done = true; + *pdone = true; return JS_UNDEFINED; } else if (it->global) { matchStr = JS_ToStringFree(ctx, JS_GetPropertyInt64(ctx, match, 0)); @@ -44468,14 +44467,14 @@ static JSValue js_regexp_string_iterator_next(JSContext *ctx, } JS_FreeValue(ctx, matchStr); } else { - it->done = TRUE; + it->done = true; } - *pdone = FALSE; + *pdone = false; return match; exception: JS_FreeValue(ctx, match); JS_FreeValue(ctx, matchStr); - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } @@ -44529,7 +44528,7 @@ static JSValue js_regexp_Symbol_matchAll(JSContext *ctx, JSValue this_val, strp = JS_VALUE_GET_STRING(flags); it->global = string_indexof_char(strp, 'g', 0) >= 0; it->unicode = string_indexof_char(strp, 'u', 0) >= 0; - it->done = FALSE; + it->done = false; JS_SetOpaqueInternal(iter, it); JS_FreeValue(ctx, C); @@ -45402,7 +45401,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc, JSObject *p; int64_t i, len; int cl, ret; - BOOL has_content; + bool has_content; indent1 = JS_UNDEFINED; sep = JS_UNDEFINED; @@ -45494,7 +45493,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc, if (js_get_length64(ctx, &len, tab)) goto exception; string_buffer_putc8(jsc->b, '{'); - has_content = FALSE; + has_content = false; for(i = 0; i < len; i++) { JS_FreeValue(ctx, prop); prop = JS_GetPropertyInt64(ctx, tab, i); @@ -45520,7 +45519,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc, string_buffer_concat_value(jsc->b, sep1); if (js_json_to_str(ctx, jsc, val, v, indent1)) goto exception; - has_content = TRUE; + has_content = true; } } if (has_content && JS_VALUE_GET_STRING(jsc->gap)->len != 0) { @@ -45802,7 +45801,7 @@ static JSValue js_reflect_get(JSContext *ctx, JSValue this_val, atom = JS_ValueToAtom(ctx, prop); if (unlikely(atom == JS_ATOM_NULL)) return JS_EXCEPTION; - ret = JS_GetPropertyInternal(ctx, obj, atom, receiver, FALSE); + ret = JS_GetPropertyInternal(ctx, obj, atom, receiver, false); JS_FreeAtom(ctx, atom); return ret; } @@ -45861,7 +45860,7 @@ static JSValue js_reflect_setPrototypeOf(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { int ret; - ret = JS_SetPrototypeInternal(ctx, argv[0], argv[1], FALSE); + ret = JS_SetPrototypeInternal(ctx, argv[0], argv[1], false); if (ret < 0) return JS_EXCEPTION; else @@ -45994,12 +45993,12 @@ static JSValue js_proxy_getPrototypeOf(JSContext *ctx, JSValue obj) } static int js_proxy_setPrototypeOf(JSContext *ctx, JSValue obj, - JSValue proto_val, BOOL throw_flag) + JSValue proto_val, bool throw_flag) { JSProxyData *s; JSValue method, ret, proto1; JSValue args[2]; - BOOL res; + bool res; int res2; s = get_proxy_method(ctx, &method, obj, JS_ATOM_setPrototypeOf); @@ -46018,7 +46017,7 @@ static int js_proxy_setPrototypeOf(JSContext *ctx, JSValue obj, JS_ThrowTypeError(ctx, "proxy: bad prototype"); return -1; } else { - return FALSE; + return false; } } res2 = JS_IsExtensible(ctx, s->target); @@ -46035,14 +46034,14 @@ static int js_proxy_setPrototypeOf(JSContext *ctx, JSValue obj, } JS_FreeValue(ctx, proto1); } - return TRUE; + return true; } static int js_proxy_isExtensible(JSContext *ctx, JSValue obj) { JSProxyData *s; JSValue method, ret; - BOOL res; + bool res; int res2; s = get_proxy_method(ctx, &method, obj, JS_ATOM_isExtensible); @@ -46068,7 +46067,7 @@ static int js_proxy_preventExtensions(JSContext *ctx, JSValue obj) { JSProxyData *s; JSValue method, ret; - BOOL res; + bool res; int res2; s = get_proxy_method(ctx, &method, obj, JS_ATOM_preventExtensions); @@ -46096,10 +46095,10 @@ static int js_proxy_has(JSContext *ctx, JSValue obj, JSAtom atom) { JSProxyData *s; JSValue method, ret1, atom_val; - int ret, res; + int res; JSObject *p; JSValue args[2]; - BOOL res2; + bool ret, res2; s = get_proxy_method(ctx, &method, obj, JS_ATOM_has); if (!s) @@ -46150,7 +46149,7 @@ static JSValue js_proxy_get(JSContext *ctx, JSValue obj, JSAtom atom, return JS_EXCEPTION; /* Note: recursion is possible thru the prototype of s->target */ if (JS_IsUndefined(method)) - return JS_GetPropertyInternal(ctx, s->target, atom, receiver, FALSE); + return JS_GetPropertyInternal(ctx, s->target, atom, receiver, false); atom_val = JS_AtomToValue(ctx, atom); if (JS_IsException(atom_val)) { JS_FreeValue(ctx, method); @@ -46191,7 +46190,8 @@ static int js_proxy_set(JSContext *ctx, JSValue obj, JSAtom atom, { JSProxyData *s; JSValue method, ret1, atom_val; - int ret, res; + bool ret; + int res; JSValue args[4]; s = get_proxy_method(ctx, &method, obj, JS_ATOM_set); @@ -46326,7 +46326,7 @@ static int js_proxy_get_own_property(JSContext *ctx, JSPropertyDescriptor *pdesc if (!(target_desc.flags & JS_PROP_CONFIGURABLE) || !p->extensible) goto fail; } - ret = FALSE; + ret = false; } else { int flags1, extensible_target; extensible_target = JS_IsExtensible(ctx, s->target); @@ -46369,7 +46369,7 @@ static int js_proxy_get_own_property(JSContext *ctx, JSPropertyDescriptor *pdesc return -1; } } - ret = TRUE; + ret = true; if (pdesc) { *pdesc = result_desc; } else { @@ -46386,11 +46386,11 @@ static int js_proxy_define_own_property(JSContext *ctx, JSValue obj, { JSProxyData *s; JSValue method, ret1, prop_val, desc_val; - int res, ret; + int res; JSObject *p; JSValue args[3]; JSPropertyDescriptor desc; - BOOL setting_not_configurable; + bool ret, setting_not_configurable; s = get_proxy_method(ctx, &method, obj, JS_ATOM_defineProperty); if (!s) @@ -46484,7 +46484,8 @@ static int js_proxy_delete_property(JSContext *ctx, JSValue obj, { JSProxyData *s; JSValue method, ret, atom_val; - int res, res2, is_extensible; + int res2, is_extensible; + bool res; JSValue args[2]; s = get_proxy_method(ctx, &method, obj, JS_ATOM_deleteProperty); @@ -46590,7 +46591,7 @@ static int js_proxy_get_own_property_names(JSContext *ctx, if (atom == JS_ATOM_NULL) goto fail; tab[i].atom = atom; - tab[i].is_enumerable = FALSE; /* XXX: redundant? */ + tab[i].is_enumerable = false; /* XXX: redundant? */ } /* check duplicate properties (XXX: inefficient, could store the @@ -46633,7 +46634,7 @@ static int js_proxy_get_own_property_names(JSContext *ctx, } /* mark the property as found */ if (!is_extensible) - tab[idx].is_enumerable = TRUE; + tab[idx].is_enumerable = true; } } } @@ -46732,7 +46733,7 @@ static int js_proxy_isArray(JSContext *ctx, JSValue obj) { JSProxyData *s = JS_GetOpaque(obj, JS_CLASS_PROXY); if (!s) - return FALSE; + return false; if (js_check_stack_overflow(ctx->rt, 0)) { JS_ThrowStackOverflow(ctx); @@ -46780,7 +46781,7 @@ static JSValue js_proxy_constructor(JSContext *ctx, JSValue this_val, s->target = js_dup(target); s->handler = js_dup(handler); s->is_func = JS_IsFunction(ctx, target); - s->is_revoked = FALSE; + s->is_revoked = false; JS_SetOpaqueInternal(obj, s); JS_SetConstructorBit(ctx, obj, JS_IsConstructor(ctx, target)); return obj; @@ -46794,7 +46795,7 @@ static JSValue js_proxy_revoke(JSContext *ctx, JSValue this_val, if (s) { /* We do not free the handler and target in case they are referenced as constants in the C call stack */ - s->is_revoked = TRUE; + s->is_revoked = true; JS_FreeValue(ctx, func_data[0]); func_data[0] = JS_NULL; } @@ -46853,7 +46854,7 @@ void JS_AddIntrinsicProxy(JSContext *ctx) obj1 = JS_NewCFunction2(ctx, js_proxy_constructor, "Proxy", 2, JS_CFUNC_constructor, 0); - JS_SetConstructorBit(ctx, obj1, TRUE); + JS_SetConstructorBit(ctx, obj1, true); JS_SetPropertyFunctionList(ctx, obj1, js_proxy_funcs, countof(js_proxy_funcs)); JS_DefinePropertyValueStr(ctx, ctx->global_obj, "Proxy", @@ -46975,7 +46976,7 @@ static const JSCFunctionListEntry js_symbol_funcs[] = { typedef struct JSMapRecord { int ref_count; /* used during enumeration to avoid freeing the record */ - BOOL empty; /* TRUE if the record is deleted */ + bool empty; /* true if the record is deleted */ struct JSMapState *map; struct list_head link; struct list_head hash_link; @@ -46984,7 +46985,7 @@ typedef struct JSMapRecord { } JSMapRecord; typedef struct JSMapState { - BOOL is_weak; /* TRUE if WeakSet/WeakMap */ + bool is_weak; /* true if WeakSet/WeakMap */ struct list_head records; /* list of JSMapRecord.link */ uint32_t record_count; struct list_head *hash_table; @@ -47002,7 +47003,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValue new_target, JSMapState *s; JSValue obj, adder = JS_UNDEFINED, iter = JS_UNDEFINED, next_method = JS_UNDEFINED; JSValue arr; - BOOL is_set, is_weak; + bool is_set, is_weak; is_set = magic & MAGIC_SET; is_weak = ((magic & MAGIC_WEAK) != 0); @@ -47027,7 +47028,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValue new_target, arr = argv[0]; if (!JS_IsUndefined(arr) && !JS_IsNull(arr)) { JSValue item, ret; - BOOL done; + int done; adder = JS_GetProperty(ctx, obj, is_set ? JS_ATOM_add : JS_ATOM_set); if (JS_IsException(adder)) @@ -47037,7 +47038,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValue new_target, goto fail; } - iter = JS_GetIterator(ctx, arr, FALSE); + iter = JS_GetIterator(ctx, arr, false); if (JS_IsException(iter)) goto fail; next_method = JS_GetProperty(ctx, iter, JS_ATOM_next); @@ -47097,7 +47098,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValue new_target, fail: if (JS_IsObject(iter)) { /* close the iterator object, preserving pending exception */ - JS_IteratorClose(ctx, iter, TRUE); + JS_IteratorClose(ctx, iter, true); } JS_FreeValue(ctx, next_method); JS_FreeValue(ctx, iter); @@ -47241,7 +47242,7 @@ static JSMapRecord *map_add_record(JSContext *ctx, JSMapState *s, return NULL; mr->ref_count = 1; mr->map = s; - mr->empty = FALSE; + mr->empty = false; if (s->is_weak) { JSWeakRefRecord *wr = js_malloc(ctx, sizeof(*wr)); if (!wr) { @@ -47301,7 +47302,7 @@ static void map_delete_record(JSRuntime *rt, JSMapState *s, JSMapRecord *mr) js_free_rt(rt, mr); } else { /* keep a zombie record for iterators */ - mr->empty = TRUE; + mr->empty = true; mr->key = JS_UNDEFINED; mr->value = JS_UNDEFINED; } @@ -47474,14 +47475,14 @@ static JSValue js_map_groupBy(JSContext *ctx, JSValue this_val, JSValue cb, res, iter, next, groups, k, v, prop; JSValue args[2]; int64_t idx; - BOOL done; + int done; // "is function?" check must be observed before argv[0] is accessed cb = argv[1]; if (check_function(ctx, cb)) return JS_EXCEPTION; - iter = JS_GetIterator(ctx, argv[0], /*is_async*/FALSE); + iter = JS_GetIterator(ctx, argv[0], /*is_async*/false); if (JS_IsException(iter)) return JS_EXCEPTION; @@ -47670,7 +47671,7 @@ static JSValue js_create_map_iterator(JSContext *ctx, JSValue this_val, static JSValue js_map_iterator_next(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, - BOOL *pdone, int magic) + int *pdone, int magic) { JSMapIteratorData *it; JSMapState *s; @@ -47679,7 +47680,7 @@ static JSValue js_map_iterator_next(JSContext *ctx, JSValue this_val, it = JS_GetOpaque2(ctx, this_val, JS_CLASS_MAP_ITERATOR + magic); if (!it) { - *pdone = FALSE; + *pdone = false; return JS_EXCEPTION; } if (JS_IsUndefined(it->obj)) @@ -47701,7 +47702,7 @@ static JSValue js_map_iterator_next(JSContext *ctx, JSValue this_val, it->obj = JS_UNDEFINED; done: /* end of enumeration */ - *pdone = TRUE; + *pdone = true; return JS_UNDEFINED; } mr = list_entry(el, JSMapRecord, link); @@ -47714,7 +47715,7 @@ static JSValue js_map_iterator_next(JSContext *ctx, JSValue this_val, /* lock the record so that it won't be freed */ mr->ref_count++; it->cur_record = mr; - *pdone = FALSE; + *pdone = false; if (it->kind == JS_ITERATOR_KIND_KEY) { return js_dup(mr->key); @@ -47888,7 +47889,8 @@ static JSValue js_set_isDisjointFrom(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { JSValue item, iter, keys, has, next, rv, rval; - BOOL done, found; + int done; + bool found; JSMapState *s; int64_t size; int ok; @@ -47915,7 +47917,7 @@ static JSValue js_set_isDisjointFrom(JSContext *ctx, JSValue this_val, next = JS_GetProperty(ctx, iter, JS_ATOM_next); if (JS_IsException(next)) goto exception; - found = FALSE; + found = false; do { item = JS_IteratorNext(ctx, iter, next, 0, NULL, &done); if (JS_IsException(item)) @@ -47930,7 +47932,7 @@ static JSValue js_set_isDisjointFrom(JSContext *ctx, JSValue this_val, iter = js_create_map_iterator(ctx, this_val, 0, NULL, MAGIC_SET); if (JS_IsException(iter)) goto exception; - found = FALSE; + found = false; do { item = js_map_iterator_next(ctx, iter, 0, NULL, &done, MAGIC_SET); if (JS_IsException(item)) @@ -47958,10 +47960,10 @@ static JSValue js_set_isSubsetOf(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { JSValue item, iter, keys, has, next, rv, rval; - BOOL done, found; + bool found; JSMapState *s; int64_t size; - int ok; + int done, ok; has = JS_UNDEFINED; iter = JS_UNDEFINED; @@ -47978,13 +47980,13 @@ static JSValue js_set_isSubsetOf(JSContext *ctx, JSValue this_val, goto exception; if (js_setlike_get_keys(ctx, argv[0], &keys) < 0) goto exception; - found = FALSE; + found = false; if (s->record_count > size) goto fini; iter = js_create_map_iterator(ctx, this_val, 0, NULL, MAGIC_SET); if (JS_IsException(iter)) goto exception; - found = TRUE; + found = true; do { item = js_map_iterator_next(ctx, iter, 0, NULL, &done, MAGIC_SET); if (JS_IsException(item)) @@ -48012,7 +48014,8 @@ static JSValue js_set_isSupersetOf(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { JSValue item, iter, keys, has, next, rval; - BOOL done, found; + int done; + bool found; JSMapState *s; int64_t size; @@ -48031,7 +48034,7 @@ static JSValue js_set_isSupersetOf(JSContext *ctx, JSValue this_val, goto exception; if (js_setlike_get_keys(ctx, argv[0], &keys) < 0) goto exception; - found = FALSE; + found = false; if (s->record_count < size) goto fini; iter = JS_Call(ctx, keys, argv[0], 0, NULL); @@ -48040,7 +48043,7 @@ static JSValue js_set_isSupersetOf(JSContext *ctx, JSValue this_val, next = JS_GetProperty(ctx, iter, JS_ATOM_next); if (JS_IsException(next)) goto exception; - found = TRUE; + found = true; do { item = JS_IteratorNext(ctx, iter, next, 0, NULL, &done); if (JS_IsException(item)) @@ -48068,8 +48071,7 @@ static JSValue js_set_intersection(JSContext *ctx, JSValue this_val, JSMapState *s, *t; JSMapRecord *mr; int64_t size; - BOOL done; - int ok; + int done, ok; has = JS_UNDEFINED; iter = JS_UNDEFINED; @@ -48167,7 +48169,7 @@ static JSValue js_set_difference(JSContext *ctx, JSValue this_val, JSMapState *s, *t; JSMapRecord *mr; int64_t size; - BOOL done; + int done; int ok; has = JS_UNDEFINED; @@ -48261,7 +48263,8 @@ static JSValue js_set_symmetricDifference(JSContext *ctx, JSValue this_val, JSMapState *s, *t; JSMapRecord *mr; int64_t size; - BOOL done, present; + int done; + bool present; s = JS_GetOpaque2(ctx, this_val, JS_CLASS_SET); if (!s) @@ -48348,7 +48351,7 @@ static JSValue js_set_union(JSContext *ctx, JSValue this_val, JSMapState *s, *t; JSMapRecord *mr; int64_t size; - BOOL done; + int done; s = JS_GetOpaque2(ctx, this_val, JS_CLASS_SET); if (!s) @@ -48544,13 +48547,13 @@ typedef struct JSPromiseData { JSPromiseStateEnum promise_state; /* 0=fulfill, 1=reject, list of JSPromiseReactionData.link */ struct list_head promise_reactions[2]; - BOOL is_handled; /* Note: only useful to debug */ + bool is_handled; /* Note: only useful to debug */ JSValue promise_result; } JSPromiseData; typedef struct JSPromiseFunctionDataResolved { int ref_count; - BOOL already_resolved; + bool already_resolved; } JSPromiseFunctionDataResolved; typedef struct JSPromiseFunctionData { @@ -48580,10 +48583,10 @@ JSValue JS_PromiseResult(JSContext *ctx, JSValue promise) return JS_DupValue(ctx, s->promise_result); } -JS_BOOL JS_IsPromise(JSValue val) +bool JS_IsPromise(JSValue val) { if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) - return FALSE; + return false; return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_PROMISE; } @@ -48614,7 +48617,7 @@ static JSValue promise_reaction_job(JSContext *ctx, int argc, { JSValue handler, arg, func; JSValue res, res2; - BOOL is_reject; + bool is_reject; assert(argc == 5); handler = argv[2]; @@ -48659,7 +48662,7 @@ void JS_SetHostPromiseRejectionTracker(JSRuntime *rt, } static void fulfill_or_reject_promise(JSContext *ctx, JSValue promise, - JSValue value, BOOL is_reject) + JSValue value, bool is_reject) { JSPromiseData *s = JS_GetOpaque(promise, JS_CLASS_PROMISE); struct list_head *el, *el1; @@ -48676,7 +48679,7 @@ static void fulfill_or_reject_promise(JSContext *ctx, JSValue promise, if (s->promise_state == JS_PROMISE_REJECTED && !s->is_handled) { JSRuntime *rt = ctx->rt; if (rt->host_promise_rejection_tracker) { - rt->host_promise_rejection_tracker(ctx, promise, value, FALSE, + rt->host_promise_rejection_tracker(ctx, promise, value, false, rt->host_promise_rejection_tracker_opaque); } } @@ -48703,7 +48706,7 @@ static void fulfill_or_reject_promise(JSContext *ctx, JSValue promise, static void reject_promise(JSContext *ctx, JSValue promise, JSValue value) { - fulfill_or_reject_promise(ctx, promise, value, TRUE); + fulfill_or_reject_promise(ctx, promise, value, true); } static JSValue js_promise_resolve_thenable_job(JSContext *ctx, @@ -48753,7 +48756,7 @@ static int js_create_resolving_functions(JSContext *ctx, if (!sr) return -1; sr->ref_count = 1; - sr->already_resolved = FALSE; /* must be shared between the two functions */ + sr->already_resolved = false; /* must be shared between the two functions */ ret = 0; for(i = 0; i < 2; i++) { obj = JS_NewObjectProtoClass(ctx, ctx->function_proto, @@ -48810,12 +48813,12 @@ static JSValue js_promise_resolve_function_call(JSContext *ctx, JSPromiseFunctionData *s; JSValue resolution, args[3]; JSValue then; - BOOL is_reject; + bool is_reject; s = p->u.promise_function_data; if (!s || s->presolved->already_resolved) return JS_UNDEFINED; - s->presolved->already_resolved = TRUE; + s->presolved->already_resolved = true; is_reject = p->class_id - JS_CLASS_PROMISE_RESOLVE_FUNCTION; if (argc > 0) resolution = argv[0]; @@ -48914,7 +48917,7 @@ static JSValue js_promise_constructor(JSContext *ctx, JSValue new_target, if (!s) goto fail; s->promise_state = JS_PROMISE_PENDING; - s->is_handled = FALSE; + s->is_handled = false; for(i = 0; i < 2; i++) init_list_head(&s->promise_reactions[i]); s->promise_result = JS_UNDEFINED; @@ -49013,13 +49016,13 @@ static JSValue js_promise_resolve(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic) { JSValue result_promise, resolving_funcs[2], ret; - BOOL is_reject = magic; + bool is_reject = magic; if (!JS_IsObject(this_val)) return JS_ThrowTypeErrorNotAnObject(ctx); if (!is_reject && JS_GetOpaque(argv[0], JS_CLASS_PROMISE)) { JSValue ctor; - BOOL is_same; + bool is_same; ctor = JS_GetProperty(ctx, argv[0], JS_ATOM_constructor); if (JS_IsException(ctor)) return ctor; @@ -49068,7 +49071,7 @@ static JSValue js_promise_try(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) { JSValue result_promise, resolving_funcs[2], ret, ret2; - BOOL is_reject = 0; + bool is_reject = 0; if (!JS_IsObject(this_val)) return JS_ThrowTypeErrorNotAnObject(ctx); @@ -49123,7 +49126,7 @@ static JSValue js_promise_all_resolve_element(JSContext *ctx, { int resolve_type = magic & 3; int is_reject = magic & 4; - BOOL alreadyCalled = JS_ToBool(ctx, func_data[0]); + bool alreadyCalled = JS_ToBool(ctx, func_data[0]); JSValue values = func_data[2]; JSValue resolve = func_data[3]; JSValue resolve_element_env = func_data[4]; @@ -49134,7 +49137,7 @@ static JSValue js_promise_all_resolve_element(JSContext *ctx, return JS_EXCEPTION; if (alreadyCalled) return JS_UNDEFINED; - func_data[0] = js_bool(TRUE); + func_data[0] = JS_TRUE; if (resolve_type == PROMISE_MAGIC_allSettled) { JSValue str; @@ -49194,8 +49197,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val, JSValue resolve_element_env = JS_UNDEFINED, resolve_element, reject_element; JSValue promise_resolve = JS_UNDEFINED, iter = JS_UNDEFINED; JSValue then_args[2], resolve_element_data[5]; - BOOL done; - int index, is_zero, is_promise_any = (magic == PROMISE_MAGIC_any); + int done, index, is_zero, is_promise_any = (magic == PROMISE_MAGIC_any); if (!JS_IsObject(this_val)) return JS_ThrowTypeErrorNotAnObject(ctx); @@ -49206,7 +49208,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val, if (JS_IsException(promise_resolve) || check_function(ctx, promise_resolve)) goto fail_reject; - iter = JS_GetIterator(ctx, argv[0], FALSE); + iter = JS_GetIterator(ctx, argv[0], false); if (JS_IsException(iter)) { JSValue error; fail_reject: @@ -49247,10 +49249,10 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val, JS_FreeValue(ctx, item); if (JS_IsException(next_promise)) { fail_reject1: - JS_IteratorClose(ctx, iter, TRUE); + JS_IteratorClose(ctx, iter, true); goto fail_reject; } - resolve_element_data[0] = js_bool(FALSE); + resolve_element_data[0] = JS_FALSE; resolve_element_data[1] = js_int32(index); resolve_element_data[2] = values; resolve_element_data[3] = resolving_funcs[is_promise_any]; @@ -49337,7 +49339,7 @@ static JSValue js_promise_race(JSContext *ctx, JSValue this_val, JSValue result_promise, resolving_funcs[2], item, next_promise, ret; JSValue next_method = JS_UNDEFINED, iter = JS_UNDEFINED; JSValue promise_resolve = JS_UNDEFINED; - BOOL done; + int done; if (!JS_IsObject(this_val)) return JS_ThrowTypeErrorNotAnObject(ctx); @@ -49348,7 +49350,7 @@ static JSValue js_promise_race(JSContext *ctx, JSValue this_val, if (JS_IsException(promise_resolve) || check_function(ctx, promise_resolve)) goto fail_reject; - iter = JS_GetIterator(ctx, argv[0], FALSE); + iter = JS_GetIterator(ctx, argv[0], false); if (JS_IsException(iter)) { JSValue error; fail_reject: @@ -49377,7 +49379,7 @@ static JSValue js_promise_race(JSContext *ctx, JSValue this_val, JS_FreeValue(ctx, item); if (JS_IsException(next_promise)) { fail_reject1: - JS_IteratorClose(ctx, iter, TRUE); + JS_IteratorClose(ctx, iter, true); goto fail_reject; } ret = JS_InvokeFree(ctx, next_promise, JS_ATOM_then, 2, @@ -49437,7 +49439,7 @@ static __exception int perform_promise_then(JSContext *ctx, JSRuntime *rt = ctx->rt; if (rt->host_promise_rejection_tracker) { rt->host_promise_rejection_tracker(ctx, promise, s->promise_result, - TRUE, rt->host_promise_rejection_tracker_opaque); + true, rt->host_promise_rejection_tracker_opaque); } } i = s->promise_state - JS_PROMISE_FULFILLED; @@ -49451,7 +49453,7 @@ static __exception int perform_promise_then(JSContext *ctx, for(i = 0; i < 2; i++) promise_reaction_data_free(ctx->rt, rd_array[i]); } - s->is_handled = TRUE; + s->is_handled = true; return 0; } @@ -49607,7 +49609,7 @@ static JSValue js_async_from_sync_iterator_unwrap(JSContext *ctx, } static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext *ctx, - BOOL done) + bool done) { JSValue func_data[1]; @@ -49705,11 +49707,11 @@ static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValue this_val goto reject; if (JS_IsUndefined(method) || JS_IsNull(method)) { if (magic == GEN_MAGIC_RETURN) { - err = js_create_iterator_result(ctx, js_dup(argv[0]), TRUE); + err = js_create_iterator_result(ctx, js_dup(argv[0]), true); is_reject = 0; } else { err = JS_MakeError(ctx, JS_TYPE_ERROR, "throw is not a method", - TRUE); + true); is_reject = 1; } goto done_resolve; @@ -50290,7 +50292,7 @@ static __exception int get_date_fields(JSContext *ctx, JSValue obj, if (isnan(dval)) { if (!force) - return FALSE; /* NaN */ + return false; /* NaN */ d = 0; /* initialize all fields to 0 */ } else { d = dval; /* assuming -8.64e15 <= dval <= -8.64e15 */ @@ -50329,7 +50331,7 @@ static __exception int get_date_fields(JSContext *ctx, JSValue obj, fields[6] = ms; fields[7] = wd; fields[8] = tz; - return TRUE; + return true; } static double time_clip(double t) { @@ -50442,7 +50444,7 @@ static JSValue set_date_field(JSContext *ctx, JSValue this_val, if (JS_ToFloat64(ctx, &a, argv[i])) return JS_EXCEPTION; if (!isfinite(a)) - res = FALSE; + res = false; fields[first_field + i] = trunc(a); } @@ -50673,12 +50675,12 @@ static JSValue js_Date_UTC(JSContext *ctx, JSValue this_val, /* Date string parsing */ -static BOOL string_skip_char(const uint8_t *sp, int *pp, int c) { +static bool string_skip_char(const uint8_t *sp, int *pp, int c) { if (sp[*pp] == c) { *pp += 1; - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -50707,7 +50709,7 @@ static int string_skip_until(const uint8_t *sp, int *pp, const char *stoplist) { } /* parse a numeric field (max_digits = 0 -> no maximum) */ -static BOOL string_get_digits(const uint8_t *sp, int *pp, int *pval, +static bool string_get_digits(const uint8_t *sp, int *pp, int *pval, int min_digits, int max_digits) { int v = 0; @@ -50721,13 +50723,13 @@ static BOOL string_get_digits(const uint8_t *sp, int *pp, int *pval, break; } if (p - p_start < min_digits) - return FALSE; + return false; *pval = v; *pp = p; - return TRUE; + return true; } -static BOOL string_get_milliseconds(const uint8_t *sp, int *pp, int *pval) { +static bool string_get_milliseconds(const uint8_t *sp, int *pp, int *pval) { /* parse optional fractional part as milliseconds and truncate. */ /* spec does not indicate which rounding should be used */ int mul = 100, ms = 0, c, p_start, p = *pp; @@ -50749,20 +50751,20 @@ static BOOL string_get_milliseconds(const uint8_t *sp, int *pp, int *pval) { *pp = p; } } - return TRUE; + return true; } -static BOOL string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, BOOL strict) { +static bool string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, bool strict) { int tz = 0, sgn, hh, mm, p = *pp; sgn = sp[p++]; if (sgn == '+' || sgn == '-') { int n = p; if (!string_get_digits(sp, &p, &hh, 1, 9)) - return FALSE; + return false; n = p - n; if (strict && n != 2 && n != 4) - return FALSE; + return false; while (n > 4) { n -= 2; hh /= 100; @@ -50774,31 +50776,31 @@ static BOOL string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, BOOL stric mm = 0; if (string_skip_char(sp, &p, ':') /* optional separator */ && !string_get_digits(sp, &p, &mm, 2, 2)) - return FALSE; + return false; } if (hh > 23 || mm > 59) - return FALSE; + return false; tz = hh * 60 + mm; if (sgn != '+') tz = -tz; } else if (sgn != 'Z') { - return FALSE; + return false; } *pp = p; *tzp = tz; - return TRUE; + return true; } -static BOOL string_match(const uint8_t *sp, int *pp, const char *s) { +static bool string_match(const uint8_t *sp, int *pp, const char *s) { int p = *pp; while (*s != '\0') { if (to_upper_ascii(sp[p]) != to_upper_ascii(*s++)) - return FALSE; + return false; p++; } *pp = p; - return TRUE; + return true; } static int find_abbrev(const uint8_t *sp, int p, const char *list, int count) { @@ -50815,75 +50817,75 @@ static int find_abbrev(const uint8_t *sp, int p, const char *list, int count) { return -1; } -static BOOL string_get_month(const uint8_t *sp, int *pp, int *pval) { +static bool string_get_month(const uint8_t *sp, int *pp, int *pval) { int n; n = find_abbrev(sp, *pp, month_names, 12); if (n < 0) - return FALSE; + return false; *pval = n + 1; *pp += 3; - return TRUE; + return true; } /* parse toISOString format */ -static BOOL js_date_parse_isostring(const uint8_t *sp, int fields[9], BOOL *is_local) { +static bool js_date_parse_isostring(const uint8_t *sp, int fields[9], bool *is_local) { int sgn, i, p = 0; /* initialize fields to the beginning of the Epoch */ for (i = 0; i < 9; i++) { fields[i] = (i == 2); } - *is_local = FALSE; + *is_local = false; /* year is either yyyy digits or [+-]yyyyyy */ sgn = sp[p]; if (sgn == '-' || sgn == '+') { p++; if (!string_get_digits(sp, &p, &fields[0], 6, 6)) - return FALSE; + return false; if (sgn == '-') { if (fields[0] == 0) - return FALSE; // reject -000000 + return false; // reject -000000 fields[0] = -fields[0]; } } else { if (!string_get_digits(sp, &p, &fields[0], 4, 4)) - return FALSE; + return false; } if (string_skip_char(sp, &p, '-')) { if (!string_get_digits(sp, &p, &fields[1], 2, 2)) /* month */ - return FALSE; + return false; if (fields[1] < 1) - return FALSE; + return false; fields[1] -= 1; if (string_skip_char(sp, &p, '-')) { if (!string_get_digits(sp, &p, &fields[2], 2, 2)) /* day */ - return FALSE; + return false; if (fields[2] < 1) - return FALSE; + return false; } } if (string_skip_char(sp, &p, 'T')) { - *is_local = TRUE; + *is_local = true; if (!string_get_digits(sp, &p, &fields[3], 2, 2) /* hour */ || !string_skip_char(sp, &p, ':') || !string_get_digits(sp, &p, &fields[4], 2, 2)) { /* minute */ fields[3] = 100; // reject unconditionally - return TRUE; + return true; } if (string_skip_char(sp, &p, ':')) { if (!string_get_digits(sp, &p, &fields[5], 2, 2)) /* second */ - return FALSE; + return false; string_get_milliseconds(sp, &p, &fields[6]); } } /* parse the time zone offset if present: [+-]HH:mm or [+-]HHmm */ if (sp[p]) { - *is_local = FALSE; - if (!string_get_tzoffset(sp, &p, &fields[8], TRUE)) - return FALSE; + *is_local = false; + if (!string_get_tzoffset(sp, &p, &fields[8], true)) + return false; } /* error if extraneous characters */ return sp[p] == '\0'; @@ -50913,27 +50915,27 @@ static struct { { "EEST", +3 * 60 }, // Eastern European Summer Time }; -static BOOL string_get_tzabbr(const uint8_t *sp, int *pp, int *offset) { +static bool string_get_tzabbr(const uint8_t *sp, int *pp, int *offset) { size_t i; for (i = 0; i < countof(js_tzabbr); i++) { if (string_match(sp, pp, js_tzabbr[i].name)) { *offset = js_tzabbr[i].offset; - return TRUE; + return true; } } - return FALSE; + return false; } /* parse toString, toUTCString and other formats */ -static BOOL js_date_parse_otherstring(const uint8_t *sp, +static bool js_date_parse_otherstring(const uint8_t *sp, int fields[minimum_length(9)], - BOOL *is_local) { + bool *is_local) { int c, i, val, p = 0, p_start; int num[3]; - BOOL has_year = FALSE; - BOOL has_mon = FALSE; - BOOL has_time = FALSE; + bool has_year = false; + bool has_mon = false; + bool has_time = false; int num_index = 0; /* initialize fields to the beginning of 2001-01-01 */ @@ -50943,23 +50945,23 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp, for (i = 3; i < 9; i++) { fields[i] = 0; } - *is_local = TRUE; + *is_local = true; while (string_skip_spaces(sp, &p)) { p_start = p; if ((c = sp[p]) == '+' || c == '-') { - if (has_time && string_get_tzoffset(sp, &p, &fields[8], FALSE)) { - *is_local = FALSE; + if (has_time && string_get_tzoffset(sp, &p, &fields[8], false)) { + *is_local = false; } else { p++; if (string_get_digits(sp, &p, &val, 1, 9)) { if (c == '-') { if (val == 0) - return FALSE; + return false; val = -val; } fields[0] = val; - has_year = TRUE; + has_year = true; } } } else @@ -50968,32 +50970,32 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp, /* time part */ fields[3] = val; if (!string_get_digits(sp, &p, &fields[4], 1, 2)) - return FALSE; + return false; if (string_skip_char(sp, &p, ':')) { if (!string_get_digits(sp, &p, &fields[5], 1, 2)) - return FALSE; + return false; string_get_milliseconds(sp, &p, &fields[6]); } else if (sp[p] != '\0' && sp[p] != ' ') - return FALSE; - has_time = TRUE; + return false; + has_time = true; } else { if (p - p_start > 2) { fields[0] = val; - has_year = TRUE; + has_year = true; } else if (val < 1 || val > 31) { fields[0] = val + (val < 100) * 1900 + (val < 50) * 100; - has_year = TRUE; + has_year = true; } else { if (num_index == 3) - return FALSE; + return false; num[num_index++] = val; } } } else if (string_get_month(sp, &p, &fields[1])) { - has_mon = TRUE; + has_mon = true; string_skip_until(sp, &p, "0123456789 -/("); } else if (has_time && string_match(sp, &p, "PM")) { @@ -51007,13 +51009,13 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp, if (has_time && string_match(sp, &p, "AM")) { /* 00:00 AM will be silently accepted */ if (fields[3] > 12) - return FALSE; + return false; if (fields[3] == 12) fields[3] -= 12; continue; } else if (string_get_tzabbr(sp, &p, &fields[8])) { - *is_local = FALSE; + *is_local = false; continue; } else if (c == '(') { /* skip parenthesized phrase */ @@ -51026,25 +51028,25 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp, break; } if (level > 0) - return FALSE; + return false; } else if (c == ')') { - return FALSE; + return false; } else { if (has_year + has_mon + has_time + num_index) - return FALSE; + return false; /* skip a word */ string_skip_until(sp, &p, " -/("); } string_skip_separators(sp, &p); } if (num_index + has_year + has_mon > 3) - return FALSE; + return false; switch (num_index) { case 0: if (!has_year) - return FALSE; + return false; break; case 1: if (has_mon) @@ -51071,12 +51073,12 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp, fields[2] = num[1]; break; default: - return FALSE; + return false; } if (fields[1] < 1 || fields[2] < 1) - return FALSE; + return false; fields[1] -= 1; - return TRUE; + return true; } static JSValue js_Date_parse(JSContext *ctx, JSValue this_val, @@ -51089,7 +51091,7 @@ static JSValue js_Date_parse(JSContext *ctx, JSValue this_val, int i, c; JSString *sp; uint8_t buf[128]; - BOOL is_local; + bool is_local; rv = JS_NAN; @@ -51109,15 +51111,15 @@ static JSValue js_Date_parse(JSContext *ctx, JSValue this_val, if (js_date_parse_isostring(buf, fields, &is_local) || js_date_parse_otherstring(buf, fields, &is_local)) { static int const field_max[6] = { 0, 11, 31, 24, 59, 59 }; - BOOL valid = TRUE; + bool valid = true; /* check field maximum values */ for (i = 1; i < 6; i++) { if (fields[i] > field_max[i]) - valid = FALSE; + valid = false; } /* special case 24:00:00.000 */ if (fields[3] == 24 && (fields[4] | fields[5] | fields[6])) - valid = FALSE; + valid = false; if (valid) { for(i = 0; i < 7; i++) fields1[i] = fields[i]; @@ -51329,10 +51331,10 @@ JSValue JS_NewDate(JSContext *ctx, double epoch_ms) return obj; } -JS_BOOL JS_IsDate(JSValue v) +bool JS_IsDate(JSValue v) { if (JS_VALUE_GET_TAG(v) != JS_TAG_OBJECT) - return FALSE; + return false; return JS_VALUE_GET_OBJ(v)->class_id == JS_CLASS_DATE; } @@ -51747,7 +51749,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx) /* Boolean */ ctx->class_proto[JS_CLASS_BOOLEAN] = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], JS_CLASS_BOOLEAN); - JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_BOOLEAN], js_bool(FALSE)); + JS_SetObjectData(ctx, ctx->class_proto[JS_CLASS_BOOLEAN], JS_FALSE); JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_BOOLEAN], js_boolean_proto_funcs, countof(js_boolean_proto_funcs)); JS_NewGlobalCConstructor(ctx, "Boolean", js_boolean_constructor, 1, @@ -51841,7 +51843,7 @@ static JSValue js_array_buffer_constructor3(JSContext *ctx, JSClassID class_id, uint8_t *buf, JSFreeArrayBufferDataFunc *free_func, - void *opaque, BOOL alloc_flag) + void *opaque, bool alloc_flag) { JSRuntime *rt = ctx->rt; JSValue obj; @@ -51897,7 +51899,7 @@ static JSValue js_array_buffer_constructor3(JSContext *ctx, abuf->data = buf; } init_list_head(&abuf->array_list); - abuf->detached = FALSE; + abuf->detached = false; abuf->shared = (class_id == JS_CLASS_SHARED_ARRAY_BUFFER); abuf->opaque = opaque; abuf->free_func = free_func; @@ -51923,7 +51925,7 @@ static JSValue js_array_buffer_constructor2(JSContext *ctx, { return js_array_buffer_constructor3(ctx, new_target, len, max_len, class_id, NULL, js_array_buffer_free, - NULL, TRUE); + NULL, true); } static JSValue js_array_buffer_constructor1(JSContext *ctx, @@ -51936,15 +51938,15 @@ static JSValue js_array_buffer_constructor1(JSContext *ctx, JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len, JSFreeArrayBufferDataFunc *free_func, void *opaque, - BOOL is_shared) + bool is_shared) { JSClassID class_id = is_shared ? JS_CLASS_SHARED_ARRAY_BUFFER : JS_CLASS_ARRAY_BUFFER; return js_array_buffer_constructor3(ctx, JS_UNDEFINED, len, NULL, class_id, - buf, free_func, opaque, FALSE); + buf, free_func, opaque, false); } -JS_BOOL JS_IsArrayBuffer(JSValue obj) { +bool JS_IsArrayBuffer(JSValue obj) { return JS_GetClassID(obj) == JS_CLASS_ARRAY_BUFFER; } @@ -51955,7 +51957,7 @@ JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len) JS_CLASS_ARRAY_BUFFER, (uint8_t *)buf, js_array_buffer_free, NULL, - TRUE); + true); } static JSValue js_array_buffer_constructor0(JSContext *ctx, JSValue new_target, @@ -52048,13 +52050,13 @@ static JSValue js_array_buffer_isView(JSContext *ctx, int argc, JSValue *argv) { JSObject *p; - BOOL res; - res = FALSE; + bool res; + res = false; if (JS_VALUE_GET_TAG(argv[0]) == JS_TAG_OBJECT) { p = JS_VALUE_GET_OBJ(argv[0]); if (p->class_id >= JS_CLASS_UINT8C_ARRAY && p->class_id <= JS_CLASS_DATAVIEW) { - res = TRUE; + res = true; } } return js_bool(res); @@ -52130,7 +52132,7 @@ void JS_DetachArrayBuffer(JSContext *ctx, JSValue obj) abuf->free_func(ctx->rt, abuf->opaque, abuf->data); abuf->data = NULL; abuf->byte_length = 0; - abuf->detached = TRUE; + abuf->detached = true; list_for_each(el, &abuf->array_list) { JSTypedArray *ta; @@ -52180,7 +52182,7 @@ uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValue obj) return NULL; } -static BOOL array_buffer_is_resizable(const JSArrayBuffer *abuf) +static bool array_buffer_is_resizable(const JSArrayBuffer *abuf) { return abuf->max_byte_length >= 0; } @@ -52189,7 +52191,7 @@ static BOOL array_buffer_is_resizable(const JSArrayBuffer *abuf) static JSValue js_array_buffer_transfer(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic) { - BOOL transfer_to_fixed_length = magic & 1; + bool transfer_to_fixed_length = magic & 1; JSArrayBuffer *abuf; uint64_t new_len, old_len, max_len, *pmax_len; uint8_t *bs, *new_bs; @@ -52236,11 +52238,11 @@ static JSValue js_array_buffer_transfer(JSContext *ctx, JSValue this_val, /* neuter the backing buffer */ abuf->data = NULL; abuf->byte_length = 0; - abuf->detached = TRUE; + abuf->detached = true; return js_array_buffer_constructor3(ctx, JS_UNDEFINED, new_len, pmax_len, JS_CLASS_ARRAY_BUFFER, bs, abuf->free_func, - NULL, FALSE); + NULL, false); } static JSValue js_array_buffer_resize(JSContext *ctx, JSValue this_val, @@ -52414,7 +52416,7 @@ static const JSCFunctionListEntry js_shared_array_buffer_proto_funcs[] = { // is the typed array detached or out of bounds relative to its RAB? // |p| must be a typed array, *not* a DataView -static BOOL typed_array_is_oob(JSObject *p) +static bool typed_array_is_oob(JSObject *p) { JSArrayBuffer *abuf; JSTypedArray *ta; @@ -52427,14 +52429,14 @@ static BOOL typed_array_is_oob(JSObject *p) ta = p->u.typed_array; abuf = ta->buffer->u.array_buffer; if (abuf->detached) - return TRUE; + return true; len = abuf->byte_length; if (ta->offset > len) - return TRUE; + return true; if (ta->track_rab) - return FALSE; + return false; if (len < (int64_t)ta->offset + ta->length) - return TRUE; + return true; size_elem = 1 << typed_array_size_log2(p->class_id); end = (int64_t)ta->offset + (int64_t)p->u.array.count * size_elem; return end > len; @@ -52857,7 +52859,7 @@ static JSValue js_typed_array_from(JSContext *ctx, JSValue this_val, int64_t k, len; int done, mapping; - mapping = FALSE; + mapping = false; mapfn = JS_UNDEFINED; this_arg = JS_UNDEFINED; r = JS_UNDEFINED; @@ -52884,7 +52886,7 @@ static JSValue js_typed_array_from(JSContext *ctx, JSValue this_val, if (JS_IsException(arr)) goto exception; stack[0] = js_dup(items); - if (js_for_of_start(ctx, &stack[1], FALSE)) + if (js_for_of_start(ctx, &stack[1], false)) goto exception; for (k = 0;; k++) { v = JS_IteratorNext(ctx, stack[0], stack[1], 0, NULL, &done); @@ -52928,7 +52930,7 @@ static JSValue js_typed_array_from(JSContext *ctx, JSValue this_val, exception_close: if (!JS_IsUndefined(stack[0])) - JS_IteratorClose(ctx, stack[0], TRUE); + JS_IteratorClose(ctx, stack[0], true); exception: JS_FreeValue(ctx, r); r = JS_EXCEPTION; @@ -53169,7 +53171,7 @@ static JSValue js_typed_array_indexOf(JSContext *ctx, JSValue this_val, double d; float f; uint16_t hf; - BOOL oob; + bool oob; p = get_typed_array(ctx, this_val); if (!p) @@ -53181,7 +53183,7 @@ static JSValue js_typed_array_indexOf(JSContext *ctx, JSValue this_val, if (len == 0) goto done; - oob = FALSE; + oob = false; if (special == special_lastIndexOf) { k = len - 1; if (argc > 1) { @@ -53215,7 +53217,7 @@ static JSValue js_typed_array_indexOf(JSContext *ctx, JSValue this_val, k = 0; } else if (k > len) { k = len; - oob = TRUE; + oob = true; } } stop = len; @@ -54121,7 +54123,7 @@ static JSValue js_typed_array_base_constructor(JSContext *ctx, /* 'obj' must be an allocated typed array object */ static int typed_array_init(JSContext *ctx, JSValue obj, JSValue buffer, - uint64_t offset, uint64_t len, BOOL track_rab) + uint64_t offset, uint64_t len, bool track_rab) { JSTypedArray *ta; JSObject *p, *pbuffer; @@ -54154,7 +54156,7 @@ static JSValue js_array_from_iterator(JSContext *ctx, uint32_t *plen, JSValue obj, JSValue method) { JSValue arr, iter, next_method = JS_UNDEFINED, val; - BOOL done; + int done; uint32_t k; *plen = 0; @@ -54227,7 +54229,7 @@ static JSValue js_typed_array_constructor_obj(JSContext *ctx, NULL); if (JS_IsException(buffer)) goto fail; - if (typed_array_init(ctx, ret, buffer, 0, len, /*track_rab*/FALSE)) + if (typed_array_init(ctx, ret, buffer, 0, len, /*track_rab*/false)) goto fail; for(i = 0; i < len; i++) { @@ -54281,7 +54283,7 @@ static JSValue js_typed_array_constructor_ta(JSContext *ctx, goto fail; } abuf = JS_GetOpaque(buffer, JS_CLASS_ARRAY_BUFFER); - if (typed_array_init(ctx, obj, buffer, 0, len, /*track_rab*/FALSE)) + if (typed_array_init(ctx, obj, buffer, 0, len, /*track_rab*/false)) goto fail; if (p->class_id == classid) { /* same type: copy the content */ @@ -54307,7 +54309,7 @@ static JSValue js_typed_array_constructor(JSContext *ctx, int argc, JSValue *argv, int classid) { - BOOL track_rab = FALSE; + bool track_rab = false; JSValue buffer, obj; JSArrayBuffer *abuf; int size_log2; @@ -54404,8 +54406,8 @@ static JSValue js_dataview_constructor(JSContext *ctx, JSValue new_target, int argc, JSValue *argv) { - BOOL recompute_len = FALSE; - BOOL track_rab = FALSE; + bool recompute_len = false; + bool track_rab = false; JSArrayBuffer *abuf; uint64_t offset; uint32_t len; @@ -54436,7 +54438,7 @@ static JSValue js_dataview_constructor(JSContext *ctx, return JS_ThrowRangeError(ctx, "invalid byteLength"); len = l; } else { - recompute_len = TRUE; + recompute_len = true; track_rab = array_buffer_is_resizable(abuf); } @@ -54476,7 +54478,7 @@ static JSValue js_dataview_constructor(JSContext *ctx, } // is the DataView out of bounds relative to its parent arraybuffer? -static BOOL dataview_is_oob(JSObject *p) +static bool dataview_is_oob(JSObject *p) { JSArrayBuffer *abuf; JSTypedArray *ta; @@ -54485,11 +54487,11 @@ static BOOL dataview_is_oob(JSObject *p) ta = p->u.typed_array; abuf = ta->buffer->u.array_buffer; if (abuf->detached) - return TRUE; + return true; if (ta->offset > abuf->byte_length) - return TRUE; + return true; if (ta->track_rab) - return FALSE; + return false; return (int64_t)ta->offset + ta->length > abuf->byte_length; } @@ -54557,7 +54559,7 @@ static JSValue js_dataview_getValue(JSContext *ctx, { JSTypedArray *ta; JSArrayBuffer *abuf; - BOOL littleEndian, is_swap; + bool littleEndian, is_swap; int size; uint8_t *ptr; uint32_t v; @@ -54670,7 +54672,7 @@ static JSValue js_dataview_setValue(JSContext *ctx, { JSTypedArray *ta; JSArrayBuffer *abuf; - BOOL littleEndian, is_swap; + bool littleEndian, is_swap; int size; uint8_t *ptr; uint64_t v64; @@ -54800,7 +54802,7 @@ static JSValue js_new_uint8array(JSContext *ctx, JSValue buffer) } JSArrayBuffer *abuf = js_get_array_buffer(ctx, buffer); assert(abuf != NULL); - if (typed_array_init(ctx, obj, buffer, 0, abuf->byte_length, /*track_rab*/FALSE)) { + if (typed_array_init(ctx, obj, buffer, 0, abuf->byte_length, /*track_rab*/false)) { // 'buffer' is freed on error above. JS_FreeValue(ctx, obj); return JS_EXCEPTION; @@ -54810,13 +54812,13 @@ static JSValue js_new_uint8array(JSContext *ctx, JSValue buffer) JSValue JS_NewUint8Array(JSContext *ctx, uint8_t *buf, size_t len, JSFreeArrayBufferDataFunc *free_func, void *opaque, - JS_BOOL is_shared) + bool is_shared) { JSClassID class_id = is_shared ? JS_CLASS_SHARED_ARRAY_BUFFER : JS_CLASS_ARRAY_BUFFER; JSValue buffer = js_array_buffer_constructor3(ctx, JS_UNDEFINED, len, NULL, class_id, buf, free_func, - opaque, FALSE); + opaque, false); return js_new_uint8array(ctx, buffer); } @@ -54826,7 +54828,7 @@ JSValue JS_NewUint8ArrayCopy(JSContext *ctx, const uint8_t *buf, size_t len) JS_CLASS_ARRAY_BUFFER, (uint8_t *)buf, js_array_buffer_free, NULL, - TRUE); + true); return js_new_uint8array(ctx, buffer); } @@ -54864,7 +54866,7 @@ static void *js_atomics_get_ptr(JSContext *ctx, JSArrayBuffer *abuf; void *ptr; uint64_t idx; - BOOL err; + bool err; int size_log2; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) @@ -55122,7 +55124,7 @@ static JSValue js_atomics_isLockFree(JSContext *ctx, typedef struct JSAtomicsWaiter { struct list_head link; - BOOL linked; + bool linked; js_cond_t cond; int32_t *ptr; } JSAtomicsWaiter; @@ -55209,7 +55211,7 @@ static JSValue js_atomics_wait(JSContext *ctx, waiter = &waiter_s; waiter->ptr = ptr; js_cond_init(&waiter->cond); - waiter->linked = TRUE; + waiter->linked = true; list_add_tail(&waiter->link, &js_atomics_waiter_list); if (timeout == INT64_MAX) { @@ -55260,7 +55262,7 @@ static JSValue js_atomics_notify(JSContext *ctx, waiter = list_entry(el, JSAtomicsWaiter, link); if (waiter->ptr == ptr) { list_del(&waiter->link); - waiter->linked = FALSE; + waiter->linked = false; list_add_tail(&waiter->link, &waiter_list); n++; if (n >= count) @@ -55440,17 +55442,17 @@ int JS_IsEqual(JSContext *ctx, JSValue op1, JSValue op2) return JS_VALUE_GET_BOOL(sp[0]); } -JS_BOOL JS_IsStrictEqual(JSContext *ctx, JSValue op1, JSValue op2) +bool JS_IsStrictEqual(JSContext *ctx, JSValue op1, JSValue op2) { return js_strict_eq2(ctx, js_dup(op1), js_dup(op2), JS_EQ_STRICT); } -JS_BOOL JS_IsSameValue(JSContext *ctx, JSValue op1, JSValue op2) +bool JS_IsSameValue(JSContext *ctx, JSValue op1, JSValue op2) { return js_same_value(ctx, op1, op2); } -JS_BOOL JS_IsSameValueZero(JSContext *ctx, JSValue op1, JSValue op2) +bool JS_IsSameValueZero(JSContext *ctx, JSValue op1, JSValue op2) { return js_same_value_zero(ctx, op1, op2); } @@ -55679,7 +55681,7 @@ static JSValue js_finrec_unregister(JSContext *ctx, JSValue this_val, int argc, return JS_ThrowTypeError(ctx, "invalid unregister token"); struct list_head *el, *el1; - BOOL removed = FALSE; + bool removed = false; list_for_each_safe(el, el1, &frd->entries) { JSFinRecEntry *fre = list_entry(el, JSFinRecEntry, link); if (js_same_value(ctx, fre->token, token)) { @@ -55688,7 +55690,7 @@ static JSValue js_finrec_unregister(JSContext *ctx, JSValue this_val, int argc, JS_FreeValue(ctx, fre->held_val); JS_FreeValue(ctx, fre->token); js_free(ctx, fre); - removed = TRUE; + removed = true; } } @@ -55812,7 +55814,7 @@ static void reset_weak_ref(JSRuntime *rt, JSWeakRefRecord **first_weak_ref) *first_weak_ref = NULL; /* fail safe */ } -static BOOL is_valid_weakref_target(JSValue val) +static bool is_valid_weakref_target(JSValue val) { switch (JS_VALUE_GET_TAG(val)) { case JS_TAG_OBJECT: @@ -55825,10 +55827,10 @@ static BOOL is_valid_weakref_target(JSValue val) // fallthru } default: - return FALSE; + return false; } - return TRUE; + return true; } static void insert_weakref_record(JSValue target, struct JSWeakRefRecord *wr) @@ -56042,7 +56044,7 @@ static void js_new_callsite_data(JSContext *ctx, JSCallSiteData *csd, JSStackFra line_num1 = find_line_num(ctx, b, sf->cur_pc - b->byte_code_buf - 1, &col_num1); - csd->native = FALSE; + csd->native = false; csd->line_num = line_num1; csd->col_num = col_num1; csd->filename = JS_AtomToString(ctx, b->filename); @@ -56051,7 +56053,7 @@ static void js_new_callsite_data(JSContext *ctx, JSCallSiteData *csd, JSStackFra JS_FreeValue(ctx, JS_GetException(ctx)); // Clear exception. } } else { - csd->native = TRUE; + csd->native = true; csd->line_num = -1; csd->col_num = -1; csd->filename = JS_NULL; @@ -56062,7 +56064,7 @@ static void js_new_callsite_data2(JSContext *ctx, JSCallSiteData *csd, const cha { csd->func = JS_NULL; csd->func_name = JS_NULL; - csd->native = FALSE; + csd->native = false; csd->line_num = line_num; csd->col_num = col_num; /* filename is UTF-8 encoded if needed (original argument to __JS_EvalInternal()) */ @@ -56127,21 +56129,21 @@ static void _JS_AddIntrinsicCallSite(JSContext *ctx) countof(js_callsite_proto_funcs)); } -BOOL JS_DetectModule(const char *input, size_t input_len) +bool JS_DetectModule(const char *input, size_t input_len) { JSRuntime *rt; JSContext *ctx; JSValue val; - BOOL is_module; + bool is_module; - is_module = TRUE; + is_module = true; rt = JS_NewRuntime(); if (!rt) - return FALSE; + return false; ctx = JS_NewContextRaw(rt); if (!ctx) { JS_FreeRuntime(rt); - return FALSE; + return false; } JS_AddIntrinsicRegExp(ctx); // otherwise regexp literals don't parse val = __JS_EvalInternal(ctx, JS_UNDEFINED, input, input_len, "", diff --git a/quickjs.h b/quickjs.h index c9ffe58b..99599865 100644 --- a/quickjs.h +++ b/quickjs.h @@ -27,6 +27,7 @@ #ifndef QUICKJS_H #define QUICKJS_H +#include #include #include #include @@ -46,8 +47,6 @@ extern "C" { #define JS_EXTERN /* nothing */ #endif -#define JS_BOOL int - typedef struct JSRuntime JSRuntime; typedef struct JSContext JSContext; typedef struct JSObject JSObject; @@ -148,7 +147,7 @@ static inline int JS_VALUE_GET_NORM_TAG(JSValue v) return tag; } -static inline JS_BOOL JS_VALUE_IS_NAN(JSValue v) +static inline bool JS_VALUE_IS_NAN(JSValue v) { uint32_t tag; tag = JS_VALUE_GET_TAG(v); @@ -219,7 +218,7 @@ static inline JSValue __JS_NewFloat64(double d) return v; } -static inline JS_BOOL JS_VALUE_IS_NAN(JSValue v) +static inline bool JS_VALUE_IS_NAN(JSValue v) { union { double d; @@ -344,7 +343,7 @@ JS_EXTERN int JS_AddRuntimeFinalizer(JSRuntime *rt, typedef void JS_MarkFunc(JSRuntime *rt, JSGCObjectHeader *gp); JS_EXTERN void JS_MarkValue(JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func); JS_EXTERN void JS_RunGC(JSRuntime *rt); -JS_EXTERN JS_BOOL JS_IsLiveObject(JSRuntime *rt, JSValue obj); +JS_EXTERN bool JS_IsLiveObject(JSRuntime *rt, JSValue obj); JS_EXTERN JSContext *JS_NewContext(JSRuntime *rt); JS_EXTERN void JS_FreeContext(JSContext *s); @@ -375,10 +374,10 @@ JS_EXTERN void JS_AddPerformance(JSContext *ctx); /* for equality comparisons and sameness */ JS_EXTERN int JS_IsEqual(JSContext *ctx, JSValue op1, JSValue op2); -JS_EXTERN JS_BOOL JS_IsStrictEqual(JSContext *ctx, JSValue op1, JSValue op2); -JS_EXTERN JS_BOOL JS_IsSameValue(JSContext *ctx, JSValue op1, JSValue op2); +JS_EXTERN bool JS_IsStrictEqual(JSContext *ctx, JSValue op1, JSValue op2); +JS_EXTERN bool JS_IsSameValue(JSContext *ctx, JSValue op1, JSValue op2); /* Similar to same-value equality, but +0 and -0 are considered equal. */ -JS_EXTERN JS_BOOL JS_IsSameValueZero(JSContext *ctx, JSValue op1, JSValue op2); +JS_EXTERN bool JS_IsSameValueZero(JSContext *ctx, JSValue op1, JSValue op2); /* Only used for running 262 tests. TODO(saghul) add build time flag. */ JS_EXTERN JSValue js_string_codePointRange(JSContext *ctx, JSValue this_val, @@ -437,7 +436,7 @@ JS_EXTERN JSAtom JS_ValueToAtom(JSContext *ctx, JSValue val); /* object class support */ typedef struct JSPropertyEnum { - JS_BOOL is_enumerable; + bool is_enumerable; JSAtom atom; } JSPropertyEnum; @@ -450,7 +449,7 @@ typedef struct JSPropertyDescriptor { typedef struct JSClassExoticMethods { /* Return -1 if exception (can only happen in case of Proxy object), - FALSE if the property does not exists, TRUE if it exists. If 1 is + false if the property does not exists, true if it exists. If 1 is returned, the property descriptor 'desc' is filled if != NULL. */ int (*get_own_property)(JSContext *ctx, JSPropertyDescriptor *desc, JSValue obj, JSAtom prop); @@ -460,20 +459,20 @@ typedef struct JSClassExoticMethods { int (*get_own_property_names)(JSContext *ctx, JSPropertyEnum **ptab, uint32_t *plen, JSValue obj); - /* return < 0 if exception, or TRUE/FALSE */ + /* return < 0 if exception, or true/false */ int (*delete_property)(JSContext *ctx, JSValue obj, JSAtom prop); - /* return < 0 if exception or TRUE/FALSE */ + /* return < 0 if exception or true/false */ int (*define_own_property)(JSContext *ctx, JSValue this_obj, JSAtom prop, JSValue val, JSValue getter, JSValue setter, int flags); /* The following methods can be emulated with the previous ones, so they are usually not needed */ - /* return < 0 if exception or TRUE/FALSE */ + /* return < 0 if exception or true/false */ int (*has_property)(JSContext *ctx, JSValue obj, JSAtom atom); JSValue (*get_property)(JSContext *ctx, JSValue obj, JSAtom atom, JSValue receiver); - /* return < 0 if exception or TRUE/FALSE */ + /* return < 0 if exception or true/false */ int (*set_property)(JSContext *ctx, JSValue obj, JSAtom atom, JSValue value, JSValue receiver, int flags); } JSClassExoticMethods; @@ -506,11 +505,11 @@ JS_EXTERN JSClassID JS_NewClassID(JSRuntime *rt, JSClassID *pclass_id); /* Returns the class ID if `v` is an object, otherwise returns JS_INVALID_CLASS_ID. */ JS_EXTERN JSClassID JS_GetClassID(JSValue v); JS_EXTERN int JS_NewClass(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def); -JS_EXTERN int JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id); +JS_EXTERN bool JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id); /* value handling */ -static js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val) +static js_force_inline JSValue JS_NewBool(JSContext *ctx, bool val) { (void)&ctx; return JS_MKVAL(JS_TAG_BOOL, (val != 0)); @@ -560,63 +559,63 @@ JS_EXTERN JSValue JS_NewNumber(JSContext *ctx, double d); JS_EXTERN JSValue JS_NewBigInt64(JSContext *ctx, int64_t v); JS_EXTERN JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v); -static inline JS_BOOL JS_IsNumber(JSValue v) +static inline bool JS_IsNumber(JSValue v) { int tag = JS_VALUE_GET_TAG(v); return tag == JS_TAG_INT || JS_TAG_IS_FLOAT64(tag); } -static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValue v) +static inline bool JS_IsBigInt(JSContext *ctx, JSValue v) { (void)&ctx; return JS_VALUE_GET_TAG(v) == JS_TAG_BIG_INT; } -static inline JS_BOOL JS_IsBool(JSValue v) +static inline bool JS_IsBool(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_BOOL; } -static inline JS_BOOL JS_IsNull(JSValue v) +static inline bool JS_IsNull(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_NULL; } -static inline JS_BOOL JS_IsUndefined(JSValue v) +static inline bool JS_IsUndefined(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_UNDEFINED; } -static inline JS_BOOL JS_IsException(JSValue v) +static inline bool JS_IsException(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_EXCEPTION; } -static inline JS_BOOL JS_IsUninitialized(JSValue v) +static inline bool JS_IsUninitialized(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_UNINITIALIZED; } -static inline JS_BOOL JS_IsString(JSValue v) +static inline bool JS_IsString(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_STRING; } -static inline JS_BOOL JS_IsSymbol(JSValue v) +static inline bool JS_IsSymbol(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_SYMBOL; } -static inline JS_BOOL JS_IsObject(JSValue v) +static inline bool JS_IsObject(JSValue v) { return JS_VALUE_GET_TAG(v) == JS_TAG_OBJECT; } JS_EXTERN JSValue JS_Throw(JSContext *ctx, JSValue obj); JS_EXTERN JSValue JS_GetException(JSContext *ctx); -JS_EXTERN JS_BOOL JS_HasException(JSContext *ctx); -JS_EXTERN JS_BOOL JS_IsError(JSContext *ctx, JSValue val); -JS_EXTERN JS_BOOL JS_IsUncatchableError(JSContext* ctx, JSValue val); +JS_EXTERN bool JS_HasException(JSContext *ctx); +JS_EXTERN bool JS_IsError(JSContext *ctx, JSValue val); +JS_EXTERN bool JS_IsUncatchableError(JSContext* ctx, JSValue val); JS_EXTERN void JS_SetUncatchableError(JSContext *ctx, JSValue val); JS_EXTERN void JS_ClearUncatchableError(JSContext *ctx, JSValue val); // Shorthand for: @@ -663,7 +662,7 @@ static inline JSValue JS_NewString(JSContext *ctx, const char *str) { JS_EXTERN JSValue JS_NewAtomString(JSContext *ctx, const char *str); JS_EXTERN JSValue JS_ToString(JSContext *ctx, JSValue val); JS_EXTERN JSValue JS_ToPropertyKey(JSContext *ctx, JSValue val); -JS_EXTERN const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValue val1, JS_BOOL cesu8); +JS_EXTERN const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValue val1, bool cesu8); static inline const char *JS_ToCStringLen(JSContext *ctx, size_t *plen, JSValue val1) { return JS_ToCStringLen2(ctx, plen, val1, 0); @@ -680,18 +679,18 @@ JS_EXTERN JSValue JS_NewObjectProto(JSContext *ctx, JSValue proto); JS_EXTERN JSValue JS_NewObject(JSContext *ctx); JS_EXTERN JSValue JS_ToObject(JSContext *ctx, JSValue val); -JS_EXTERN JS_BOOL JS_IsFunction(JSContext* ctx, JSValue val); -JS_EXTERN JS_BOOL JS_IsConstructor(JSContext* ctx, JSValue val); -JS_EXTERN JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, JS_BOOL val); +JS_EXTERN bool JS_IsFunction(JSContext* ctx, JSValue val); +JS_EXTERN bool JS_IsConstructor(JSContext* ctx, JSValue val); +JS_EXTERN bool JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, bool val); -JS_EXTERN JS_BOOL JS_IsRegExp(JSValue val); -JS_EXTERN JS_BOOL JS_IsMap(JSValue val); +JS_EXTERN bool JS_IsRegExp(JSValue val); +JS_EXTERN bool JS_IsMap(JSValue val); JS_EXTERN JSValue JS_NewArray(JSContext *ctx); JS_EXTERN int JS_IsArray(JSContext *ctx, JSValue val); JS_EXTERN JSValue JS_NewDate(JSContext *ctx, double epoch_ms); -JS_EXTERN JS_BOOL JS_IsDate(JSValue v); +JS_EXTERN bool JS_IsDate(JSValue v); JS_EXTERN JSValue JS_GetProperty(JSContext *ctx, JSValue this_obj, JSAtom prop); JS_EXTERN JSValue JS_GetPropertyUint32(JSContext *ctx, JSValue this_obj, @@ -744,13 +743,13 @@ JS_EXTERN JSValue JS_CallConstructor(JSContext *ctx, JSValue func_obj, JS_EXTERN JSValue JS_CallConstructor2(JSContext *ctx, JSValue func_obj, JSValue new_target, int argc, JSValue *argv); -/* Try to detect if the input is a module. Returns TRUE if parsing the input +/* Try to detect if the input is a module. Returns true if parsing the input * as a module produces no syntax errors. It's a naive approach that is not * wholly infallible: non-strict classic scripts may _parse_ okay as a module * but not _execute_ as one (different runtime semantics.) Use with caution. * |input| can be either ASCII or UTF-8 encoded source code. */ -JS_EXTERN JS_BOOL JS_DetectModule(const char *input, size_t input_len); +JS_EXTERN bool JS_DetectModule(const char *input, size_t input_len); /* 'input' must be zero terminated i.e. input[input_len] = '\0'. */ JS_EXTERN JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len, const char *filename, int eval_flags); @@ -787,11 +786,11 @@ JS_EXTERN JSValue JS_JSONStringify(JSContext *ctx, JSValue obj, typedef void JSFreeArrayBufferDataFunc(JSRuntime *rt, void *opaque, void *ptr); JS_EXTERN JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len, JSFreeArrayBufferDataFunc *free_func, void *opaque, - JS_BOOL is_shared); + bool is_shared); JS_EXTERN JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len); JS_EXTERN void JS_DetachArrayBuffer(JSContext *ctx, JSValue obj); JS_EXTERN uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValue obj); -JS_EXTERN JS_BOOL JS_IsArrayBuffer(JSValue obj); +JS_EXTERN bool JS_IsArrayBuffer(JSValue obj); JS_EXTERN uint8_t *JS_GetUint8Array(JSContext *ctx, size_t *psize, JSValue obj); typedef enum JSTypedArrayEnum { @@ -817,7 +816,7 @@ JS_EXTERN JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValue obj, size_t *pbytes_per_element); JS_EXTERN JSValue JS_NewUint8Array(JSContext *ctx, uint8_t *buf, size_t len, JSFreeArrayBufferDataFunc *free_func, void *opaque, - JS_BOOL is_shared); + bool is_shared); /* returns -1 if not a typed array otherwise return a JSTypedArrayEnum value */ JS_EXTERN int JS_GetTypedArrayType(JSValue obj); JS_EXTERN JSValue JS_NewUint8ArrayCopy(JSContext *ctx, const uint8_t *buf, size_t len); @@ -838,21 +837,21 @@ typedef enum JSPromiseStateEnum { JS_EXTERN JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs); JS_EXTERN JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise); JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValue promise); -JS_EXTERN JS_BOOL JS_IsPromise(JSValue val); +JS_EXTERN bool JS_IsPromise(JSValue val); -JS_EXTERN JSValue JS_NewSymbol(JSContext *ctx, const char *description, JS_BOOL is_global); +JS_EXTERN JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global); -/* is_handled = TRUE means that the rejection is handled */ +/* is_handled = true means that the rejection is handled */ typedef void JSHostPromiseRejectionTracker(JSContext *ctx, JSValue promise, JSValue reason, - JS_BOOL is_handled, void *opaque); + bool is_handled, void *opaque); JS_EXTERN void JS_SetHostPromiseRejectionTracker(JSRuntime *rt, JSHostPromiseRejectionTracker *cb, void *opaque); /* return != 0 if the JS code needs to be interrupted */ typedef int JSInterruptHandler(JSRuntime *rt, void *opaque); JS_EXTERN void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque); -/* if can_block is TRUE, Atomics.wait() can be used */ -JS_EXTERN void JS_SetCanBlock(JSRuntime *rt, JS_BOOL can_block); +/* if can_block is true, Atomics.wait() can be used */ +JS_EXTERN void JS_SetCanBlock(JSRuntime *rt, bool can_block); /* set the [IsHTMLDDA] internal slot */ JS_EXTERN void JS_SetIsHTMLDDA(JSContext *ctx, JSValue obj); @@ -881,7 +880,7 @@ JS_EXTERN JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m); typedef JSValue JSJobFunc(JSContext *ctx, int argc, JSValue *argv); JS_EXTERN int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func, int argc, JSValue *argv); -JS_EXTERN JS_BOOL JS_IsJobPending(JSRuntime *rt); +JS_EXTERN bool JS_IsJobPending(JSRuntime *rt); JS_EXTERN int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx); /* Structure to retrieve (de)serialized SharedArrayBuffer objects. */ diff --git a/run-test262.c b/run-test262.c index d721d121..a94fd25e 100644 --- a/run-test262.c +++ b/run-test262.c @@ -528,7 +528,7 @@ static void start_thread(js_thread_t *thrd, void *(*start)(void *), void *arg) // it so make a copy. Race-y for very short-lived threads. Can be solved // by switching to _beginthreadex(CREATE_SUSPENDED) but means changing // |start| from __cdecl to __stdcall. - if (!DuplicateHandle(cp, h, cp, thrd, 0, FALSE, DUPLICATE_SAME_ACCESS)) + if (!DuplicateHandle(cp, h, cp, thrd, 0, false, DUPLICATE_SAME_ACCESS)) fatal(1, "DuplicateHandle error"); #else pthread_attr_t attr; @@ -587,7 +587,7 @@ typedef struct { js_thread_t tid; char *script; JSValue broadcast_func; - BOOL broadcast_pending; + bool broadcast_pending; JSValue broadcast_sab; /* in the main context */ uint8_t *broadcast_sab_buf; size_t broadcast_sab_size; @@ -626,7 +626,7 @@ static void *agent_start(void *arg) } JS_SetContextOpaque(ctx, agent); JS_SetRuntimeInfo(rt, "agent"); - JS_SetCanBlock(rt, TRUE); + JS_SetCanBlock(rt, true); add_helpers(ctx); ret_val = JS_Eval(ctx, agent->script, strlen(agent->script), @@ -654,14 +654,14 @@ static void *agent_start(void *arg) js_cond_wait(&tls->agent_cond, &tls->agent_mutex); } - agent->broadcast_pending = FALSE; + agent->broadcast_pending = false; js_cond_signal(&tls->agent_cond); js_mutex_unlock(&tls->agent_mutex); args[0] = JS_NewArrayBuffer(ctx, agent->broadcast_sab_buf, agent->broadcast_sab_size, - NULL, NULL, TRUE); + NULL, NULL, true); args[1] = JS_NewInt32(ctx, agent->broadcast_val); ret_val = JS_Call(ctx, agent->broadcast_func, JS_UNDEFINED, 2, args); @@ -732,16 +732,16 @@ static JSValue js_agent_leaving(JSContext *ctx, JSValue this_val, return JS_UNDEFINED; } -static BOOL is_broadcast_pending(ThreadLocalStorage *tls) +static bool is_broadcast_pending(ThreadLocalStorage *tls) { struct list_head *el; Test262Agent *agent; list_for_each(el, &tls->agent_list) { agent = list_entry(el, Test262Agent, link); if (agent->broadcast_pending) - return TRUE; + return true; } - return FALSE; + return false; } static JSValue js_agent_broadcast(JSContext *ctx, JSValue this_val, @@ -769,7 +769,7 @@ static JSValue js_agent_broadcast(JSContext *ctx, JSValue this_val, js_mutex_lock(&tls->agent_mutex); list_for_each(el, &tls->agent_list) { agent = list_entry(el, Test262Agent, link); - agent->broadcast_pending = TRUE; + agent->broadcast_pending = true; /* the shared array buffer is used by the thread, so increment its refcount */ agent->broadcast_sab = JS_DupValue(ctx, sab); @@ -1357,13 +1357,13 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len, ThreadLocalStorage *tls = JS_GetRuntimeOpaque(JS_GetRuntime(ctx)); JSValue res_val, exception_val; int ret, error_line, pos, pos_line; - BOOL is_error, has_error_line, ret_promise; + bool is_error, has_error_line, ret_promise; const char *error_name; int start, duration; pos = skip_comments(buf, 1, &pos_line); error_line = pos_line; - has_error_line = FALSE; + has_error_line = false; exception_val = JS_UNDEFINED; error_name = NULL; @@ -1435,7 +1435,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len, p = strstr(stack_str, filename); if (p != NULL && p[len] == ':') { error_line = atoi(p + len + 1); - has_error_line = TRUE; + has_error_line = true; } JS_FreeCString(ctx, stack_str); } @@ -1476,7 +1476,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len, int s_line; char *s = find_error(filename, &s_line, eval_flags & JS_EVAL_FLAG_STRICT); const char *strict_mode = (eval_flags & JS_EVAL_FLAG_STRICT) ? "strict mode: " : ""; - BOOL is_unexpected_error = TRUE; + bool is_unexpected_error = true; if (!JS_IsUndefined(exception_val)) { msg_val = JS_ToString(ctx, exception_val); @@ -1494,7 +1494,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len, printf("%s:%d: %sOK, now has error %s\n", filename, error_line, strict_mode, msg); atomic_inc(&fixed_errors); - is_unexpected_error = FALSE; + is_unexpected_error = false; } } else { if (!s) { // not yet reported @@ -1533,7 +1533,7 @@ static int eval_buf(JSContext *ctx, const char *buf, size_t buf_len, if (s) { printf("%s:%d: %sOK, fixed error: %s\n", filename, s_line, strict_mode, s); atomic_inc(&fixed_errors); - is_unexpected_error = FALSE; + is_unexpected_error = false; } } } @@ -1579,8 +1579,8 @@ static int eval_file(JSContext *ctx, const char *base, const char *p, warning("cannot load %s", filename); goto fail; } - if (eval_buf(ctx, buf, buf_len, filename, FALSE, FALSE, NULL, - eval_flags, FALSE, &msec)) { + if (eval_buf(ctx, buf, buf_len, filename, false, false, NULL, + eval_flags, false, &msec)) { warning("error evaluating %s", filename); goto fail; } @@ -1742,8 +1742,8 @@ JSContext *JS_NewCustomContext(JSRuntime *rt) int run_test_buf(ThreadLocalStorage *tls, const char *filename, char *harness, namelist_t *ip, char *buf, size_t buf_len, - const char* error_type, int eval_flags, BOOL is_negative, - BOOL is_async, BOOL can_block, int *msec) + const char* error_type, int eval_flags, bool is_negative, + bool is_async, bool can_block, int *msec) { JSRuntime *rt; JSContext *ctx; @@ -1784,7 +1784,7 @@ int run_test_buf(ThreadLocalStorage *tls, const char *filename, char *harness, } } - ret = eval_buf(ctx, buf, buf_len, filename, TRUE, is_negative, + ret = eval_buf(ctx, buf, buf_len, filename, true, is_negative, error_type, eval_flags, is_async, msec); ret = (ret != 0); @@ -1811,13 +1811,13 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec) char *desc, *p; char *error_type; int ret, eval_flags, use_strict, use_nostrict; - BOOL is_negative, is_nostrict, is_onlystrict, is_async, is_module, skip; - BOOL detect_module = TRUE; - BOOL can_block; + bool is_negative, is_nostrict, is_onlystrict, is_async, is_module, skip; + bool detect_module = true; + bool can_block; namelist_t include_list = { 0 }, *ip = &include_list; - is_nostrict = is_onlystrict = is_negative = is_async = is_module = skip = FALSE; - can_block = TRUE; + is_nostrict = is_onlystrict = is_negative = is_async = is_module = skip = false; + can_block = true; error_type = NULL; buf = load_file(filename, &buf_len); @@ -1857,26 +1857,26 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec) while ((option = get_option(&p, &state)) != NULL) { if (str_equal(option, "noStrict") || str_equal(option, "raw")) { - is_nostrict = TRUE; + is_nostrict = true; skip |= (test_mode == TEST_STRICT); } else if (str_equal(option, "onlyStrict")) { - is_onlystrict = TRUE; + is_onlystrict = true; skip |= (test_mode == TEST_NOSTRICT); } else if (str_equal(option, "async")) { - is_async = TRUE; + is_async = true; skip |= skip_async; } else if (str_equal(option, "qjs:no-detect-module")) { - detect_module = FALSE; + detect_module = false; } else if (str_equal(option, "module")) { - is_module = TRUE; + is_module = true; skip |= skip_module; } else if (str_equal(option, "CanBlockIsFalse")) { - can_block = FALSE; + can_block = false; } free(option); } @@ -1890,7 +1890,7 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec) q++; error_type = strdup_len(q, strcspn(q, " \r\n")); } - is_negative = TRUE; + is_negative = true; } p = find_tag(desc, "features:", &state); if (p) { @@ -1982,7 +1982,7 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int *msec) /* run a test when called by test262-harness+eshost */ int run_test262_harness_test(ThreadLocalStorage *tls, const char *filename, - BOOL is_module) + bool is_module) { JSRuntime *rt; JSContext *ctx; @@ -1990,7 +1990,7 @@ int run_test262_harness_test(ThreadLocalStorage *tls, const char *filename, size_t buf_len; int eval_flags, ret_code, ret; JSValue res_val; - BOOL can_block; + bool can_block; outfile = stdout; /* for js_print_262 */ @@ -2006,7 +2006,7 @@ int run_test262_harness_test(ThreadLocalStorage *tls, const char *filename, } JS_SetRuntimeInfo(rt, filename); - can_block = TRUE; + can_block = true; JS_SetCanBlock(rt, can_block); /* loader for ES6 modules */ @@ -2148,12 +2148,12 @@ int main(int argc, char **argv) { ThreadLocalStorage tls_s, *tls = &tls_s; int i, optind; - BOOL is_dir_list; - BOOL only_check_errors = FALSE; + bool is_dir_list; + bool only_check_errors = false; const char *filename; const char *ignore = ""; - BOOL is_test262_harness = FALSE; - BOOL is_module = FALSE; + bool is_test262_harness = false; + bool is_module = false; js_std_set_worker_new_context_func(JS_NewCustomContext); @@ -2183,7 +2183,7 @@ int main(int argc, char **argv) /* cannot use getopt because we want to pass the command line to the script */ optind = 1; - is_dir_list = TRUE; + is_dir_list = true; while (optind < argc) { char *arg = argv[optind]; if (*arg != '-') @@ -2210,17 +2210,17 @@ int main(int argc, char **argv) } else if (str_equal(arg, "-x")) { namelist_load(&exclude_list, get_opt_arg(arg, argv[optind++])); } else if (str_equal(arg, "-f")) { - is_dir_list = FALSE; + is_dir_list = false; } else if (str_equal(arg, "-E")) { - only_check_errors = TRUE; + only_check_errors = true; } else if (str_equal(arg, "-T")) { slow_test_threshold = atoi(get_opt_arg(arg, argv[optind++])); } else if (str_equal(arg, "-t")) { nthreads = atoi(get_opt_arg(arg, argv[optind++])); } else if (str_equal(arg, "-N")) { - is_test262_harness = TRUE; + is_test262_harness = true; } else if (str_equal(arg, "--module")) { - is_module = TRUE; + is_module = true; } else { fatal(1, "unknown option: %s", arg); break; diff --git a/unicode_gen.c b/unicode_gen.c index 76806e6d..cb46fbc9 100644 --- a/unicode_gen.c +++ b/unicode_gen.c @@ -567,7 +567,7 @@ void parse_composition_exclusions(const char *filename) continue; c0 = strtoul(p, (char **)&p, 16); assert(c0 > 0 && c0 <= CHARCODE_MAX); - unicode_db[c0].is_excluded = TRUE; + unicode_db[c0].is_excluded = true; } fclose(f); } @@ -887,7 +887,7 @@ void dump_unicode_data(CCInfo *tab) } } -BOOL is_complicated_case(const CCInfo *ci) +bool is_complicated_case(const CCInfo *ci) { return (ci->u_len > 1 || ci->l_len > 1 || (ci->u_len > 0 && ci->l_len > 0) || @@ -1373,7 +1373,7 @@ static int sp_cc_cmp(const void *p1, const void *p2) return memcmp(c1->f_data, c2->f_data, sizeof(c1->f_data[0]) * c1->f_len); } } - + /* dump the case special cases (multi character results which are identical and need specific handling in lre_canonicalize() */ void dump_case_folding_special_cases(CCInfo *tab) @@ -1393,7 +1393,7 @@ void dump_case_folding_special_cases(CCInfo *tab) len = 1; while ((i + len) <= CHARCODE_MAX && !sp_cc_cmp(&perm[i], &perm[i + len])) len++; - + if (len > 1) { for(j = i; j < i + len; j++) dump_cc_info(&tab[perm[j]], perm[j]); @@ -1404,7 +1404,7 @@ void dump_case_folding_special_cases(CCInfo *tab) free(perm); global_tab = NULL; } - + int tabcmp(const int *tab1, const int *tab2, int n) { @@ -1428,7 +1428,7 @@ void dump_str(const char *str, const int *buf, int len) void compute_internal_props(void) { int i; - BOOL has_ul; + bool has_ul; for(i = 0; i <= CHARCODE_MAX; i++) { CCInfo *ci = &unicode_db[i]; @@ -1468,7 +1468,7 @@ void dump_byte_table(FILE *f, const char *cname, const uint8_t *tab, int len) #define PROP_BLOCK_LEN 32 -void build_prop_table(FILE *f, int prop_index, BOOL add_index) +void build_prop_table(FILE *f, int prop_index, bool add_index) { int i, j, n, v, offset, code; DynBuf dbuf_s, *dbuf = &dbuf_s; @@ -1570,11 +1570,11 @@ void build_prop_table(FILE *f, int prop_index, BOOL add_index) void build_flags_tables(FILE *f) { - build_prop_table(f, PROP_Cased1, TRUE); - build_prop_table(f, PROP_Case_Ignorable, TRUE); - build_prop_table(f, PROP_ID_Start, TRUE); - build_prop_table(f, PROP_ID_Continue1, TRUE); - build_prop_table(f, PROP_White_Space, TRUE); + build_prop_table(f, PROP_Cased1, true); + build_prop_table(f, PROP_Case_Ignorable, true); + build_prop_table(f, PROP_ID_Start, true); + build_prop_table(f, PROP_ID_Continue1, true); + build_prop_table(f, PROP_White_Space, true); } void dump_name_table(FILE *f, const char *cname, const char **tab_name, int len, @@ -1818,7 +1818,7 @@ void build_prop_list_table(FILE *f) i == PROP_White_Space) { /* already generated */ } else { - build_prop_table(f, i, FALSE); + build_prop_table(f, i, false); } } @@ -1912,7 +1912,7 @@ static int64_t get_time_ns(void) void check_flags(void) { int c; - BOOL flag_ref, flag; + bool flag_ref, flag; for(c = 0; c <= CHARCODE_MAX; c++) { flag_ref = get_prop(c, PROP_Cased); flag = lre_is_cased(c); @@ -2220,29 +2220,29 @@ int get_short_code(int c) } } -static BOOL is_short(int code) +static bool is_short(int code) { return get_short_code(code) >= 0; } -static BOOL is_short_tab(const int *tab, int len) +static bool is_short_tab(const int *tab, int len) { int i; for(i = 0; i < len; i++) { if (!is_short(tab[i])) - return FALSE; + return false; } - return TRUE; + return true; } -static BOOL is_16bit(const int *tab, int len) +static bool is_16bit(const int *tab, int len) { int i; for(i = 0; i < len; i++) { if (tab[i] > 0xffff) - return FALSE; + return false; } - return TRUE; + return true; } static uint32_t to_lower_simple(uint32_t c) @@ -2487,10 +2487,10 @@ void find_decomp_run(DecompEntry *tab_de, int i) } if (l == 2) { - BOOL is_16bit; + bool is_16bit; n = 0; - is_16bit = FALSE; + is_16bit = false; for(;;) { if (!((i + n + 1) <= CHARCODE_MAX && n + 2 <= len_max)) break; @@ -2500,7 +2500,7 @@ void find_decomp_run(DecompEntry *tab_de, int i) is_short(ci1->decomp_data[1]))) break; if (!is_16bit && !is_short(ci1->decomp_data[0])) - is_16bit = TRUE; + is_16bit = true; ci2 = &unicode_db[i + n + 1]; if (!(ci2->decomp_len == l && ci2->is_compat == ci->is_compat && @@ -3063,7 +3063,7 @@ int main(int argc, char **argv) build_conv_table(unicode_db); #ifdef DUMP_CASE_FOLDING_SPECIAL_CASES - dump_case_folding_special_cases(unicode_db); + dump_case_folding_special_cases(unicode_db); #endif if (!outfilename) {