MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add JS_NAN and JS_INF constants

+256 -252
+5
include/ant.h
··· 17 17 #define ANT_PTR(ptr) js_mknum((double)(uintptr_t)(ptr)) 18 18 #define ANT_COPY(buf, len, s) cpy(buf, len, s, sizeof(s) - 1) 19 19 20 + #define JS_NAN ((double)NAN) 21 + #define JS_NEG_NAN ((double)(-NAN)) 22 + #define JS_INF ((double)INFINITY) 23 + #define JS_NEG_INF ((double)(-INFINITY)) 24 + 20 25 struct js; 21 26 22 27 typedef uint32_t jsoff_t;
+2 -12
libant/meson.build
··· 4 4 'c_std=gnu23', 5 5 'default_library=static', 6 6 'b_lto=false', 7 - 'strip=true' 7 + 'strip=true', 8 + 'warning_level=2' 8 9 ], subproject_dir: 'vendor') 9 10 10 11 use_lto = get_option('lto') ··· 33 34 include = include_directories('../include') 34 35 build_include = include_directories('.') 35 36 strip_include = include_directories('../src/strip') 36 - 37 - add_project_arguments( 38 - '-D NO_EXECUTE_PERMISSION', 39 - '-Wno-unused-function', 40 - '-Wno-deprecated-declarations', 41 - language: 'c') 42 - 43 - if host_machine.system() == 'linux' 44 - add_project_arguments('-fno-pie', language: 'c') 45 - add_project_link_arguments('-no-pie', language: 'c') 46 - endif 47 37 48 38 libant_core = static_library( 49 39 'ant_core',
+2 -21
meson.build
··· 5 5 'default_library=static', 6 6 'b_lto=true', 7 7 'b_lto_threads=8', 8 - 'strip=true' 8 + 'strip=true', 9 + 'warning_level=2' 9 10 ], subproject_dir: 'vendor') 10 11 11 12 src_root = meson.project_source_root() ··· 32 33 include = include_directories('include') 33 34 build_include = include_directories('.') 34 35 strip_include = include_directories('src/strip') 35 - 36 - add_project_arguments( 37 - '-D NO_EXECUTE_PERMISSION', 38 - '-Wall', 39 - '-Wextra', 40 - '-Wshadow', 41 - '-Wdouble-promotion', 42 - '-Wformat=2', 43 - '-Wundef', 44 - '-Wconversion', 45 - '-Wno-sign-conversion', 46 - '-Wno-unused-function', 47 - '-Wno-unused-parameter', 48 - '-Wno-deprecated-declarations', 49 - language: 'c') 50 - 51 - if host_machine.system() == 'linux' 52 - add_project_arguments('-fno-pie', language: 'c') 53 - add_project_link_arguments('-no-pie', language: 'c') 54 - endif 55 36 56 37 libant = static_library( 57 38 'ant',
+8 -3
meson/deps/meson.build
··· 39 39 40 40 libuv_sub = subproject('libuv', default_options: [ 41 41 'build_tests=false', 42 - 'build_benchmarks=false' 42 + 'build_benchmarks=false', 43 + 'warning_level=0' 43 44 ]) 44 45 libuv_dep = libuv_sub.get_variable('libuv_dep') 45 46 ··· 64 65 tlsuv_compile_args = [ 65 66 '-Wno-unused-function', 66 67 '-Wno-unused-variable', 68 + '-Wno-unused-parameter', 69 + '-Wno-sign-compare', 67 70 '-Wno-bitwise-op-parentheses', 68 71 '-Wno-sometimes-uninitialized', 72 + '-Wno-cast-function-type-mismatch', 73 + '-Wno-missing-field-initializers', 69 74 '-I' + meson.project_source_root() / vendor_dir / 'libuv-v1.51.0' / 'include' 70 75 ] 71 76 if cmake_prefix != '' ··· 82 87 tlsuv_dep = cmake.subproject('tlsuv', options: tlsuv_opts).dependency('tlsuv') 83 88 bdwgc_dep = cmake.subproject('bdwgc', options: bdwgc_opts).dependency('gc') 84 89 85 - pcre2_dep = subproject('pcre2').get_variable('libpcre2_8') 90 + pcre2_dep = subproject('pcre2', default_options: ['warning_level=0']).get_variable('libpcre2_8') 86 91 uthash_dep = subproject('uthash').get_variable('uthash_dep') 87 92 yyjson_dep = subproject('yyjson').get_variable('yyjson_dep') 88 93 uuidv7_dep = subproject('uuidv7').get_variable('uuidv7_dep') ··· 90 95 minicoro_dep = subproject('minicoro').get_variable('minicoro_dep') 91 96 92 97 zlib_dep = subproject('zlib-ng', 93 - default_options: ['b_lto=false'] 98 + default_options: ['b_lto=false', 'warning_level=0'] 94 99 ).get_variable('zlib_ng_dep') 95 100 96 101 libffi_dep = subproject('libffi', default_options: [
+19
meson/meson.build
··· 9 9 warning('Building in non-release mode. For best performance, use --buildtype=release') 10 10 endif 11 11 12 + add_project_arguments( 13 + '-DNO_EXECUTE_PERMISSION', 14 + '-Wshadow', 15 + '-Wdouble-promotion', 16 + '-Wformat=2', 17 + '-Wundef', 18 + '-Wconversion', 19 + '-Wno-sign-conversion', 20 + '-Wno-unused-function', 21 + '-Wno-unused-parameter', 22 + '-Wno-deprecated-declarations', 23 + language: 'c' 24 + ) 25 + 26 + if host_machine.system() == 'linux' 27 + add_project_arguments('-fno-pie', language: 'c') 28 + add_project_link_arguments('-no-pie', language: 'c') 29 + endif 30 + 12 31 subdir('deps') 13 32 subdir('version') 14 33 subdir('snapshot')
+220 -216
src/ant.c
··· 2377 2377 } 2378 2378 2379 2379 jsoff_t line_len = line_end - line_start; 2380 - if (line_len >= bufsize) line_len = bufsize - 1; 2380 + if (line_len >= bufsize) line_len = (jsoff_t)(bufsize - 1); 2381 2381 2382 2382 memcpy(buf, &code[line_start], line_len); 2383 2383 buf[line_len] = '\0'; ··· 2496 2496 get_error_line(js->code, js->clen, js->toff > 0 ? js->toff : js->pos, error_line, sizeof(error_line), &error_col); 2497 2497 2498 2498 va_start(ap, xx); 2499 + #pragma GCC diagnostic push 2500 + #pragma GCC diagnostic ignored "-Wformat-nonliteral" 2499 2501 vsnprintf(error_msg, sizeof(error_msg), xx, ap); 2502 + #pragma GCC diagnostic pop 2500 2503 va_end(ap); 2501 2504 2502 2505 const char *err_name = get_error_type_name(err_type); ··· 3156 3159 int remainder = 0; 3157 3160 for (size_t i = 0; i < numlen; i++) { 3158 3161 int d = remainder * 10 + (num[i] - '0'); 3159 - num[i] = '0' + (d / radix); 3162 + num[i] = (char)('0' + (d / radix)); 3160 3163 remainder = d % radix; 3161 3164 } 3162 3165 size_t start = 0; ··· 3176 3179 result_cap = new_cap; 3177 3180 } 3178 3181 rpos--; 3179 - result[rpos] = remainder < 10 ? '0' + remainder : 'a' + (remainder - 10); 3182 + result[rpos] = (char)(remainder < 10 ? '0' + remainder : 'a' + (remainder - 10)); 3180 3183 } 3181 3184 3182 3185 ANT_GC_FREE(num); ··· 3453 3456 if (vtype(arg) == T_NUM) return tod(arg); 3454 3457 if (vtype(arg) == T_BOOL) return vdata(arg) ? 1.0 : 0.0; 3455 3458 if (vtype(arg) == T_NULL) return 0.0; 3456 - if (vtype(arg) == T_UNDEF) return NAN; 3459 + if (vtype(arg) == T_UNDEF) return JS_NAN; 3457 3460 3458 3461 if (vtype(arg) == T_STR) { 3459 3462 jsoff_t len, off = vstr(js, arg, &len); ··· 3462 3465 if (!*s) return 0.0; 3463 3466 double val = strtod(s, (char **)&end); 3464 3467 while (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r') end++; 3465 - return (end == s || *end) ? NAN : val; 3468 + return (end == s || *end) ? JS_NAN : val; 3466 3469 } 3467 3470 3468 3471 if (vtype(arg) == T_OBJ || vtype(arg) == T_ARR) { ··· 3473 3476 } 3474 3477 3475 3478 jsval_t str_val = js_tostring_val(js, arg); 3476 - if (is_err(str_val) || vtype(str_val) != T_STR) return NAN; 3479 + if (is_err(str_val) || vtype(str_val) != T_STR) return JS_NAN; 3477 3480 return js_to_number(js, str_val); 3478 3481 } 3479 3482 3480 - return NAN; 3483 + return JS_NAN; 3481 3484 } 3482 3485 3483 3486 static jsval_t setup_func_prototype(struct js *js, jsval_t func) { ··· 3646 3649 unsigned long idx = 0; 3647 3650 3648 3651 if (vtype(obj) == T_ARR && klen > 0 && key[0] >= '0' && key[0] <= '9') { 3649 - char *endptr; 3650 - idx = strtoul(key, &endptr, 10); 3651 - if (endptr == key + klen) { 3652 - jsoff_t len_off = lkp_interned(js, obj, INTERN_LENGTH, 6); 3653 - jsoff_t cur_len = 0; 3654 - if (len_off != 0) { 3655 - jsval_t len_val = resolveprop(js, mkval(T_PROP, len_off)); 3656 - if (vtype(len_val) == T_NUM) cur_len = (jsoff_t) tod(len_val); 3652 + char *inner_endptr; 3653 + idx = strtoul(key, &inner_endptr, 10); 3654 + if (inner_endptr == key + klen) { 3655 + jsoff_t inner_len_off = lkp_interned(js, obj, INTERN_LENGTH, 6); 3656 + jsoff_t inner_cur_len = 0; 3657 + if (inner_len_off != 0) { 3658 + jsval_t len_val = resolveprop(js, mkval(T_PROP, inner_len_off)); 3659 + if (vtype(len_val) == T_NUM) inner_cur_len = (jsoff_t) tod(len_val); 3657 3660 } 3658 - if (idx >= cur_len) need_length_update = 1; 3661 + if (idx >= inner_cur_len) need_length_update = 1; 3659 3662 } 3660 3663 } 3661 3664 3662 3665 jsval_t result = mkprop(js, obj, k, v, 0); 3663 3666 3664 3667 if (need_length_update) { 3665 - jsoff_t len_off = lkp_interned(js, obj, INTERN_LENGTH, 6); 3666 - jsval_t len_key = js_mkstr(js, "length", 6); 3667 - jsval_t new_len = tov((double)(idx + 1)); 3668 - if (len_off != 0) { 3669 - saveval(js, len_off + sizeof(jsoff_t) * 2, new_len); 3670 - } else mkprop(js, obj, len_key, new_len, 0); 3668 + jsoff_t inner_len_off = lkp_interned(js, obj, INTERN_LENGTH, 6); 3669 + jsval_t inner_len_key = js_mkstr(js, "length", 6); 3670 + jsval_t inner_new_len = tov((double)(idx + 1)); 3671 + if (inner_len_off != 0) { 3672 + saveval(js, inner_len_off + sizeof(jsoff_t) * 2, inner_new_len); 3673 + } else mkprop(js, obj, inner_len_key, inner_new_len, 0); 3671 3674 } 3672 3675 3673 3676 return result; ··· 3838 3841 3839 3842 LH: { 3840 3843 bool lt; 3841 - int u = is_unicode_space((const unsigned char *)p, end - p, &lt); 3844 + int u = is_unicode_space((const unsigned char *)p, (jsoff_t)(end - p), &lt); 3842 3845 if (u > 0) { 3843 3846 if (lt) saw_nl = true; 3844 3847 p += u; ··· 3850 3853 3851 3854 L0: 3852 3855 if (nl) *nl = saw_nl; 3853 - return p - code; 3856 + return (jsoff_t)(p - code); 3854 3857 } 3855 3858 3856 3859 #define K(s, t) if (len == sizeof(s)-1 && !memcmp(buf, s, sizeof(s)-1)) return t ··· 4141 4144 } 4142 4145 4143 4146 if (depth == target_depth) { 4144 - if (c == 'f' && is_function_keyword(code, pos, len)) return true; 4145 - if (c == 'a' && is_async_function(code, pos, len)) return true; 4147 + if (c == 'f' && is_function_keyword(code, (jsoff_t)pos, (jsoff_t)len)) return true; 4148 + if (c == 'a' && is_async_function(code, (jsoff_t)pos, (jsoff_t)len)) return true; 4146 4149 } 4147 4150 4148 4151 pos++; ··· 4226 4229 size_t si = 0, di = 0; 4227 4230 while (si < srclen && di + 4 < dstlen) { 4228 4231 uint32_t cp; 4229 - int el = parse_unicode_escape(src, srclen, si, &cp); 4232 + int el = parse_unicode_escape(src, (jsoff_t)srclen, (jsoff_t)si, &cp); 4230 4233 if (el > 0) { 4231 4234 di += encode_utf8(cp, dst + di); 4232 4235 si += el; ··· 4485 4488 } 4486 4489 4487 4490 if (b == NULL || q < b) { 4488 - i = (q - buf) + 1; 4491 + i = (jsoff_t)((q - buf) + 1); 4489 4492 js->tok = TOK_STRING; 4490 4493 js->tlen = i; 4491 4494 return TOK_STRING; 4492 4495 } 4493 4496 4494 - jsoff_t esc_pos = b - buf; 4497 + jsoff_t esc_pos = (jsoff_t)(b - buf); 4495 4498 if (esc_pos + 1 >= rem) { 4496 4499 js->tok = TOK_ERR; 4497 4500 js->tlen = rem; ··· 4541 4544 } 4542 4545 4543 4546 if (b == NULL || q < b) { 4544 - i = (q - buf) + 1; 4547 + i = (jsoff_t)((q - buf) + 1); 4545 4548 js->tok = TOK_TEMPLATE; 4546 4549 js->tlen = i; 4547 4550 return TOK_TEMPLATE; 4548 4551 } 4549 4552 4550 - jsoff_t esc_pos = b - buf; 4553 + jsoff_t esc_pos = (jsoff_t)(b - buf); 4551 4554 i = esc_pos + 2; 4552 4555 if (i > rem) { 4553 4556 js->tok = TOK_ERR; ··· 5326 5329 jsoff_t ctor_off = lkp_scope(js, js->scope, name, len); 5327 5330 5328 5331 if (ctor_off == 0 && global_scope_stack) { 5329 - int stack_len = utarray_len(global_scope_stack); 5330 - for (int i = stack_len - 1; i >= 0 && ctor_off == 0; i--) { 5331 - jsoff_t *scope_off = (jsoff_t *)utarray_eltptr(global_scope_stack, i); 5332 + unsigned int stack_len = utarray_len(global_scope_stack); 5333 + for (int i = (int)stack_len - 1; i >= 0 && ctor_off == 0; i--) { 5334 + jsoff_t *scope_off = (jsoff_t *)utarray_eltptr(global_scope_stack, (unsigned int)i); 5332 5335 jsval_t scope = mkval(T_OBJ, *scope_off); 5333 5336 ctor_off = lkp_scope(js, scope, name, len); 5334 5337 } ··· 5486 5489 return mkval(T_PROP, off); 5487 5490 } 5488 5491 5489 - jsval_t with_slot = get_slot(js, scope, SLOT_WITH); 5490 - if (vtype(with_slot) != T_UNDEF) { 5492 + jsval_t scope_with_slot = get_slot(js, scope, SLOT_WITH); 5493 + if (vtype(scope_with_slot) != T_UNDEF) { 5491 5494 jsval_t with_obj = ( 5492 - vtype(with_slot) == T_OBJ || 5493 - vtype(with_slot) == T_ARR || 5494 - vtype(with_slot) == T_FUNC) ? 5495 - with_slot : mkval(T_OBJ, vdata(with_slot) 5495 + vtype(scope_with_slot) == T_OBJ || 5496 + vtype(scope_with_slot) == T_ARR || 5497 + vtype(scope_with_slot) == T_FUNC) ? 5498 + scope_with_slot : mkval(T_OBJ, vdata(scope_with_slot) 5496 5499 ); 5497 5500 5498 5501 jsoff_t prop_off = lkp_interned(js, with_obj, key_intern, key_len); ··· 5511 5514 jsoff_t *root_off = (jsoff_t *)utarray_eltptr(global_scope_stack, 0); 5512 5515 if (root_off && *root_off != 0) { 5513 5516 jsval_t root_scope = mkval(T_OBJ, *root_off); 5514 - jsoff_t off = lkp(js, root_scope, key_str, key_len); 5515 - if (off != 0) return mkval(T_PROP, off); 5517 + jsoff_t root_lkp_off = lkp(js, root_scope, key_str, key_len); 5518 + if (root_lkp_off != 0) return mkval(T_PROP, root_lkp_off); 5516 5519 } 5517 5520 } 5518 5521 ··· 5839 5842 } 5840 5843 } 5841 5844 if (vtype(obj) == T_STR) { 5842 - double idx_d = NAN; 5845 + double idx_d = JS_NAN; 5843 5846 if (vtype(key_val) == T_NUM) { 5844 5847 idx_d = tod(key_val); 5845 5848 } else { ··· 5849 5852 memcpy(temp, keystr, copy_len); 5850 5853 temp[copy_len] = '\0'; 5851 5854 idx_d = strtod(temp, &endptr); 5852 - if (endptr == temp || *endptr != '\0') idx_d = NAN; 5855 + if (endptr == temp || *endptr != '\0') idx_d = JS_NAN; 5853 5856 } 5854 5857 if (!isnan(idx_d) && idx_d >= 0 && idx_d == (double)(long)idx_d) { 5855 5858 jsoff_t idx = (jsoff_t) idx_d; ··· 6524 6527 6525 6528 int argi = 0; 6526 6529 for (int i = 0; i < pf->param_count; i++) { 6527 - parsed_param_t *pp = (parsed_param_t *)utarray_eltptr(pf->params, i); 6530 + parsed_param_t *pp = (parsed_param_t *)utarray_eltptr(pf->params, (unsigned int)i); 6528 6531 6529 6532 if (pp->is_destruct) { 6530 6533 jsval_t arg_val = (argi < argc) ? args[argi++] : js_mkundef(); ··· 6837 6840 if (fnpos < fnlen && fn[fnpos] == ')') fnpos++; 6838 6841 fnpos = skiptonext(fn, fnlen, fnpos, NULL); 6839 6842 if (fnpos < fnlen && fn[fnpos] == '{') fnpos++; 6840 - size_t body_len = fnlen - fnpos - 1; 6843 + jsoff_t body_len = fnlen - fnpos - 1; 6841 6844 6842 6845 bool func_strict = is_strict_function_body(&fn[fnpos], body_len); 6843 6846 if (code_uses_arguments(&fn[fnpos], body_len)) { ··· 6985 6988 } 6986 6989 } else { 6987 6990 jsval_t builtin_slot = get_slot(js, func_obj, SLOT_BUILTIN); 6988 - if (vtype(builtin_slot) == T_NUM && tod(builtin_slot) == BUILTIN_OBJECT) res = call_c(js, builtin_Object); else { 6991 + if (vtype(builtin_slot) == T_NUM && (int)tod(builtin_slot) == BUILTIN_OBJECT) res = call_c(js, builtin_Object); else { 6989 6992 jsoff_t fnlen; 6990 6993 6991 6994 const char *code_str = get_func_code(js, func_obj, &fnlen); ··· 7205 7208 js->this_val = saved_this; 7206 7209 if (vtype(result) == T_STR) return result; 7207 7210 7208 - uint8_t rt = vtype(result); 7209 - if (rt != T_OBJ && rt != T_ARR && rt != T_FUNC) { 7211 + uint8_t rtype = vtype(result); 7212 + if (rtype != T_OBJ && rtype != T_ARR && rtype != T_FUNC) { 7210 7213 char buf[256]; 7211 7214 size_t len = tostr(js, result, buf, sizeof(buf)); 7212 7215 return js_mkstr(js, buf, len); ··· 7357 7360 L_TOK_EQ: 7358 7361 L_TOK_NE: { 7359 7362 bool eq = false; 7360 - uint8_t lt = vtype(l), rt = vtype(r); 7363 + uint8_t lt = vtype(l), rtype = vtype(r); 7361 7364 7362 - if ((lt == T_NULL && rt == T_NULL) || (lt == T_UNDEF && rt == T_UNDEF) || 7363 - (lt == T_UNDEF && rt == T_NULL) || (lt == T_NULL && rt == T_UNDEF)) { 7365 + if ((lt == T_NULL && rtype == T_NULL) || (lt == T_UNDEF && rtype == T_UNDEF) || 7366 + (lt == T_UNDEF && rtype == T_NULL) || (lt == T_NULL && rtype == T_UNDEF)) { 7364 7367 eq = true; 7365 - } else if (lt == T_NULL || rt == T_NULL || lt == T_UNDEF || rt == T_UNDEF) { 7368 + } else if (lt == T_NULL || rtype == T_NULL || lt == T_UNDEF || rtype == T_UNDEF) { 7366 7369 eq = false; 7367 - } else if (lt == rt) { 7370 + } else if (lt == rtype) { 7368 7371 eq = strict_eq_values(js, l, r); 7369 - } else if ((lt == T_BIGINT && rt == T_NUM) || (lt == T_NUM && rt == T_BIGINT)) { 7372 + } else if ((lt == T_BIGINT && rtype == T_NUM) || (lt == T_NUM && rtype == T_BIGINT)) { 7370 7373 double num_val = lt == T_NUM ? tod(l) : tod(r); 7371 7374 jsval_t bigint_val = lt == T_BIGINT ? l : r; 7372 7375 if (isfinite(num_val) && num_val == trunc(num_val)) { ··· 7378 7381 } 7379 7382 } else if (lt == T_BOOL) { 7380 7383 return do_op(js, op, tov(vdata(l) ? 1.0 : 0.0), r); 7381 - } else if (rt == T_BOOL) { 7384 + } else if (rtype == T_BOOL) { 7382 7385 return do_op(js, op, l, tov(vdata(r) ? 1.0 : 0.0)); 7383 - } else if ((lt == T_NUM && rt == T_STR) || (lt == T_STR && rt == T_NUM)) { 7386 + } else if ((lt == T_NUM && rtype == T_STR) || (lt == T_STR && rtype == T_NUM)) { 7384 7387 eq = js_to_number(js, l) == js_to_number(js, r); 7385 7388 } else if (lt == T_ARR || lt == T_OBJ) { 7386 7389 jsval_t l_prim = js_tostring_val(js, l); 7387 7390 if (!is_err(l_prim)) return do_op(js, op, l_prim, r); 7388 - } else if (rt == T_ARR || rt == T_OBJ) { 7391 + } else if (rtype == T_ARR || rtype == T_OBJ) { 7389 7392 jsval_t r_prim = js_tostring_val(js, r); 7390 7393 if (!is_err(r_prim)) return do_op(js, op, l, r_prim); 7391 7394 } ··· 7413 7416 L_TOK_DIV: 7414 7417 L_TOK_REM: 7415 7418 L_TOK_EXP: { 7416 - uint8_t lt = vtype(l), rt = vtype(r); 7417 - if (lt == T_NUM && rt == T_NUM) { 7419 + uint8_t lt = vtype(l), rtype = vtype(r); 7420 + if (lt == T_NUM && rtype == T_NUM) { 7418 7421 double a = tod(l), b = tod(r); 7419 7422 switch (op) { 7420 7423 case TOK_MINUS: return tov(a - b); ··· 7424 7427 case TOK_EXP: return tov(pow(a, b)); 7425 7428 } 7426 7429 } 7427 - if (lt == T_BIGINT && rt == T_BIGINT) { 7430 + if (lt == T_BIGINT && rtype == T_BIGINT) { 7428 7431 switch (op) { 7429 7432 case TOK_MINUS: return bigint_sub(js, l, r); 7430 7433 case TOK_MUL: return bigint_mul(js, l, r); ··· 7433 7436 case TOK_EXP: return bigint_exp(js, l, r); 7434 7437 } 7435 7438 } 7436 - if (lt == T_BIGINT || rt == T_BIGINT) 7439 + if (lt == T_BIGINT || rtype == T_BIGINT) 7437 7440 return js_mkerr(js, "Cannot mix BigInt value and other types"); 7438 7441 double a = js_to_number(js, l), b = js_to_number(js, r); 7439 7442 switch (op) { ··· 7449 7452 L_TOK_LE: 7450 7453 L_TOK_GT: 7451 7454 L_TOK_GE: { 7452 - uint8_t lt = vtype(l), rt = vtype(r); 7453 - if (lt == T_NUM && rt == T_NUM) { 7455 + uint8_t lt = vtype(l), rtype = vtype(r); 7456 + if (lt == T_NUM && rtype == T_NUM) { 7454 7457 double a = tod(l), b = tod(r); 7455 7458 switch (op) { 7456 7459 case TOK_LT: return mkval(T_BOOL, a < b); ··· 7459 7462 case TOK_GE: return mkval(T_BOOL, a >= b); 7460 7463 } 7461 7464 } 7462 - if (lt == T_BIGINT && rt == T_BIGINT) { 7465 + if (lt == T_BIGINT && rtype == T_BIGINT) { 7463 7466 int cmp = bigint_compare(js, l, r); 7464 7467 switch (op) { 7465 7468 case TOK_LT: return mkval(T_BOOL, cmp < 0); ··· 7468 7471 case TOK_GE: return mkval(T_BOOL, cmp >= 0); 7469 7472 } 7470 7473 } 7471 - if (lt == T_BIGINT || rt == T_BIGINT) 7474 + if (lt == T_BIGINT || rtype == T_BIGINT) 7472 7475 return js_mkerr(js, "Cannot mix BigInt value and other types"); 7473 - if (lt == T_STR && rt == T_STR) 7476 + if (lt == T_STR && rtype == T_STR) 7474 7477 return do_string_op(js, op, l, r); 7475 7478 double a = js_to_number(js, l), b = js_to_number(js, r); 7476 7479 switch (op) { ··· 7487 7490 L_TOK_SHL: 7488 7491 L_TOK_SHR: 7489 7492 L_TOK_ZSHR: { 7490 - uint8_t lt = vtype(l), rt = vtype(r); 7491 - if (lt == T_BIGINT || rt == T_BIGINT) 7493 + uint8_t lt = vtype(l), rtype = vtype(r); 7494 + if (lt == T_BIGINT || rtype == T_BIGINT) 7492 7495 return js_mkerr(js, "Cannot mix BigInt value and other types"); 7493 7496 int32_t ai = (lt == T_NUM) ? js_to_int32(tod(l)) : js_to_int32(js_to_number(js, l)); 7494 - uint32_t bi = (rt == T_NUM) ? js_to_uint32(tod(r)) : js_to_uint32(js_to_number(js, r)); 7497 + uint32_t bi = (rtype == T_NUM) ? js_to_uint32(tod(r)) : js_to_uint32(js_to_number(js, r)); 7495 7498 switch (op) { 7496 7499 case TOK_XOR: return tov((double)(ai ^ (int32_t)bi)); 7497 7500 case TOK_AND: return tov((double)(ai & (int32_t)bi)); ··· 7566 7569 7567 7570 if (brace_count != 0) return js_mkerr_typed(js, JS_ERR_SYNTAX, "unclosed ${"); 7568 7571 7569 - jsval_t expr_result = js_eval_str(js, (const char *)&in[expr_start], n - expr_start); 7572 + jsval_t expr_result = js_eval_str(js, (const char *)&in[expr_start], (jsoff_t)(n - expr_start)); 7570 7573 if (is_err(expr_result)) return expr_result; 7571 7574 expr_result = resolveprop(js, expr_result); 7572 7575 ··· 7663 7666 } 7664 7667 if (brace_count != 0) return js_mkerr_typed(js, JS_ERR_SYNTAX, "unclosed ${"); 7665 7668 7666 - jsval_t expr_result = js_eval_str(js, (const char *)&in[expr_start], n - expr_start); 7669 + jsval_t expr_result = js_eval_str(js, (const char *)&in[expr_start], (jsoff_t)(n - expr_start)); 7667 7670 if (is_err(expr_result)) return expr_result; 7668 7671 expr_result = resolveprop(js, expr_result); 7669 7672 values[value_count++] = expr_result; ··· 8715 8718 if (vtype(idx) == T_STR) { 8716 8719 prop_len = 0; prop = (const char *)&js->mem[vstr(js, idx, &prop_len)]; 8717 8720 } else { 8718 - char buf[32]; prop_len = tostr(js, idx, buf, sizeof(buf)); 8721 + char buf[32]; prop_len = (jsoff_t)tostr(js, idx, buf, sizeof(buf)); 8719 8722 prop = buf; 8720 8723 } 8721 8724 } ··· 9852 9855 if (next(js) == TOK_LBRACE) { 9853 9856 is_nested_obj = true; 9854 9857 nested_pattern_start = js->toff; 9855 - int depth = 1; 9858 + int inner_depth = 1; 9856 9859 js->consumed = 1; 9857 - while (depth > 0 && next(js) != TOK_EOF) { 9858 - if (js->tok == TOK_LBRACE) depth++; 9859 - else if (js->tok == TOK_RBRACE) depth--; 9860 - if (depth > 0) js->consumed = 1; 9860 + while (inner_depth > 0 && next(js) != TOK_EOF) { 9861 + if (js->tok == TOK_LBRACE) inner_depth++; 9862 + else if (js->tok == TOK_RBRACE) inner_depth--; 9863 + if (inner_depth > 0) js->consumed = 1; 9861 9864 } 9862 9865 js->consumed = 1; 9863 9866 } else if (next(js) == TOK_LBRACKET) { 9864 9867 is_nested_arr = true; 9865 9868 nested_pattern_start = js->toff; 9866 - int depth = 1; 9869 + int inner_depth = 1; 9867 9870 js->consumed = 1; 9868 - while (depth > 0 && next(js) != TOK_EOF) { 9869 - if (js->tok == TOK_LBRACKET) depth++; 9870 - else if (js->tok == TOK_RBRACKET) depth--; 9871 - if (depth > 0) js->consumed = 1; 9871 + while (inner_depth > 0 && next(js) != TOK_EOF) { 9872 + if (js->tok == TOK_LBRACKET) inner_depth++; 9873 + else if (js->tok == TOK_RBRACKET) inner_depth--; 9874 + if (inner_depth > 0) js->consumed = 1; 9872 9875 } 9873 9876 js->consumed = 1; 9874 9877 } else { ··· 11472 11475 11473 11476 static bool label_exists(const char *name, jsoff_t len, bool check_loop) { 11474 11477 if (!label_stack) return false; 11475 - int depth = utarray_len(label_stack); 11476 - for (int i = depth - 1; i >= 0; i--) { 11477 - label_entry_t *entry = (label_entry_t *)utarray_eltptr(label_stack, i); 11478 + unsigned int depth = utarray_len(label_stack); 11479 + for (int i = (int)depth - 1; i >= 0; i--) { 11480 + label_entry_t *entry = (label_entry_t *)utarray_eltptr(label_stack, (unsigned int)i); 11478 11481 if (entry && entry->name_len == len && 11479 11482 memcmp(entry->name, name, len) == 0) { 11480 11483 if (check_loop && !entry->is_loop) { ··· 11491 11494 if (!label_stack || !continue_target_label) return false; 11492 11495 if (marker_index <= 0) return false; 11493 11496 11494 - label_entry_t *entry = (label_entry_t *)utarray_eltptr(label_stack, marker_index - 1); 11497 + label_entry_t *entry = (label_entry_t *)utarray_eltptr(label_stack, (unsigned int)(marker_index - 1)); 11495 11498 if (!entry) return false; 11496 11499 if (entry->name == NULL) return false; 11497 11500 if (!entry->is_loop) return false; ··· 11534 11537 if (!(js->flags & (F_LOOP | F_SWITCH))) { 11535 11538 bool in_labeled_block = false; 11536 11539 if (label_stack) { 11537 - int depth = utarray_len(label_stack); 11538 - for (int i = depth - 1; i >= 0; i--) { 11539 - label_entry_t *entry = (label_entry_t *)utarray_eltptr(label_stack, i); 11540 + unsigned int depth = utarray_len(label_stack); 11541 + for (int i = (int)depth - 1; i >= 0; i--) { 11542 + label_entry_t *entry = (label_entry_t *)utarray_eltptr(label_stack, (unsigned int)i); 11540 11543 if (entry && entry->is_block) { 11541 11544 in_labeled_block = true; 11542 11545 break; ··· 12259 12262 set_slot(js, method_obj, SLOT_SCOPE, func_scope); 12260 12263 if (super_len > 0) set_slot(js, method_obj, SLOT_SUPER, super_constructor); 12261 12264 12262 - jsval_t func_proto = get_slot(js, js_glob(js), SLOT_FUNC_PROTO); 12263 - if (vtype(func_proto) == T_FUNC) set_proto(js, method_obj, func_proto); 12265 + jsval_t method_func_proto = get_slot(js, js_glob(js), SLOT_FUNC_PROTO); 12266 + if (vtype(method_func_proto) == T_FUNC) set_proto(js, method_obj, method_func_proto); 12264 12267 12265 12268 jsval_t method_func = mkval(T_FUNC, (unsigned long) vdata(method_obj)); 12266 12269 jsval_t set_res = setprop(js, func_obj, member_name, method_func); ··· 13665 13668 13666 13669 static jsval_t builtin_Date_UTC(struct js *js, jsval_t *args, int nargs) { 13667 13670 (void) js; 13668 - if (nargs < 1) return tov(NAN); 13671 + if (nargs < 1) return tov(JS_NAN); 13669 13672 13670 13673 int year = (int)tod(args[0]); 13671 13674 int month = nargs >= 2 ? (int)tod(args[1]) : 0; ··· 13691 13694 13692 13695 static double date_get_time(struct js *js, jsval_t this_val) { 13693 13696 jsval_t time_val = js_get_slot(js, this_val, SLOT_DATA); 13694 - if (vtype(time_val) != T_NUM) return NAN; 13697 + if (vtype(time_val) != T_NUM) return JS_NAN; 13695 13698 return tod(time_val); 13696 13699 } 13697 13700 ··· 13705 13708 (void) args; 13706 13709 (void) nargs; 13707 13710 double ms = date_get_time(js, js->this_val); 13708 - if (isnan(ms)) return tov(NAN); 13711 + if (isnan(ms)) return tov(JS_NAN); 13709 13712 time_t t = (time_t)(ms / 1000.0); 13710 13713 struct tm *tm = localtime(&t); 13711 13714 return tov((double)(tm->tm_year + 1900)); ··· 13715 13718 (void) args; 13716 13719 (void) nargs; 13717 13720 double ms = date_get_time(js, js->this_val); 13718 - if (isnan(ms)) return tov(NAN); 13721 + if (isnan(ms)) return tov(JS_NAN); 13719 13722 time_t t = (time_t)(ms / 1000.0); 13720 13723 struct tm *tm = localtime(&t); 13721 13724 return tov((double)tm->tm_mon); ··· 13725 13728 (void) args; 13726 13729 (void) nargs; 13727 13730 double ms = date_get_time(js, js->this_val); 13728 - if (isnan(ms)) return tov(NAN); 13731 + if (isnan(ms)) return tov(JS_NAN); 13729 13732 time_t t = (time_t)(ms / 1000.0); 13730 13733 struct tm *tm = localtime(&t); 13731 13734 return tov((double)tm->tm_mday); ··· 13735 13738 (void) args; 13736 13739 (void) nargs; 13737 13740 double ms = date_get_time(js, js->this_val); 13738 - if (isnan(ms)) return tov(NAN); 13741 + if (isnan(ms)) return tov(JS_NAN); 13739 13742 time_t t = (time_t)(ms / 1000.0); 13740 13743 struct tm *tm = localtime(&t); 13741 13744 return tov((double)tm->tm_hour); ··· 13745 13748 (void) args; 13746 13749 (void) nargs; 13747 13750 double ms = date_get_time(js, js->this_val); 13748 - if (isnan(ms)) return tov(NAN); 13751 + if (isnan(ms)) return tov(JS_NAN); 13749 13752 time_t t = (time_t)(ms / 1000.0); 13750 13753 struct tm *tm = localtime(&t); 13751 13754 return tov((double)tm->tm_min); ··· 13755 13758 (void) args; 13756 13759 (void) nargs; 13757 13760 double ms = date_get_time(js, js->this_val); 13758 - if (isnan(ms)) return tov(NAN); 13761 + if (isnan(ms)) return tov(JS_NAN); 13759 13762 time_t t = (time_t)(ms / 1000.0); 13760 13763 struct tm *tm = localtime(&t); 13761 13764 return tov((double)tm->tm_sec); ··· 13765 13768 (void) args; 13766 13769 (void) nargs; 13767 13770 double ms = date_get_time(js, js->this_val); 13768 - if (isnan(ms)) return tov(NAN); 13771 + if (isnan(ms)) return tov(JS_NAN); 13769 13772 return tov(fmod(ms, 1000.0)); 13770 13773 } 13771 13774 ··· 13773 13776 (void) args; 13774 13777 (void) nargs; 13775 13778 double ms = date_get_time(js, js->this_val); 13776 - if (isnan(ms)) return tov(NAN); 13779 + if (isnan(ms)) return tov(JS_NAN); 13777 13780 time_t t = (time_t)(ms / 1000.0); 13778 13781 struct tm *tm = localtime(&t); 13779 13782 return tov((double)tm->tm_wday); ··· 13817 13820 (void) args; 13818 13821 (void) nargs; 13819 13822 double ms = date_get_time(js, js->this_val); 13820 - if (isnan(ms)) return tov(NAN); 13823 + if (isnan(ms)) return tov(JS_NAN); 13821 13824 time_t t = (time_t)(ms / 1000.0); 13822 13825 struct tm *local = localtime(&t); 13823 13826 struct tm *utc = gmtime(&t); ··· 13832 13835 (void) args; 13833 13836 (void) nargs; 13834 13837 double ms = date_get_time(js, js->this_val); 13835 - if (isnan(ms)) return tov(NAN); 13838 + if (isnan(ms)) return tov(JS_NAN); 13836 13839 time_t t = (time_t)(ms / 1000.0); 13837 13840 struct tm *tm = gmtime(&t); 13838 13841 return tov((double)(tm->tm_year + 1900)); ··· 13842 13845 (void) args; 13843 13846 (void) nargs; 13844 13847 double ms = date_get_time(js, js->this_val); 13845 - if (isnan(ms)) return tov(NAN); 13848 + if (isnan(ms)) return tov(JS_NAN); 13846 13849 time_t t = (time_t)(ms / 1000.0); 13847 13850 struct tm *tm = gmtime(&t); 13848 13851 return tov((double)tm->tm_mon); ··· 13852 13855 (void) args; 13853 13856 (void) nargs; 13854 13857 double ms = date_get_time(js, js->this_val); 13855 - if (isnan(ms)) return tov(NAN); 13858 + if (isnan(ms)) return tov(JS_NAN); 13856 13859 time_t t = (time_t)(ms / 1000.0); 13857 13860 struct tm *tm = gmtime(&t); 13858 13861 return tov((double)tm->tm_mday); ··· 13862 13865 (void) args; 13863 13866 (void) nargs; 13864 13867 double ms = date_get_time(js, js->this_val); 13865 - if (isnan(ms)) return tov(NAN); 13868 + if (isnan(ms)) return tov(JS_NAN); 13866 13869 time_t t = (time_t)(ms / 1000.0); 13867 13870 struct tm *tm = gmtime(&t); 13868 13871 return tov((double)tm->tm_hour); ··· 13872 13875 (void) args; 13873 13876 (void) nargs; 13874 13877 double ms = date_get_time(js, js->this_val); 13875 - if (isnan(ms)) return tov(NAN); 13878 + if (isnan(ms)) return tov(JS_NAN); 13876 13879 time_t t = (time_t)(ms / 1000.0); 13877 13880 struct tm *tm = gmtime(&t); 13878 13881 return tov((double)tm->tm_min); ··· 13882 13885 (void) args; 13883 13886 (void) nargs; 13884 13887 double ms = date_get_time(js, js->this_val); 13885 - if (isnan(ms)) return tov(NAN); 13888 + if (isnan(ms)) return tov(JS_NAN); 13886 13889 time_t t = (time_t)(ms / 1000.0); 13887 13890 struct tm *tm = gmtime(&t); 13888 13891 return tov((double)tm->tm_sec); ··· 13892 13895 (void) args; 13893 13896 (void) nargs; 13894 13897 double ms = date_get_time(js, js->this_val); 13895 - if (isnan(ms)) return tov(NAN); 13898 + if (isnan(ms)) return tov(JS_NAN); 13896 13899 return tov(fmod(ms, 1000.0)); 13897 13900 } 13898 13901 ··· 13900 13903 (void) args; 13901 13904 (void) nargs; 13902 13905 double ms = date_get_time(js, js->this_val); 13903 - if (isnan(ms)) return tov(NAN); 13906 + if (isnan(ms)) return tov(JS_NAN); 13904 13907 time_t t = (time_t)(ms / 1000.0); 13905 13908 struct tm *tm = gmtime(&t); 13906 13909 return tov((double)tm->tm_wday); ··· 13912 13915 } 13913 13916 13914 13917 static jsval_t builtin_Date_setTime(struct js *js, jsval_t *args, int nargs) { 13915 - if (nargs < 1) return tov(NAN); 13918 + if (nargs < 1) return tov(JS_NAN); 13916 13919 double ms = tod(args[0]); 13917 13920 date_set_time(js, js->this_val, ms); 13918 13921 return tov(ms); 13919 13922 } 13920 13923 13921 13924 static jsval_t builtin_Date_setMilliseconds(struct js *js, jsval_t *args, int nargs) { 13922 - if (nargs < 1) return tov(NAN); 13925 + if (nargs < 1) return tov(JS_NAN); 13923 13926 double ms = date_get_time(js, js->this_val); 13924 - if (isnan(ms)) return tov(NAN); 13927 + if (isnan(ms)) return tov(JS_NAN); 13925 13928 double newMs = tod(args[0]); 13926 13929 ms = floor(ms / 1000.0) * 1000.0 + newMs; 13927 13930 date_set_time(js, js->this_val, ms); ··· 13929 13932 } 13930 13933 13931 13934 static jsval_t builtin_Date_setSeconds(struct js *js, jsval_t *args, int nargs) { 13932 - if (nargs < 1) return tov(NAN); 13935 + if (nargs < 1) return tov(JS_NAN); 13933 13936 double ms = date_get_time(js, js->this_val); 13934 - if (isnan(ms)) return tov(NAN); 13937 + if (isnan(ms)) return tov(JS_NAN); 13935 13938 time_t t = (time_t)(ms / 1000.0); 13936 13939 struct tm *tm = localtime(&t); 13937 13940 tm->tm_sec = (int)tod(args[0]); ··· 13944 13947 } 13945 13948 13946 13949 static jsval_t builtin_Date_setMinutes(struct js *js, jsval_t *args, int nargs) { 13947 - if (nargs < 1) return tov(NAN); 13950 + if (nargs < 1) return tov(JS_NAN); 13948 13951 double ms = date_get_time(js, js->this_val); 13949 - if (isnan(ms)) return tov(NAN); 13952 + if (isnan(ms)) return tov(JS_NAN); 13950 13953 time_t t = (time_t)(ms / 1000.0); 13951 13954 struct tm *tm = localtime(&t); 13952 13955 tm->tm_min = (int)tod(args[0]); ··· 13958 13961 } 13959 13962 13960 13963 static jsval_t builtin_Date_setHours(struct js *js, jsval_t *args, int nargs) { 13961 - if (nargs < 1) return tov(NAN); 13964 + if (nargs < 1) return tov(JS_NAN); 13962 13965 double ms = date_get_time(js, js->this_val); 13963 - if (isnan(ms)) return tov(NAN); 13966 + if (isnan(ms)) return tov(JS_NAN); 13964 13967 time_t t = (time_t)(ms / 1000.0); 13965 13968 struct tm *tm = localtime(&t); 13966 13969 tm->tm_hour = (int)tod(args[0]); ··· 13973 13976 } 13974 13977 13975 13978 static jsval_t builtin_Date_setDate(struct js *js, jsval_t *args, int nargs) { 13976 - if (nargs < 1) return tov(NAN); 13979 + if (nargs < 1) return tov(JS_NAN); 13977 13980 double ms = date_get_time(js, js->this_val); 13978 - if (isnan(ms)) return tov(NAN); 13981 + if (isnan(ms)) return tov(JS_NAN); 13979 13982 time_t t = (time_t)(ms / 1000.0); 13980 13983 struct tm *tm = localtime(&t); 13981 13984 tm->tm_mday = (int)tod(args[0]); ··· 13986 13989 } 13987 13990 13988 13991 static jsval_t builtin_Date_setMonth(struct js *js, jsval_t *args, int nargs) { 13989 - if (nargs < 1) return tov(NAN); 13992 + if (nargs < 1) return tov(JS_NAN); 13990 13993 double ms = date_get_time(js, js->this_val); 13991 - if (isnan(ms)) return tov(NAN); 13994 + if (isnan(ms)) return tov(JS_NAN); 13992 13995 time_t t = (time_t)(ms / 1000.0); 13993 13996 struct tm *tm = localtime(&t); 13994 13997 tm->tm_mon = (int)tod(args[0]); ··· 14000 14003 } 14001 14004 14002 14005 static jsval_t builtin_Date_setFullYear(struct js *js, jsval_t *args, int nargs) { 14003 - if (nargs < 1) return tov(NAN); 14006 + if (nargs < 1) return tov(JS_NAN); 14004 14007 double ms = date_get_time(js, js->this_val); 14005 14008 if (isnan(ms)) ms = 0; 14006 14009 time_t t = (time_t)(ms / 1000.0); ··· 14015 14018 } 14016 14019 14017 14020 static jsval_t builtin_Date_setUTCMilliseconds(struct js *js, jsval_t *args, int nargs) { 14018 - if (nargs < 1) return tov(NAN); 14021 + if (nargs < 1) return tov(JS_NAN); 14019 14022 double ms = date_get_time(js, js->this_val); 14020 - if (isnan(ms)) return tov(NAN); 14023 + if (isnan(ms)) return tov(JS_NAN); 14021 14024 double newMs = tod(args[0]); 14022 14025 ms = floor(ms / 1000.0) * 1000.0 + newMs; 14023 14026 date_set_time(js, js->this_val, ms); ··· 14025 14028 } 14026 14029 14027 14030 static jsval_t builtin_Date_setUTCSeconds(struct js *js, jsval_t *args, int nargs) { 14028 - if (nargs < 1) return tov(NAN); 14031 + if (nargs < 1) return tov(JS_NAN); 14029 14032 double ms = date_get_time(js, js->this_val); 14030 - if (isnan(ms)) return tov(NAN); 14033 + if (isnan(ms)) return tov(JS_NAN); 14031 14034 time_t t = (time_t)(ms / 1000.0); 14032 14035 struct tm *tm = gmtime(&t); 14033 14036 struct tm copy = *tm; ··· 14039 14042 } 14040 14043 14041 14044 static jsval_t builtin_Date_setUTCMinutes(struct js *js, jsval_t *args, int nargs) { 14042 - if (nargs < 1) return tov(NAN); 14045 + if (nargs < 1) return tov(JS_NAN); 14043 14046 double ms = date_get_time(js, js->this_val); 14044 - if (isnan(ms)) return tov(NAN); 14047 + if (isnan(ms)) return tov(JS_NAN); 14045 14048 time_t t = (time_t)(ms / 1000.0); 14046 14049 struct tm *tm = gmtime(&t); 14047 14050 struct tm copy = *tm; ··· 14054 14057 } 14055 14058 14056 14059 static jsval_t builtin_Date_setUTCHours(struct js *js, jsval_t *args, int nargs) { 14057 - if (nargs < 1) return tov(NAN); 14060 + if (nargs < 1) return tov(JS_NAN); 14058 14061 double ms = date_get_time(js, js->this_val); 14059 - if (isnan(ms)) return tov(NAN); 14062 + if (isnan(ms)) return tov(JS_NAN); 14060 14063 time_t t = (time_t)(ms / 1000.0); 14061 14064 struct tm *tm = gmtime(&t); 14062 14065 struct tm copy = *tm; ··· 14070 14073 } 14071 14074 14072 14075 static jsval_t builtin_Date_setUTCDate(struct js *js, jsval_t *args, int nargs) { 14073 - if (nargs < 1) return tov(NAN); 14076 + if (nargs < 1) return tov(JS_NAN); 14074 14077 double ms = date_get_time(js, js->this_val); 14075 - if (isnan(ms)) return tov(NAN); 14078 + if (isnan(ms)) return tov(JS_NAN); 14076 14079 time_t t = (time_t)(ms / 1000.0); 14077 14080 struct tm *tm = gmtime(&t); 14078 14081 struct tm copy = *tm; ··· 14084 14087 } 14085 14088 14086 14089 static jsval_t builtin_Date_setUTCMonth(struct js *js, jsval_t *args, int nargs) { 14087 - if (nargs < 1) return tov(NAN); 14090 + if (nargs < 1) return tov(JS_NAN); 14088 14091 double ms = date_get_time(js, js->this_val); 14089 - if (isnan(ms)) return tov(NAN); 14092 + if (isnan(ms)) return tov(JS_NAN); 14090 14093 time_t t = (time_t)(ms / 1000.0); 14091 14094 struct tm *tm = gmtime(&t); 14092 14095 struct tm copy = *tm; ··· 14099 14102 } 14100 14103 14101 14104 static jsval_t builtin_Date_setUTCFullYear(struct js *js, jsval_t *args, int nargs) { 14102 - if (nargs < 1) return tov(NAN); 14105 + if (nargs < 1) return tov(JS_NAN); 14103 14106 double ms = date_get_time(js, js->this_val); 14104 14107 if (isnan(ms)) ms = 0; 14105 14108 time_t t = (time_t)(ms / 1000.0); ··· 14189 14192 (void) args; 14190 14193 (void) nargs; 14191 14194 double ms = date_get_time(js, js->this_val); 14192 - if (isnan(ms)) return tov(NAN); 14195 + if (isnan(ms)) return tov(JS_NAN); 14193 14196 time_t t = (time_t)(ms / 1000.0); 14194 14197 struct tm *tm = localtime(&t); 14195 14198 return tov((double)(tm->tm_year)); 14196 14199 } 14197 14200 14198 14201 static jsval_t builtin_Date_setYear(struct js *js, jsval_t *args, int nargs) { 14199 - if (nargs < 1) return tov(NAN); 14202 + if (nargs < 1) return tov(JS_NAN); 14200 14203 double year_arg = tod(args[0]); 14201 14204 if (isnan(year_arg)) { 14202 - date_set_time(js, js->this_val, NAN); 14203 - return tov(NAN); 14205 + date_set_time(js, js->this_val, JS_NAN); 14206 + return tov(JS_NAN); 14204 14207 } 14205 14208 int year = (int)year_arg; 14206 14209 if (year >= 0 && year <= 99) year += 1900; ··· 14234 14237 14235 14238 static jsval_t builtin_Math_abs(struct js *js, jsval_t *args, int nargs) { 14236 14239 (void) js; 14237 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14240 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14238 14241 return tov(fabs(tod(args[0]))); 14239 14242 } 14240 14243 14241 14244 static jsval_t builtin_Math_acos(struct js *js, jsval_t *args, int nargs) { 14242 14245 (void) js; 14243 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14246 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14244 14247 return tov(acos(tod(args[0]))); 14245 14248 } 14246 14249 14247 14250 static jsval_t builtin_Math_acosh(struct js *js, jsval_t *args, int nargs) { 14248 14251 (void) js; 14249 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14252 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14250 14253 return tov(acosh(tod(args[0]))); 14251 14254 } 14252 14255 14253 14256 static jsval_t builtin_Math_asin(struct js *js, jsval_t *args, int nargs) { 14254 14257 (void) js; 14255 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14258 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14256 14259 return tov(asin(tod(args[0]))); 14257 14260 } 14258 14261 14259 14262 static jsval_t builtin_Math_asinh(struct js *js, jsval_t *args, int nargs) { 14260 14263 (void) js; 14261 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14264 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14262 14265 return tov(asinh(tod(args[0]))); 14263 14266 } 14264 14267 14265 14268 static jsval_t builtin_Math_atan(struct js *js, jsval_t *args, int nargs) { 14266 14269 (void) js; 14267 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14270 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14268 14271 return tov(atan(tod(args[0]))); 14269 14272 } 14270 14273 14271 14274 static jsval_t builtin_Math_atanh(struct js *js, jsval_t *args, int nargs) { 14272 14275 (void) js; 14273 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14276 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14274 14277 return tov(atanh(tod(args[0]))); 14275 14278 } 14276 14279 14277 14280 static jsval_t builtin_Math_atan2(struct js *js, jsval_t *args, int nargs) { 14278 14281 (void) js; 14279 - if (nargs < 2 || vtype(args[0]) != T_NUM || vtype(args[1]) != T_NUM) return tov(NAN); 14282 + if (nargs < 2 || vtype(args[0]) != T_NUM || vtype(args[1]) != T_NUM) return tov(JS_NAN); 14280 14283 return tov(atan2(tod(args[0]), tod(args[1]))); 14281 14284 } 14282 14285 14283 14286 static jsval_t builtin_Math_cbrt(struct js *js, jsval_t *args, int nargs) { 14284 14287 (void) js; 14285 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14288 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14286 14289 return tov(cbrt(tod(args[0]))); 14287 14290 } 14288 14291 14289 14292 static jsval_t builtin_Math_ceil(struct js *js, jsval_t *args, int nargs) { 14290 14293 (void) js; 14291 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14294 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14292 14295 return tov(ceil(tod(args[0]))); 14293 14296 } 14294 14297 ··· 14304 14307 14305 14308 static jsval_t builtin_Math_cos(struct js *js, jsval_t *args, int nargs) { 14306 14309 (void) js; 14307 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14310 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14308 14311 return tov(cos(tod(args[0]))); 14309 14312 } 14310 14313 14311 14314 static jsval_t builtin_Math_cosh(struct js *js, jsval_t *args, int nargs) { 14312 14315 (void) js; 14313 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14316 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14314 14317 return tov(cosh(tod(args[0]))); 14315 14318 } 14316 14319 14317 14320 static jsval_t builtin_Math_exp(struct js *js, jsval_t *args, int nargs) { 14318 14321 (void) js; 14319 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14322 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14320 14323 return tov(exp(tod(args[0]))); 14321 14324 } 14322 14325 14323 14326 static jsval_t builtin_Math_expm1(struct js *js, jsval_t *args, int nargs) { 14324 14327 (void) js; 14325 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14328 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14326 14329 return tov(expm1(tod(args[0]))); 14327 14330 } 14328 14331 14329 14332 static jsval_t builtin_Math_floor(struct js *js, jsval_t *args, int nargs) { 14330 14333 (void) js; 14331 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14334 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14332 14335 return tov(floor(tod(args[0]))); 14333 14336 } 14334 14337 14335 14338 static jsval_t builtin_Math_fround(struct js *js, jsval_t *args, int nargs) { 14336 14339 (void) js; 14337 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14340 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14338 14341 return tov((double)(float)tod(args[0])); 14339 14342 } 14340 14343 ··· 14343 14346 if (nargs == 0) return tov(0.0); 14344 14347 double sum = 0.0; 14345 14348 for (int i = 0; i < nargs; i++) { 14346 - if (vtype(args[i]) != T_NUM) return tov(NAN); 14349 + if (vtype(args[i]) != T_NUM) return tov(JS_NAN); 14347 14350 double v = tod(args[i]); 14348 14351 sum += v * v; 14349 14352 } ··· 14371 14374 14372 14375 static jsval_t builtin_Math_log(struct js *js, jsval_t *args, int nargs) { 14373 14376 (void) js; 14374 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14377 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14375 14378 return tov(log(tod(args[0]))); 14376 14379 } 14377 14380 14378 14381 static jsval_t builtin_Math_log1p(struct js *js, jsval_t *args, int nargs) { 14379 14382 (void) js; 14380 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14383 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14381 14384 return tov(log1p(tod(args[0]))); 14382 14385 } 14383 14386 14384 14387 static jsval_t builtin_Math_log10(struct js *js, jsval_t *args, int nargs) { 14385 14388 (void) js; 14386 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14389 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14387 14390 return tov(log10(tod(args[0]))); 14388 14391 } 14389 14392 14390 14393 static jsval_t builtin_Math_log2(struct js *js, jsval_t *args, int nargs) { 14391 14394 (void) js; 14392 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14395 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14393 14396 return tov(log2(tod(args[0]))); 14394 14397 } 14395 14398 14396 14399 static jsval_t builtin_Math_max(struct js *js, jsval_t *args, int nargs) { 14397 14400 (void) js; 14398 - if (nargs == 0) return tov(-INFINITY); 14399 - double max_val = -INFINITY; 14401 + if (nargs == 0) return tov(JS_NEG_INF); 14402 + double max_val = JS_NEG_INF; 14400 14403 for (int i = 0; i < nargs; i++) { 14401 - if (vtype(args[i]) != T_NUM) return tov(NAN); 14404 + if (vtype(args[i]) != T_NUM) return tov(JS_NAN); 14402 14405 double v = tod(args[i]); 14403 - if (isnan(v)) return tov(NAN); 14406 + if (isnan(v)) return tov(JS_NAN); 14404 14407 if (v > max_val) max_val = v; 14405 14408 } 14406 14409 return tov(max_val); ··· 14408 14411 14409 14412 static jsval_t builtin_Math_min(struct js *js, jsval_t *args, int nargs) { 14410 14413 (void) js; 14411 - if (nargs == 0) return tov(INFINITY); 14412 - double min_val = INFINITY; 14414 + if (nargs == 0) return tov(JS_INF); 14415 + double min_val = JS_INF; 14413 14416 for (int i = 0; i < nargs; i++) { 14414 - if (vtype(args[i]) != T_NUM) return tov(NAN); 14417 + if (vtype(args[i]) != T_NUM) return tov(JS_NAN); 14415 14418 double v = tod(args[i]); 14416 - if (isnan(v)) return tov(NAN); 14419 + if (isnan(v)) return tov(JS_NAN); 14417 14420 if (v < min_val) min_val = v; 14418 14421 } 14419 14422 return tov(min_val); ··· 14421 14424 14422 14425 static jsval_t builtin_Math_pow(struct js *js, jsval_t *args, int nargs) { 14423 14426 (void) js; 14424 - if (nargs < 2 || vtype(args[0]) != T_NUM || vtype(args[1]) != T_NUM) return tov(NAN); 14427 + if (nargs < 2 || vtype(args[0]) != T_NUM || vtype(args[1]) != T_NUM) return tov(JS_NAN); 14425 14428 return tov(pow(tod(args[0]), tod(args[1]))); 14426 14429 } 14427 14430 ··· 14440 14443 14441 14444 static jsval_t builtin_Math_round(struct js *js, jsval_t *args, int nargs) { 14442 14445 (void) js; 14443 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14446 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14444 14447 double x = tod(args[0]); 14445 14448 if (isnan(x) || isinf(x)) return tov(x); 14446 14449 return tov(floor(x + 0.5)); ··· 14448 14451 14449 14452 static jsval_t builtin_Math_sign(struct js *js, jsval_t *args, int nargs) { 14450 14453 (void) js; 14451 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14454 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14452 14455 double v = tod(args[0]); 14453 - if (isnan(v)) return tov(NAN); 14456 + if (isnan(v)) return tov(JS_NAN); 14454 14457 if (v > 0) return tov(1.0); 14455 14458 if (v < 0) return tov(-1.0); 14456 14459 return tov(v); ··· 14458 14461 14459 14462 static jsval_t builtin_Math_sin(struct js *js, jsval_t *args, int nargs) { 14460 14463 (void) js; 14461 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14464 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14462 14465 return tov(sin(tod(args[0]))); 14463 14466 } 14464 14467 14465 14468 static jsval_t builtin_Math_sinh(struct js *js, jsval_t *args, int nargs) { 14466 14469 (void) js; 14467 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14470 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14468 14471 return tov(sinh(tod(args[0]))); 14469 14472 } 14470 14473 14471 14474 static jsval_t builtin_Math_sqrt(struct js *js, jsval_t *args, int nargs) { 14472 14475 (void) js; 14473 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14476 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14474 14477 return tov(sqrt(tod(args[0]))); 14475 14478 } 14476 14479 14477 14480 static jsval_t builtin_Math_tan(struct js *js, jsval_t *args, int nargs) { 14478 14481 (void) js; 14479 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14482 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14480 14483 return tov(tan(tod(args[0]))); 14481 14484 } 14482 14485 14483 14486 static jsval_t builtin_Math_tanh(struct js *js, jsval_t *args, int nargs) { 14484 14487 (void) js; 14485 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14488 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14486 14489 return tov(tanh(tod(args[0]))); 14487 14490 } 14488 14491 14489 14492 static jsval_t builtin_Math_trunc(struct js *js, jsval_t *args, int nargs) { 14490 14493 (void) js; 14491 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(NAN); 14494 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 14492 14495 return tov(trunc(tod(args[0]))); 14493 14496 } 14494 14497 ··· 15394 15397 15395 15398 uint8_t proto_type = vtype(proto_obj); 15396 15399 if (proto_type != T_OBJ && proto_type != T_ARR && proto_type != T_FUNC) return mkval(T_BOOL, 0); 15397 - jsoff_t proto_data = vdata(proto_obj); 15400 + jsoff_t proto_data = (jsoff_t)vdata(proto_obj); 15398 15401 15399 15402 jsval_t current = get_proto(js, obj); 15400 15403 while (!is_undefined(current) && !is_null(current)) { ··· 15629 15632 jsoff_t elem_off = lkp(js, arr, idxstr, idxlen); 15630 15633 if (elem_off != 0) { 15631 15634 jsval_t elem = resolveprop(js, mkval(T_PROP, elem_off)); 15632 - size_t idxlen = uint_to_str(idxstr, sizeof(idxstr), (unsigned)result_idx); 15633 - jsval_t key = js_mkstr(js, idxstr, idxlen); 15635 + size_t result_idxlen = uint_to_str(idxstr, sizeof(idxstr), (unsigned)result_idx); 15636 + jsval_t key = js_mkstr(js, idxstr, result_idxlen); 15634 15637 setprop(js, result, key, elem); 15635 15638 } 15636 15639 result_idx++; ··· 17464 17467 for (uint32_t i = 1; i <= capture_count && idx < limit; i++) { 17465 17468 PCRE2_SIZE cap_start = ovector[2*i]; 17466 17469 PCRE2_SIZE cap_end = ovector[2*i+1]; 17467 - size_t idxlen = uint_to_str(idxstr, sizeof(idxstr), (unsigned)idx); 17468 - key = js_mkstr(js, idxstr, idxlen); 17470 + size_t cap_idxlen = uint_to_str(idxstr, sizeof(idxstr), (unsigned)idx); 17471 + key = js_mkstr(js, idxstr, cap_idxlen); 17469 17472 if (cap_start == PCRE2_UNSET) { 17470 17473 setprop(js, arr, key, js_mkundef()); 17471 17474 } else { ··· 18278 18281 static jsval_t builtin_string_charCodeAt(struct js *js, jsval_t *args, int nargs) { 18279 18282 jsval_t str = to_string_val(js, js->this_val); 18280 18283 if (vtype(str) != T_STR) return js_mkerr(js, "charCodeAt called on non-string"); 18281 - if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(-NAN); 18284 + if (nargs < 1 || vtype(args[0]) != T_NUM) return tov(JS_NAN); 18282 18285 18283 18286 double idx_d = tod(args[0]); 18284 - if (idx_d < 0 || idx_d != (double)(long)idx_d) return tov(-NAN); 18287 + if (idx_d < 0 || idx_d != (double)(long)idx_d) return tov(JS_NAN); 18285 18288 18286 18289 jsoff_t idx = (jsoff_t) idx_d; 18287 18290 jsoff_t str_len = offtolen(loadoff(js, (jsoff_t) vdata(str))); 18288 18291 18289 - if (idx >= str_len) return tov(-NAN); 18292 + if (idx >= str_len) return tov(JS_NAN); 18290 18293 18291 18294 jsoff_t str_off = (jsoff_t) vdata(str) + sizeof(jsoff_t); 18292 18295 unsigned char ch = (unsigned char) js->mem[str_off + idx]; ··· 18713 18716 } else { 18714 18717 while (int_part > 0 && p > buf) { 18715 18718 int digit = int_part % radix; 18716 - *--p = digit < 10 ? '0' + digit : 'a' + (digit - 10); 18719 + *--p = (char)(digit < 10 ? '0' + digit : 'a' + (digit - 10)); 18717 18720 int_part /= radix; 18718 18721 } 18719 18722 } ··· 18732 18735 for (int i = 0; i < 16 && frac_part > 0.0000001 && frac_pos < 63; i++) { 18733 18736 frac_part *= radix; 18734 18737 int digit = (int)frac_part; 18735 - frac_buf[frac_pos++] = digit < 10 ? '0' + digit : 'a' + (digit - 10); 18738 + frac_buf[frac_pos++] = (char)(digit < 10 ? '0' + digit : 'a' + (digit - 10)); 18736 18739 frac_part -= digit; 18737 18740 } 18738 18741 frac_buf[frac_pos] = '\0'; ··· 18776 18779 18777 18780 char digit_buf[128]; 18778 18781 snprintf(digit_buf, sizeof(digit_buf), "%.0f", rounded); 18779 - int digit_len = strlen(digit_buf); 18782 + int digit_len = (int)strlen(digit_buf); 18780 18783 18781 18784 while (digit_len < digits + 1) { 18782 18785 memmove(digit_buf + 1, digit_buf, digit_len + 1); ··· 18856 18859 18857 18860 char digit_buf[32]; 18858 18861 snprintf(digit_buf, sizeof(digit_buf), "%.0f", rounded); 18859 - int digit_len = strlen(digit_buf); 18862 + int digit_len = (int)strlen(digit_buf); 18860 18863 18861 18864 char buf[128]; 18862 18865 int pos = 0; ··· 18882 18885 18883 18886 char digit_buf[64]; 18884 18887 snprintf(digit_buf, sizeof(digit_buf), "%.0f", rounded); 18885 - int digit_len = strlen(digit_buf); 18888 + int digit_len = (int)strlen(digit_buf); 18886 18889 18887 18890 while (digit_len < digits_after_point + 1) { 18888 18891 memmove(digit_buf + 1, digit_buf, digit_len + 1); ··· 18967 18970 18968 18971 char digit_buf[32]; 18969 18972 snprintf(digit_buf, sizeof(digit_buf), "%.0f", rounded); 18970 - int digit_len = strlen(digit_buf); 18973 + int digit_len = (int)strlen(digit_buf); 18971 18974 18972 18975 while (digit_len < digits + 1) { 18973 18976 memmove(digit_buf + 1, digit_buf, digit_len + 1); ··· 19034 19037 } 19035 19038 19036 19039 static jsval_t builtin_parseInt(struct js *js, jsval_t *args, int nargs) { 19037 - if (nargs < 1) return tov(-NAN); 19040 + if (nargs < 1) return tov(JS_NAN); 19038 19041 19039 19042 jsval_t str_val = args[0]; 19040 19043 if (vtype(str_val) != T_STR) { ··· 19048 19051 int radix = 0; 19049 19052 if (nargs >= 2 && vtype(args[1]) == T_NUM) { 19050 19053 radix = (int) tod(args[1]); 19051 - if (radix != 0 && (radix < 2 || radix > 36)) return tov(-NAN); 19054 + if (radix != 0 && (radix < 2 || radix > 36)) return tov(JS_NAN); 19052 19055 } 19053 19056 19054 19057 jsoff_t i = 0; 19055 19058 while (i < str_len && is_space(str[i])) i++; 19056 19059 19057 - if (i >= str_len) return tov(-NAN); 19060 + if (i >= str_len) return tov(JS_NAN); 19058 19061 19059 19062 int sign = 1; 19060 19063 if (str[i] == '-') { ··· 19093 19096 i++; 19094 19097 } 19095 19098 19096 - if (!found_digit) return tov(-NAN); 19099 + if (!found_digit) return tov(JS_NAN); 19097 19100 19098 19101 return tov(sign * result); 19099 19102 } 19100 19103 19101 19104 static jsval_t builtin_parseFloat(struct js *js, jsval_t *args, int nargs) { 19102 - if (nargs < 1) return tov(-NAN); 19105 + if (nargs < 1) return tov(JS_NAN); 19103 19106 19104 19107 jsval_t str_val = args[0]; 19105 19108 if (vtype(str_val) != T_STR) { ··· 19113 19116 jsoff_t i = 0; 19114 19117 while (i < str_len && is_space(str[i])) i++; 19115 19118 19116 - if (i >= str_len) return tov(-NAN); 19119 + if (i >= str_len) return tov(JS_NAN); 19117 19120 19118 19121 char *end; 19119 19122 double result = strtod(&str[i], &end); 19120 19123 19121 - if (end == &str[i]) return tov(-NAN); 19124 + if (end == &str[i]) return tov(JS_NAN); 19122 19125 19123 19126 return tov(result); 19124 19127 } ··· 20459 20462 20460 20463 while (next(js) != TOK_RBRACE && count < max_bindings) { 20461 20464 if (next(js) != TOK_IDENTIFIER && next(js) != TOK_DEFAULT) { 20462 - return js_mkerr_typed(js, JS_ERR_SYNTAX, "expected identifier or 'default' in import list"); 20465 + return -1; 20463 20466 } 20464 20467 const char *import_name = &js->code[js->toff]; 20465 20468 size_t import_len = js->tlen; ··· 20471 20474 if (next(js) == TOK_AS) { 20472 20475 js->consumed = 1; 20473 20476 if (next(js) != TOK_IDENTIFIER && next(js) != TOK_DEFAULT) { 20474 - return js_mkerr_typed(js, JS_ERR_SYNTAX, "expected identifier or 'default' after 'as'"); 20477 + return -1; 20475 20478 } 20476 20479 local_name = &js->code[js->toff]; 20477 20480 local_len = js->tlen; ··· 20487 20490 if (next(js) == TOK_COMMA) js->consumed = 1; 20488 20491 } 20489 20492 20490 - EXPECT(TOK_RBRACE, (void)0); 20493 + if (next(js) != TOK_RBRACE) return -1; 20494 + js->consumed = 1; 20491 20495 return count; 20492 20496 } 20493 20497 ··· 21736 21740 static jsval_t proxy_revoke_fn(struct js *js, jsval_t *args, int nargs) { 21737 21741 (void)args; (void)nargs; 21738 21742 jsval_t func = js->current_func; 21739 - jsoff_t ref_off = get_slot(js, func, SLOT_PROXY_REF); 21743 + jsval_t ref_slot = get_slot(js, func, SLOT_PROXY_REF); 21740 21744 21741 - if (ref_off != 0) { 21742 - jsval_t proxy = resolveprop(js, mkval(T_PROP, ref_off)); 21745 + if (vtype(ref_slot) != T_UNDEF && vdata(ref_slot) != 0) { 21746 + jsval_t proxy = resolveprop(js, mkval(T_PROP, (jsoff_t)vdata(ref_slot))); 21743 21747 proxy_data_t *data = get_proxy_data(proxy); 21744 21748 if (data) data->revoked = true; 21745 21749 } ··· 22297 22301 setprop(js, number_ctor_obj, js_mkstr(js, "MIN_VALUE", 9), tov(5e-324)); 22298 22302 setprop(js, number_ctor_obj, js_mkstr(js, "MAX_SAFE_INTEGER", 16), tov(9007199254740991.0)); 22299 22303 setprop(js, number_ctor_obj, js_mkstr(js, "MIN_SAFE_INTEGER", 16), tov(-9007199254740991.0)); 22300 - setprop(js, number_ctor_obj, js_mkstr(js, "POSITIVE_INFINITY", 17), tov(INFINITY)); 22301 - setprop(js, number_ctor_obj, js_mkstr(js, "NEGATIVE_INFINITY", 17), tov(-INFINITY)); 22302 - setprop(js, number_ctor_obj, js_mkstr(js, "NaN", 3), tov(NAN)); 22304 + setprop(js, number_ctor_obj, js_mkstr(js, "POSITIVE_INFINITY", 17), tov(JS_INF)); 22305 + setprop(js, number_ctor_obj, js_mkstr(js, "NEGATIVE_INFINITY", 17), tov(JS_NEG_INF)); 22306 + setprop(js, number_ctor_obj, js_mkstr(js, "NaN", 3), tov(JS_NAN)); 22303 22307 setprop(js, number_ctor_obj, js_mkstr(js, "EPSILON", 7), tov(2.220446049250313e-16)); 22304 22308 22305 22309 js_setprop_nonconfigurable(js, number_ctor_obj, "prototype", 9, number_proto); ··· 22421 22425 setprop(js, glob, js_mkstr(js, "isFinite", 8), js_mkfun(builtin_global_isFinite)); 22422 22426 setprop(js, glob, js_mkstr(js, "btoa", 4), js_mkfun(builtin_btoa)); 22423 22427 setprop(js, glob, js_mkstr(js, "atob", 4), js_mkfun(builtin_atob)); 22424 - setprop(js, glob, js_mkstr(js, "NaN", 3), tov(NAN)); 22425 - setprop(js, glob, js_mkstr(js, "Infinity", 8), tov(INFINITY)); 22428 + setprop(js, glob, js_mkstr(js, "NaN", 3), tov(JS_NAN)); 22429 + setprop(js, glob, js_mkstr(js, "Infinity", 8), tov(JS_INF)); 22426 22430 setprop(js, glob, js_mkstr(js, "undefined", 9), js_mkundef()); 22427 22431 22428 22432 jsval_t math_obj = mkobj(js, 0); ··· 22616 22620 jsoff_t obj_off; 22617 22621 22618 22622 if (vtype(obj) == T_OBJ) { 22619 - obj_off = vdata(obj); 22623 + obj_off = (jsoff_t)vdata(obj); 22620 22624 } else if (vtype(obj) == T_ARR || vtype(obj) == T_FUNC) { 22621 - obj_off = vdata(obj); 22625 + obj_off = (jsoff_t)vdata(obj); 22622 22626 obj = mkval(T_OBJ, obj_off); 22623 22627 } else { 22624 22628 return false; ··· 23057 23061 } 23058 23062 23059 23063 int arg_idx = 0; 23060 - for (int i = 0; i < pf->param_count; i++) { 23064 + for (unsigned int i = 0; i < (unsigned int)pf->param_count; i++) { 23061 23065 parsed_param_t *pp = (parsed_param_t *)utarray_eltptr(pf->params, i); 23062 23066 23063 23067 if (pp->is_destruct) {