Remove unnecessary casts

Follow-up to https://github.com/quickjs-ng/quickjs/pull/195
This commit is contained in:
Saúl Ibarra Corretgé 2023-12-19 23:18:11 +01:00
parent c29ae8d08c
commit d1852b5ea2
4 changed files with 101 additions and 101 deletions

View file

@ -2213,7 +2213,7 @@ static int handle_posted_message(JSRuntime *rt, JSContext *ctx,
/* 'func' might be destroyed when calling itself (if it frees the /* 'func' might be destroyed when calling itself (if it frees the
handler), so must take extra care */ handler), so must take extra care */
func = JS_DupValue(ctx, port->on_message_func); func = JS_DupValue(ctx, port->on_message_func);
retval = JS_Call(ctx, func, JS_UNDEFINED, 1, (JSValue *)&obj); retval = JS_Call(ctx, func, JS_UNDEFINED, 1, &obj);
JS_FreeValue(ctx, obj); JS_FreeValue(ctx, obj);
JS_FreeValue(ctx, func); JS_FreeValue(ctx, func);
if (JS_IsException(retval)) { if (JS_IsException(retval)) {

194
quickjs.c
View file

@ -1320,7 +1320,7 @@ static JSValue js_dup(JSValue v)
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v); JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
p->ref_count++; p->ref_count++;
} }
return (JSValue)v; return v;
} }
static void js_trigger_gc(JSRuntime *rt, size_t size) static void js_trigger_gc(JSRuntime *rt, size_t size)
@ -1810,7 +1810,7 @@ int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx)
e = list_entry(rt->job_list.next, JSJobEntry, link); e = list_entry(rt->job_list.next, JSJobEntry, link);
list_del(&e->link); list_del(&e->link);
ctx = e->ctx; ctx = e->ctx;
res = e->job_func(e->ctx, e->argc, (JSValue *)e->argv); res = e->job_func(e->ctx, e->argc, e->argv);
for(i = 0; i < e->argc; i++) for(i = 0; i < e->argc; i++)
JS_FreeValue(ctx, e->argv[i]); JS_FreeValue(ctx, e->argv[i]);
if (JS_IsException(res)) if (JS_IsException(res))
@ -7254,7 +7254,7 @@ static int JS_DefinePrivateField(JSContext *ctx, JSValue obj,
JS_ThrowTypeErrorNotASymbol(ctx); JS_ThrowTypeErrorNotASymbol(ctx);
goto fail; goto fail;
} }
prop = js_symbol_to_atom(ctx, (JSValue)name); prop = js_symbol_to_atom(ctx, name);
p = JS_VALUE_GET_OBJ(obj); p = JS_VALUE_GET_OBJ(obj);
prs = find_own_property(&pr, p, prop); prs = find_own_property(&pr, p, prop);
if (prs) { if (prs) {
@ -7285,7 +7285,7 @@ static JSValue JS_GetPrivateField(JSContext *ctx, JSValue obj,
/* safety check */ /* safety check */
if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL)) if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL))
return JS_ThrowTypeErrorNotASymbol(ctx); return JS_ThrowTypeErrorNotASymbol(ctx);
prop = js_symbol_to_atom(ctx, (JSValue)name); prop = js_symbol_to_atom(ctx, name);
p = JS_VALUE_GET_OBJ(obj); p = JS_VALUE_GET_OBJ(obj);
prs = find_own_property(&pr, p, prop); prs = find_own_property(&pr, p, prop);
if (!prs) { if (!prs) {
@ -7312,7 +7312,7 @@ static int JS_SetPrivateField(JSContext *ctx, JSValue obj,
JS_ThrowTypeErrorNotASymbol(ctx); JS_ThrowTypeErrorNotASymbol(ctx);
goto fail; goto fail;
} }
prop = js_symbol_to_atom(ctx, (JSValue)name); prop = js_symbol_to_atom(ctx, name);
p = JS_VALUE_GET_OBJ(obj); p = JS_VALUE_GET_OBJ(obj);
prs = find_own_property(&pr, p, prop); prs = find_own_property(&pr, p, prop);
if (!prs) { if (!prs) {
@ -7408,7 +7408,7 @@ static int JS_CheckBrand(JSContext *ctx, JSValue obj, JSValue func)
if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT))
goto not_obj; goto not_obj;
p = JS_VALUE_GET_OBJ(obj); p = JS_VALUE_GET_OBJ(obj);
prs = find_own_property(&pr, p, js_symbol_to_atom(ctx, (JSValue)brand)); prs = find_own_property(&pr, p, js_symbol_to_atom(ctx, brand));
if (!prs) { if (!prs) {
JS_ThrowTypeError(ctx, "invalid brand on object"); JS_ThrowTypeError(ctx, "invalid brand on object");
return -1; return -1;
@ -8169,7 +8169,7 @@ static int call_setter(JSContext *ctx, JSObject *setter,
func = JS_MKPTR(JS_TAG_OBJECT, setter); func = JS_MKPTR(JS_TAG_OBJECT, setter);
/* Note: the field could be removed in the setter */ /* Note: the field could be removed in the setter */
func = js_dup(func); func = js_dup(func);
ret = JS_CallFree(ctx, func, this_obj, 1, (JSValue *)&val); ret = JS_CallFree(ctx, func, this_obj, 1, &val);
JS_FreeValue(ctx, val); JS_FreeValue(ctx, val);
if (JS_IsException(ret)) if (JS_IsException(ret))
return -1; return -1;
@ -9020,7 +9020,7 @@ int JS_DefineProperty(JSContext *ctx, JSValue this_obj,
return -1; return -1;
} }
/* this code relies on the fact that Uint32 are never allocated */ /* this code relies on the fact that Uint32 are never allocated */
val = (JSValue)js_uint32(array_length); val = js_uint32(array_length);
/* prs may have been modified */ /* prs may have been modified */
prs = find_own_property(&pr, p, prop); prs = find_own_property(&pr, p, prop);
assert(prs != NULL); assert(prs != NULL);
@ -9837,7 +9837,7 @@ static JSValue JS_ToPrimitiveFree(JSContext *ctx, JSValue val, int hint)
break; break;
} }
arg = JS_AtomToString(ctx, atom); arg = JS_AtomToString(ctx, atom);
ret = JS_CallFree(ctx, method, val, 1, (JSValue *)&arg); ret = JS_CallFree(ctx, method, val, 1, &arg);
JS_FreeValue(ctx, arg); JS_FreeValue(ctx, arg);
if (JS_IsException(ret)) if (JS_IsException(ret))
goto exception; goto exception;
@ -14178,7 +14178,7 @@ static JSValue js_call_c_function(JSContext *ctx, JSValue func_obj,
ctx = p->u.cfunc.realm; /* change the current realm */ ctx = p->u.cfunc.realm; /* change the current realm */
sf->js_mode = 0; sf->js_mode = 0;
sf->cur_func = (JSValue)func_obj; sf->cur_func = func_obj;
sf->arg_count = argc; sf->arg_count = argc;
arg_buf = argv; arg_buf = argv;
@ -14191,7 +14191,7 @@ static JSValue js_call_c_function(JSContext *ctx, JSValue func_obj,
arg_buf[i] = JS_UNDEFINED; arg_buf[i] = JS_UNDEFINED;
sf->arg_count = arg_count; sf->arg_count = arg_count;
} }
sf->arg_buf = (JSValue*)arg_buf; sf->arg_buf = arg_buf;
func = p->u.cfunc.c_function; func = p->u.cfunc.c_function;
switch(cproto) { switch(cproto) {
@ -14414,7 +14414,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
return JS_ThrowTypeError(caller_ctx, "not a function"); return JS_ThrowTypeError(caller_ctx, "not a function");
} }
return call_func(caller_ctx, func_obj, this_obj, argc, return call_func(caller_ctx, func_obj, this_obj, argc,
(JSValue *)argv, flags); argv, flags);
} }
b = p->u.func.function_bytecode; b = p->u.func.function_bytecode;
@ -14432,7 +14432,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
sf->js_mode = b->js_mode; sf->js_mode = b->js_mode;
arg_buf = argv; arg_buf = argv;
sf->arg_count = argc; sf->arg_count = argc;
sf->cur_func = (JSValue)func_obj; sf->cur_func = func_obj;
init_list_head(&sf->var_ref_list); init_list_head(&sf->var_ref_list);
var_refs = p->u.func.var_refs; var_refs = p->u.func.var_refs;
@ -14568,12 +14568,12 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
int arg = *pc++; int arg = *pc++;
switch(arg) { switch(arg) {
case OP_SPECIAL_OBJECT_ARGUMENTS: case OP_SPECIAL_OBJECT_ARGUMENTS:
*sp++ = js_build_arguments(ctx, argc, (JSValue *)argv); *sp++ = js_build_arguments(ctx, argc, argv);
if (unlikely(JS_IsException(sp[-1]))) if (unlikely(JS_IsException(sp[-1])))
goto exception; goto exception;
break; break;
case OP_SPECIAL_OBJECT_MAPPED_ARGUMENTS: case OP_SPECIAL_OBJECT_MAPPED_ARGUMENTS:
*sp++ = js_build_mapped_arguments(ctx, argc, (JSValue *)argv, *sp++ = js_build_mapped_arguments(ctx, argc, argv,
sf, min_int(argc, b->arg_count)); sf, min_int(argc, b->arg_count));
if (unlikely(JS_IsException(sp[-1]))) if (unlikely(JS_IsException(sp[-1])))
goto exception; goto exception;
@ -14613,7 +14613,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
{ {
int first = get_u16(pc); int first = get_u16(pc);
pc += 2; pc += 2;
*sp++ = js_build_rest(ctx, first, argc, (JSValue *)argv); *sp++ = js_build_rest(ctx, first, argc, argv);
if (unlikely(JS_IsException(sp[-1]))) if (unlikely(JS_IsException(sp[-1])))
goto exception; goto exception;
} }
@ -14863,7 +14863,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
magic = get_u16(pc); magic = get_u16(pc);
pc += 2; pc += 2;
ret_val = js_function_apply(ctx, sp[-3], 2, (JSValue *)&sp[-2], magic); ret_val = js_function_apply(ctx, sp[-3], 2, &sp[-2], magic);
if (unlikely(JS_IsException(ret_val))) if (unlikely(JS_IsException(ret_val)))
goto exception; goto exception;
JS_FreeValue(ctx, sp[-3]); JS_FreeValue(ctx, sp[-3]);
@ -14996,7 +14996,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
JS_EVAL_TYPE_DIRECT, scope_idx); JS_EVAL_TYPE_DIRECT, scope_idx);
} else { } else {
ret_val = JS_Call(ctx, sp[-2], JS_UNDEFINED, len, ret_val = JS_Call(ctx, sp[-2], JS_UNDEFINED, len,
(JSValue *)tab); tab);
} }
free_arg_list(ctx, tab, len); free_arg_list(ctx, tab, len);
if (unlikely(JS_IsException(ret_val))) if (unlikely(JS_IsException(ret_val)))
@ -15620,7 +15620,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
{ {
JSValue ret; JSValue ret;
ret = JS_Call(ctx, sp[-3], sp[-4], ret = JS_Call(ctx, sp[-3], sp[-4],
1, (JSValue *)(sp - 1)); 1, (sp - 1));
if (JS_IsException(ret)) if (JS_IsException(ret))
goto exception; goto exception;
JS_FreeValue(ctx, sp[-1]); JS_FreeValue(ctx, sp[-1]);
@ -15648,7 +15648,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
0, NULL); 0, NULL);
} else { } else {
ret = JS_CallFree(ctx, method, sp[-4], ret = JS_CallFree(ctx, method, sp[-4],
1, (JSValue *)(sp - 1)); 1, (sp - 1));
} }
if (JS_IsException(ret)) if (JS_IsException(ret))
goto exception; goto exception;
@ -16854,14 +16854,14 @@ JSValue JS_Call(JSContext *ctx, JSValue func_obj, JSValue this_obj,
int argc, JSValue *argv) int argc, JSValue *argv)
{ {
return JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED, return JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED,
argc, (JSValue *)argv, JS_CALL_FLAG_COPY_ARGV); argc, argv, JS_CALL_FLAG_COPY_ARGV);
} }
static JSValue JS_CallFree(JSContext *ctx, JSValue func_obj, JSValue this_obj, static JSValue JS_CallFree(JSContext *ctx, JSValue func_obj, JSValue this_obj,
int argc, JSValue *argv) int argc, JSValue *argv)
{ {
JSValue res = JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED, JSValue res = JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED,
argc, (JSValue *)argv, JS_CALL_FLAG_COPY_ARGV); argc, argv, JS_CALL_FLAG_COPY_ARGV);
JS_FreeValue(ctx, func_obj); JS_FreeValue(ctx, func_obj);
return res; return res;
} }
@ -16966,7 +16966,7 @@ static JSValue JS_CallConstructorInternal(JSContext *ctx,
return JS_ThrowTypeError(ctx, "not a function"); return JS_ThrowTypeError(ctx, "not a function");
} }
return call_func(ctx, func_obj, new_target, argc, return call_func(ctx, func_obj, new_target, argc,
(JSValue *)argv, flags); argv, flags);
} }
b = p->u.func.function_bytecode; b = p->u.func.function_bytecode;
@ -16995,7 +16995,7 @@ JSValue JS_CallConstructor2(JSContext *ctx, JSValue func_obj,
int argc, JSValue *argv) int argc, JSValue *argv)
{ {
return JS_CallConstructorInternal(ctx, func_obj, new_target, return JS_CallConstructorInternal(ctx, func_obj, new_target,
argc, (JSValue *)argv, argc, argv,
JS_CALL_FLAG_COPY_ARGV); JS_CALL_FLAG_COPY_ARGV);
} }
@ -17003,7 +17003,7 @@ JSValue JS_CallConstructor(JSContext *ctx, JSValue func_obj,
int argc, JSValue *argv) int argc, JSValue *argv)
{ {
return JS_CallConstructorInternal(ctx, func_obj, func_obj, return JS_CallConstructorInternal(ctx, func_obj, func_obj,
argc, (JSValue *)argv, argc, argv,
JS_CALL_FLAG_COPY_ARGV); JS_CALL_FLAG_COPY_ARGV);
} }
@ -17368,7 +17368,7 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
fail: fail:
error = JS_GetException(ctx); error = JS_GetException(ctx);
ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED, ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED,
1, (JSValue *)&error); 1, &error);
JS_FreeValue(ctx, error); JS_FreeValue(ctx, error);
js_async_function_terminate(ctx->rt, s); js_async_function_terminate(ctx->rt, s);
JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */ JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */
@ -17379,7 +17379,7 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
if (JS_IsUndefined(func_ret)) { if (JS_IsUndefined(func_ret)) {
/* function returned */ /* function returned */
ret2 = JS_Call(ctx, s->resolving_funcs[0], JS_UNDEFINED, ret2 = JS_Call(ctx, s->resolving_funcs[0], JS_UNDEFINED,
1, (JSValue *)&value); 1, &value);
JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */ JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */
JS_FreeValue(ctx, value); JS_FreeValue(ctx, value);
js_async_function_terminate(ctx->rt, s); js_async_function_terminate(ctx->rt, s);
@ -17390,7 +17390,7 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
/* await */ /* await */
JS_FreeValue(ctx, func_ret); /* not used */ JS_FreeValue(ctx, func_ret); /* not used */
promise = js_promise_resolve(ctx, ctx->promise_ctor, promise = js_promise_resolve(ctx, ctx->promise_ctor,
1, (JSValue *)&value, 0); 1, &value, 0);
JS_FreeValue(ctx, value); JS_FreeValue(ctx, value);
if (JS_IsException(promise)) if (JS_IsException(promise))
goto fail; goto fail;
@ -17404,8 +17404,8 @@ static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionData *s)
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
resolving_funcs1[i] = JS_UNDEFINED; resolving_funcs1[i] = JS_UNDEFINED;
res = perform_promise_then(ctx, promise, res = perform_promise_then(ctx, promise,
(JSValue *)resolving_funcs, resolving_funcs,
(JSValue *)resolving_funcs1); resolving_funcs1);
JS_FreeValue(ctx, promise); JS_FreeValue(ctx, promise);
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
JS_FreeValue(ctx, resolving_funcs[i]); JS_FreeValue(ctx, resolving_funcs[i]);
@ -17604,8 +17604,8 @@ static int js_async_generator_await(JSContext *ctx,
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
resolving_funcs1[i] = JS_UNDEFINED; resolving_funcs1[i] = JS_UNDEFINED;
res = perform_promise_then(ctx, promise, res = perform_promise_then(ctx, promise,
(JSValue *)resolving_funcs, resolving_funcs,
(JSValue *)resolving_funcs1); resolving_funcs1);
JS_FreeValue(ctx, promise); JS_FreeValue(ctx, promise);
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
JS_FreeValue(ctx, resolving_funcs[i]); JS_FreeValue(ctx, resolving_funcs[i]);
@ -17694,8 +17694,8 @@ static int js_async_generator_completed_return(JSContext *ctx,
resolving_funcs[0] = JS_UNDEFINED; resolving_funcs[0] = JS_UNDEFINED;
resolving_funcs[1] = JS_UNDEFINED; resolving_funcs[1] = JS_UNDEFINED;
res = perform_promise_then(ctx, promise, res = perform_promise_then(ctx, promise,
(JSValue *)resolving_funcs1, resolving_funcs1,
(JSValue *)resolving_funcs); resolving_funcs);
JS_FreeValue(ctx, resolving_funcs1[0]); JS_FreeValue(ctx, resolving_funcs1[0]);
JS_FreeValue(ctx, resolving_funcs1[1]); JS_FreeValue(ctx, resolving_funcs1[1]);
JS_FreeValue(ctx, promise); JS_FreeValue(ctx, promise);
@ -17857,7 +17857,7 @@ static JSValue js_async_generator_next(JSContext *ctx, JSValue this_val,
JS_ThrowTypeError(ctx, "not an AsyncGenerator object"); JS_ThrowTypeError(ctx, "not an AsyncGenerator object");
err = JS_GetException(ctx); err = JS_GetException(ctx);
res2 = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, res2 = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED,
1, (JSValue *)&err); 1, &err);
JS_FreeValue(ctx, err); JS_FreeValue(ctx, err);
JS_FreeValue(ctx, res2); JS_FreeValue(ctx, res2);
JS_FreeValue(ctx, resolving_funcs[0]); JS_FreeValue(ctx, resolving_funcs[0]);
@ -26303,13 +26303,13 @@ JSModuleDef *JS_RunModule(JSContext *ctx, const char *basename,
static JSValue js_dynamic_import_resolve(JSContext *ctx, JSValue this_val, static JSValue js_dynamic_import_resolve(JSContext *ctx, JSValue this_val,
int argc, JSValue *argv, int magic, JSValue *func_data) int argc, JSValue *argv, int magic, JSValue *func_data)
{ {
return JS_Call(ctx, func_data[0], JS_UNDEFINED, 1, (JSValue *)&func_data[2]); return JS_Call(ctx, func_data[0], JS_UNDEFINED, 1, &func_data[2]);
} }
static JSValue js_dynamic_import_reject(JSContext *ctx, JSValue this_val, static JSValue js_dynamic_import_reject(JSContext *ctx, JSValue this_val,
int argc, JSValue *argv, int magic, JSValue *func_data) int argc, JSValue *argv, int magic, JSValue *func_data)
{ {
return JS_Call(ctx, func_data[1], JS_UNDEFINED, 1, (JSValue *)&argv[0]); return JS_Call(ctx, func_data[1], JS_UNDEFINED, 1, &argv[0]);
} }
static JSValue js_dynamic_import_job(JSContext *ctx, static JSValue js_dynamic_import_job(JSContext *ctx,
@ -26351,8 +26351,8 @@ static JSValue js_dynamic_import_job(JSContext *ctx,
funcs[1] = JS_NewCFunctionData(ctx, js_dynamic_import_reject, 0, 0, 3, args); funcs[1] = JS_NewCFunctionData(ctx, js_dynamic_import_reject, 0, 0, 3, args);
JS_FreeValue(ctx, js_promise_then(ctx, m->promise, 2, funcs)); JS_FreeValue(ctx, js_promise_then(ctx, m->promise, 2, funcs));
JS_FreeValue(ctx, (JSValue)funcs[0]); JS_FreeValue(ctx, funcs[0]);
JS_FreeValue(ctx, (JSValue)funcs[1]); JS_FreeValue(ctx, funcs[1]);
JS_FreeValue(ctx, ns); JS_FreeValue(ctx, ns);
JS_FreeCString(ctx, basename); JS_FreeCString(ctx, basename);
@ -26360,7 +26360,7 @@ static JSValue js_dynamic_import_job(JSContext *ctx,
} }
ret = JS_Call(ctx, resolving_funcs[0], JS_UNDEFINED, ret = JS_Call(ctx, resolving_funcs[0], JS_UNDEFINED,
1, (JSValue *)&ns); 1, &ns);
JS_FreeValue(ctx, ret); /* XXX: what to do if exception ? */ JS_FreeValue(ctx, ret); /* XXX: what to do if exception ? */
JS_FreeValue(ctx, ns); JS_FreeValue(ctx, ns);
JS_FreeCString(ctx, basename); JS_FreeCString(ctx, basename);
@ -26369,7 +26369,7 @@ static JSValue js_dynamic_import_job(JSContext *ctx,
err = JS_GetException(ctx); err = JS_GetException(ctx);
ret = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, ret = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED,
1, (JSValue *)&err); 1, &err);
JS_FreeValue(ctx, ret); /* XXX: what to do if exception ? */ JS_FreeValue(ctx, ret); /* XXX: what to do if exception ? */
JS_FreeValue(ctx, err); JS_FreeValue(ctx, err);
JS_FreeCString(ctx, basename); JS_FreeCString(ctx, basename);
@ -26456,7 +26456,7 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
goto clean; goto clean;
} }
if (!JS_IsUndefined(ret_val)) { if (!JS_IsUndefined(ret_val)) {
js_array_push(ctx, promises, 1, (JSValue *)&ret_val, 0); js_array_push(ctx, promises, 1, &ret_val, 0);
JS_FreeValue(ctx, ret_val); JS_FreeValue(ctx, ret_val);
async = TRUE; async = TRUE;
} }
@ -26465,7 +26465,7 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
promise = js_promise_all(ctx, ctx->promise_ctor, 1, &promises, 0); promise = js_promise_all(ctx, ctx->promise_ctor, 1, &promises, 0);
if (JS_IsException(promise)) { if (JS_IsException(promise)) {
JS_FreeValue(ctx, (JSValue)promises); JS_FreeValue(ctx, promises);
return JS_EXCEPTION; return JS_EXCEPTION;
} }
@ -26490,10 +26490,10 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
} }
} else { } else {
JSValue funcs[2]; JSValue funcs[2];
funcs[0] = JS_NewCFunctionData(ctx, js_async_function_call2, 0, 0, 1, (JSValue *)&m->func_obj); funcs[0] = JS_NewCFunctionData(ctx, js_async_function_call2, 0, 0, 1, &m->func_obj);
funcs[1] = JS_UNDEFINED; funcs[1] = JS_UNDEFINED;
ret_val = js_promise_then(ctx, promise, 2, funcs); ret_val = js_promise_then(ctx, promise, 2, funcs);
JS_FreeValue(ctx, (JSValue)funcs[0]); JS_FreeValue(ctx, funcs[0]);
JS_FreeValue(ctx, m->func_obj); JS_FreeValue(ctx, m->func_obj);
m->func_obj = JS_UNDEFINED; m->func_obj = JS_UNDEFINED;
} }
@ -26507,7 +26507,7 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
m->eval_mark = FALSE; m->eval_mark = FALSE;
m->evaluated = TRUE; m->evaluated = TRUE;
clean: clean:
JS_FreeValue(ctx, (JSValue)promises); JS_FreeValue(ctx, promises);
JS_FreeValue(ctx, promise); JS_FreeValue(ctx, promise);
return ret_val; return ret_val;
} }
@ -35865,9 +35865,9 @@ static JSValue js_function_apply(JSContext *ctx, JSValue this_val,
if (!tab) if (!tab)
return JS_EXCEPTION; return JS_EXCEPTION;
if (magic & 1) { if (magic & 1) {
ret = JS_CallConstructor2(ctx, this_val, this_arg, len, (JSValue *)tab); ret = JS_CallConstructor2(ctx, this_val, this_arg, len, tab);
} else { } else {
ret = JS_Call(ctx, this_val, this_arg, len, (JSValue *)tab); ret = JS_Call(ctx, this_val, this_arg, len, tab);
} }
free_arg_list(ctx, tab, len); free_arg_list(ctx, tab, len);
return ret; return ret;
@ -36470,7 +36470,7 @@ static JSValue js_array_of(JSContext *ctx, JSValue this_val,
if (JS_IsConstructor(ctx, this_val)) { if (JS_IsConstructor(ctx, this_val)) {
args[0] = js_int32(argc); args[0] = js_int32(argc);
obj = JS_CallConstructor(ctx, this_val, 1, (JSValue *)args); obj = JS_CallConstructor(ctx, this_val, 1, args);
} else { } else {
obj = JS_NewArray(ctx); obj = JS_NewArray(ctx);
} }
@ -37817,8 +37817,8 @@ static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValue target,
if (!JS_IsUndefined(mapperFunction)) { if (!JS_IsUndefined(mapperFunction)) {
JSValue args[3] = { element, JS_NewInt64(ctx, sourceIndex), source }; JSValue args[3] = { element, JS_NewInt64(ctx, sourceIndex), source };
element = JS_Call(ctx, mapperFunction, thisArg, 3, args); element = JS_Call(ctx, mapperFunction, thisArg, 3, args);
JS_FreeValue(ctx, (JSValue)args[0]); JS_FreeValue(ctx, args[0]);
JS_FreeValue(ctx, (JSValue)args[1]); JS_FreeValue(ctx, args[1]);
if (JS_IsException(element)) if (JS_IsException(element))
return -1; return -1;
} }
@ -39377,7 +39377,7 @@ static JSValue js_string_match(JSContext *ctx, JSValue this_val,
str = JS_NewString(ctx, "g"); str = JS_NewString(ctx, "g");
if (JS_IsException(str)) if (JS_IsException(str))
goto fail; goto fail;
args[args_len++] = (JSValue)str; args[args_len++] = str;
} }
rx = JS_CallConstructor(ctx, ctx->regexp_ctor, args_len, args); rx = JS_CallConstructor(ctx, ctx->regexp_ctor, args_len, args);
JS_FreeValue(ctx, str); JS_FreeValue(ctx, str);
@ -39386,7 +39386,7 @@ static JSValue js_string_match(JSContext *ctx, JSValue this_val,
JS_FreeValue(ctx, S); JS_FreeValue(ctx, S);
return JS_EXCEPTION; return JS_EXCEPTION;
} }
result = JS_InvokeFree(ctx, rx, atom, 1, (JSValue *)&S); result = JS_InvokeFree(ctx, rx, atom, 1, &S);
JS_FreeValue(ctx, S); JS_FreeValue(ctx, S);
return result; return result;
} }
@ -42563,7 +42563,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
JS_ThrowTypeError(ctx, "bigint are forbidden in JSON.stringify"); JS_ThrowTypeError(ctx, "bigint are forbidden in JSON.stringify");
goto exception; goto exception;
} }
v = js_array_includes(ctx, jsc->stack, 1, (JSValue *)&val); v = js_array_includes(ctx, jsc->stack, 1, &val);
if (JS_IsException(v)) if (JS_IsException(v))
goto exception; goto exception;
if (JS_ToBoolFree(ctx, v)) { if (JS_ToBoolFree(ctx, v)) {
@ -42584,7 +42584,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
sep = js_dup(jsc->empty); sep = js_dup(jsc->empty);
sep1 = js_dup(jsc->empty); sep1 = js_dup(jsc->empty);
} }
v = js_array_push(ctx, jsc->stack, 1, (JSValue *)&val, 0); v = js_array_push(ctx, jsc->stack, 1, &val, 0);
if (check_exception_free(ctx, v)) if (check_exception_free(ctx, v))
goto exception; goto exception;
ret = JS_IsArray(ctx, val); ret = JS_IsArray(ctx, val);
@ -42624,7 +42624,7 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
if (!JS_IsUndefined(jsc->property_list)) if (!JS_IsUndefined(jsc->property_list))
tab = js_dup(jsc->property_list); tab = js_dup(jsc->property_list);
else else
tab = js_object_keys(ctx, JS_UNDEFINED, 1, (JSValue *)&val, JS_ITERATOR_KIND_KEY); tab = js_object_keys(ctx, JS_UNDEFINED, 1, &val, JS_ITERATOR_KIND_KEY);
if (JS_IsException(tab)) if (JS_IsException(tab))
goto exception; goto exception;
if (js_get_length64(ctx, &len, tab)) if (js_get_length64(ctx, &len, tab))
@ -42767,7 +42767,7 @@ JSValue JS_JSONStringify(JSContext *ctx, JSValue obj,
continue; continue;
} }
present = js_array_includes(ctx, jsc->property_list, present = js_array_includes(ctx, jsc->property_list,
1, (JSValue *)&v); 1, &v);
if (JS_IsException(present)) { if (JS_IsException(present)) {
JS_FreeValue(ctx, v); JS_FreeValue(ctx, v);
goto exception; goto exception;
@ -42891,7 +42891,7 @@ static JSValue js_reflect_construct(JSContext *ctx, JSValue this_val,
tab = build_arg_list(ctx, &len, array_arg); tab = build_arg_list(ctx, &len, array_arg);
if (!tab) if (!tab)
return JS_EXCEPTION; return JS_EXCEPTION;
ret = JS_CallConstructor2(ctx, func, new_target, len, (JSValue *)tab); ret = JS_CallConstructor2(ctx, func, new_target, len, tab);
free_arg_list(ctx, tab, len); free_arg_list(ctx, tab, len);
return ret; return ret;
} }
@ -43096,7 +43096,7 @@ static JSValue js_proxy_getPrototypeOf(JSContext *ctx, JSValue obj)
return JS_EXCEPTION; return JS_EXCEPTION;
if (JS_IsUndefined(method)) if (JS_IsUndefined(method))
return JS_GetPrototype(ctx, s->target); return JS_GetPrototype(ctx, s->target);
ret = JS_CallFree(ctx, method, s->handler, 1, (JSValue *)&s->target); ret = JS_CallFree(ctx, method, s->handler, 1, &s->target);
if (JS_IsException(ret)) if (JS_IsException(ret))
return ret; return ret;
if (JS_VALUE_GET_TAG(ret) != JS_TAG_NULL && if (JS_VALUE_GET_TAG(ret) != JS_TAG_NULL &&
@ -43183,7 +43183,7 @@ static int js_proxy_isExtensible(JSContext *ctx, JSValue obj)
return -1; return -1;
if (JS_IsUndefined(method)) if (JS_IsUndefined(method))
return JS_IsExtensible(ctx, s->target); return JS_IsExtensible(ctx, s->target);
ret = JS_CallFree(ctx, method, s->handler, 1, (JSValue *)&s->target); ret = JS_CallFree(ctx, method, s->handler, 1, &s->target);
if (JS_IsException(ret)) if (JS_IsException(ret))
return -1; return -1;
res = JS_ToBoolFree(ctx, ret); res = JS_ToBoolFree(ctx, ret);
@ -43209,7 +43209,7 @@ static int js_proxy_preventExtensions(JSContext *ctx, JSValue obj)
return -1; return -1;
if (JS_IsUndefined(method)) if (JS_IsUndefined(method))
return JS_PreventExtensions(ctx, s->target); return JS_PreventExtensions(ctx, s->target);
ret = JS_CallFree(ctx, method, s->handler, 1, (JSValue *)&s->target); ret = JS_CallFree(ctx, method, s->handler, 1, &s->target);
if (JS_IsException(ret)) if (JS_IsException(ret))
return -1; return -1;
res = JS_ToBoolFree(ctx, ret); res = JS_ToBoolFree(ctx, ret);
@ -43693,7 +43693,7 @@ static int js_proxy_get_own_property_names(JSContext *ctx,
JS_VALUE_GET_OBJ(s->target), JS_VALUE_GET_OBJ(s->target),
JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK); JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK);
} }
prop_array = JS_CallFree(ctx, method, s->handler, 1, (JSValue *)&s->target); prop_array = JS_CallFree(ctx, method, s->handler, 1, &s->target);
if (JS_IsException(prop_array)) if (JS_IsException(prop_array))
return -1; return -1;
tab = NULL; tab = NULL;
@ -44035,7 +44035,7 @@ static JSValue js_symbol_toString(JSContext *ctx, JSValue this_val,
if (JS_IsException(val)) if (JS_IsException(val))
return val; return val;
/* XXX: use JS_ToStringInternal() with a flags */ /* XXX: use JS_ToStringInternal() with a flags */
ret = js_string_constructor(ctx, JS_UNDEFINED, 1, (JSValue *)&val); ret = js_string_constructor(ctx, JS_UNDEFINED, 1, &val);
JS_FreeValue(ctx, val); JS_FreeValue(ctx, val);
return ret; return ret;
} }
@ -44184,7 +44184,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValue new_target,
break; break;
} }
if (is_set) { if (is_set) {
ret = JS_Call(ctx, adder, obj, 1, (JSValue *)&item); ret = JS_Call(ctx, adder, obj, 1, &item);
if (JS_IsException(ret)) { if (JS_IsException(ret)) {
JS_FreeValue(ctx, item); JS_FreeValue(ctx, item);
goto fail; goto fail;
@ -44385,7 +44385,7 @@ static JSMapRecord *map_add_record(JSContext *ctx, JSMapState *s,
} else { } else {
js_dup(key); js_dup(key);
} }
mr->key = (JSValue)key; mr->key = key;
h = map_hash_key(ctx, key) & (s->hash_size - 1); h = map_hash_key(ctx, key) & (s->hash_size - 1);
list_add_tail(&mr->hash_link, &s->hash_table[h]); list_add_tail(&mr->hash_link, &s->hash_table[h]);
list_add_tail(&mr->link, &s->records); list_add_tail(&mr->link, &s->records);
@ -44582,8 +44582,8 @@ static JSValue js_map_forEach(JSContext *ctx, JSValue this_val,
args[0] = args[1]; args[0] = args[1];
else else
args[0] = js_dup(mr->value); args[0] = js_dup(mr->value);
args[2] = (JSValue)this_val; args[2] = this_val;
ret = JS_Call(ctx, func, this_arg, 3, (JSValue *)args); ret = JS_Call(ctx, func, this_arg, 3, args);
JS_FreeValue(ctx, args[0]); JS_FreeValue(ctx, args[0]);
if (!magic) if (!magic)
JS_FreeValue(ctx, args[1]); JS_FreeValue(ctx, args[1]);
@ -45063,7 +45063,7 @@ static JSValue promise_reaction_job(JSContext *ctx, int argc,
functions */ functions */
if (!JS_IsUndefined(func)) { if (!JS_IsUndefined(func)) {
res2 = JS_Call(ctx, func, JS_UNDEFINED, res2 = JS_Call(ctx, func, JS_UNDEFINED,
1, (JSValue *)&res); 1, &res);
} else { } else {
res2 = JS_UNDEFINED; res2 = JS_UNDEFINED;
} }
@ -45143,10 +45143,10 @@ static JSValue js_promise_resolve_thenable_job(JSContext *ctx,
then = argv[2]; then = argv[2];
if (js_create_resolving_functions(ctx, args, promise) < 0) if (js_create_resolving_functions(ctx, args, promise) < 0)
return JS_EXCEPTION; return JS_EXCEPTION;
res = JS_Call(ctx, then, thenable, 2, (JSValue *)args); res = JS_Call(ctx, then, thenable, 2, args);
if (JS_IsException(res)) { if (JS_IsException(res)) {
JSValue error = JS_GetException(ctx); JSValue error = JS_GetException(ctx);
res = JS_Call(ctx, args[1], JS_UNDEFINED, 1, (JSValue *)&error); res = JS_Call(ctx, args[1], JS_UNDEFINED, 1, &error);
JS_FreeValue(ctx, error); JS_FreeValue(ctx, error);
} }
JS_FreeValue(ctx, args[0]); JS_FreeValue(ctx, args[0]);
@ -45342,11 +45342,11 @@ static JSValue js_promise_constructor(JSContext *ctx, JSValue new_target,
JS_SetOpaque(obj, s); JS_SetOpaque(obj, s);
if (js_create_resolving_functions(ctx, args, obj)) if (js_create_resolving_functions(ctx, args, obj))
goto fail; goto fail;
ret = JS_Call(ctx, executor, JS_UNDEFINED, 2, (JSValue *)args); ret = JS_Call(ctx, executor, JS_UNDEFINED, 2, args);
if (JS_IsException(ret)) { if (JS_IsException(ret)) {
JSValue ret2, error; JSValue ret2, error;
error = JS_GetException(ctx); error = JS_GetException(ctx);
ret2 = JS_Call(ctx, args[1], JS_UNDEFINED, 1, (JSValue *)&error); ret2 = JS_Call(ctx, args[1], JS_UNDEFINED, 1, &error);
JS_FreeValue(ctx, error); JS_FreeValue(ctx, error);
if (JS_IsException(ret2)) if (JS_IsException(ret2))
goto fail1; goto fail1;
@ -45403,10 +45403,10 @@ static JSValue js_new_promise_capability(JSContext *ctx,
if (JS_IsUndefined(ctor)) { if (JS_IsUndefined(ctor)) {
result_promise = js_promise_constructor(ctx, ctor, 1, result_promise = js_promise_constructor(ctx, ctor, 1,
(JSValue *)&executor); &executor);
} else { } else {
result_promise = JS_CallConstructor(ctx, ctor, 1, result_promise = JS_CallConstructor(ctx, ctor, 1,
(JSValue *)&executor); &executor);
} }
if (JS_IsException(result_promise)) if (JS_IsException(result_promise))
goto fail; goto fail;
@ -45566,10 +45566,10 @@ static JSValue js_promise_all_resolve_element(JSContext *ctx,
error = js_aggregate_error_constructor(ctx, values); error = js_aggregate_error_constructor(ctx, values);
if (JS_IsException(error)) if (JS_IsException(error))
return JS_EXCEPTION; return JS_EXCEPTION;
ret = JS_Call(ctx, resolve, JS_UNDEFINED, 1, (JSValue *)&error); ret = JS_Call(ctx, resolve, JS_UNDEFINED, 1, &error);
JS_FreeValue(ctx, error); JS_FreeValue(ctx, error);
} else { } else {
ret = JS_Call(ctx, resolve, JS_UNDEFINED, 1, (JSValue *)&values); ret = JS_Call(ctx, resolve, JS_UNDEFINED, 1, &values);
} }
if (JS_IsException(ret)) if (JS_IsException(ret))
return ret; return ret;
@ -45605,7 +45605,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val,
fail_reject: fail_reject:
error = JS_GetException(ctx); error = JS_GetException(ctx);
ret = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, 1, ret = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, 1,
(JSValue *)&error); &error);
JS_FreeValue(ctx, error); JS_FreeValue(ctx, error);
if (JS_IsException(ret)) if (JS_IsException(ret))
goto fail; goto fail;
@ -45636,7 +45636,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val,
if (done) if (done)
break; break;
next_promise = JS_Call(ctx, promise_resolve, next_promise = JS_Call(ctx, promise_resolve,
this_val, 1, (JSValue *)&item); this_val, 1, &item);
JS_FreeValue(ctx, item); JS_FreeValue(ctx, item);
if (JS_IsException(next_promise)) { if (JS_IsException(next_promise)) {
fail_reject1: fail_reject1:
@ -45644,7 +45644,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val,
goto fail_reject; goto fail_reject;
} }
resolve_element_data[0] = js_bool(FALSE); resolve_element_data[0] = js_bool(FALSE);
resolve_element_data[1] = (JSValue)js_int32(index); resolve_element_data[1] = js_int32(index);
resolve_element_data[2] = values; resolve_element_data[2] = values;
resolve_element_data[3] = resolving_funcs[is_promise_any]; resolve_element_data[3] = resolving_funcs[is_promise_any];
resolve_element_data[4] = resolve_element_env; resolve_element_data[4] = resolve_element_env;
@ -45704,7 +45704,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValue this_val,
values = error; values = error;
} }
ret = JS_Call(ctx, resolving_funcs[is_promise_any], JS_UNDEFINED, ret = JS_Call(ctx, resolving_funcs[is_promise_any], JS_UNDEFINED,
1, (JSValue *)&values); 1, &values);
if (check_exception_free(ctx, ret)) if (check_exception_free(ctx, ret))
goto fail_reject; goto fail_reject;
} }
@ -45747,7 +45747,7 @@ static JSValue js_promise_race(JSContext *ctx, JSValue this_val,
fail_reject: fail_reject:
error = JS_GetException(ctx); error = JS_GetException(ctx);
ret = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, 1, ret = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, 1,
(JSValue *)&error); &error);
JS_FreeValue(ctx, error); JS_FreeValue(ctx, error);
if (JS_IsException(ret)) if (JS_IsException(ret))
goto fail; goto fail;
@ -45766,7 +45766,7 @@ static JSValue js_promise_race(JSContext *ctx, JSValue this_val,
if (done) if (done)
break; break;
next_promise = JS_Call(ctx, promise_resolve, next_promise = JS_Call(ctx, promise_resolve,
this_val, 1, (JSValue *)&item); this_val, 1, &item);
JS_FreeValue(ctx, item); JS_FreeValue(ctx, item);
if (JS_IsException(next_promise)) { if (JS_IsException(next_promise)) {
fail_reject1: fail_reject1:
@ -45774,7 +45774,7 @@ static JSValue js_promise_race(JSContext *ctx, JSValue this_val,
goto fail_reject; goto fail_reject;
} }
ret = JS_InvokeFree(ctx, next_promise, JS_ATOM_then, 2, ret = JS_InvokeFree(ctx, next_promise, JS_ATOM_then, 2,
(JSValue *)resolving_funcs); resolving_funcs);
if (check_exception_free(ctx, ret)) if (check_exception_free(ctx, ret))
goto fail_reject1; goto fail_reject1;
} }
@ -45867,7 +45867,7 @@ static JSValue js_promise_then(JSContext *ctx, JSValue this_val,
if (JS_IsException(result_promise)) if (JS_IsException(result_promise))
return result_promise; return result_promise;
ret = perform_promise_then(ctx, this_val, argv, ret = perform_promise_then(ctx, this_val, argv,
(JSValue *)resolving_funcs); resolving_funcs);
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
JS_FreeValue(ctx, resolving_funcs[i]); JS_FreeValue(ctx, resolving_funcs[i]);
if (ret) { if (ret) {
@ -45911,7 +45911,7 @@ static JSValue js_promise_then_finally_func(JSContext *ctx, JSValue this_val,
res = JS_Call(ctx, onFinally, JS_UNDEFINED, 0, NULL); res = JS_Call(ctx, onFinally, JS_UNDEFINED, 0, NULL);
if (JS_IsException(res)) if (JS_IsException(res))
return res; return res;
promise = js_promise_resolve(ctx, ctor, 1, (JSValue *)&res, 0); promise = js_promise_resolve(ctx, ctor, 1, &res, 0);
JS_FreeValue(ctx, res); JS_FreeValue(ctx, res);
if (JS_IsException(promise)) if (JS_IsException(promise))
return promise; return promise;
@ -45926,7 +45926,7 @@ static JSValue js_promise_then_finally_func(JSContext *ctx, JSValue this_val,
JS_FreeValue(ctx, promise); JS_FreeValue(ctx, promise);
return then_func; return then_func;
} }
ret = JS_InvokeFree(ctx, promise, JS_ATOM_then, 1, (JSValue *)&then_func); ret = JS_InvokeFree(ctx, promise, JS_ATOM_then, 1, &then_func);
JS_FreeValue(ctx, then_func); JS_FreeValue(ctx, then_func);
return ret; return ret;
} }
@ -45960,7 +45960,7 @@ static JSValue js_promise_finally(JSContext *ctx, JSValue this_val,
} }
} }
JS_FreeValue(ctx, ctor); JS_FreeValue(ctx, ctor);
ret = JS_Invoke(ctx, this_val, JS_ATOM_then, 2, (JSValue *)then_funcs); ret = JS_Invoke(ctx, this_val, JS_ATOM_then, 2, then_funcs);
JS_FreeValue(ctx, then_funcs[0]); JS_FreeValue(ctx, then_funcs[0]);
JS_FreeValue(ctx, then_funcs[1]); JS_FreeValue(ctx, then_funcs[1]);
return ret; return ret;
@ -46003,7 +46003,7 @@ static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext *ctx,
{ {
JSValue func_data[1]; JSValue func_data[1];
func_data[0] = (JSValue)js_bool(done); func_data[0] = js_bool(done);
return JS_NewCFunctionData(ctx, js_async_from_sync_iterator_unwrap, return JS_NewCFunctionData(ctx, js_async_from_sync_iterator_unwrap,
1, 0, 1, func_data); 1, 0, 1, func_data);
} }
@ -46126,7 +46126,7 @@ static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValue this_val
is_reject = 1; is_reject = 1;
done_resolve: done_resolve:
res2 = JS_Call(ctx, resolving_funcs[is_reject], JS_UNDEFINED, res2 = JS_Call(ctx, resolving_funcs[is_reject], JS_UNDEFINED,
1, (JSValue *)&err); 1, &err);
JS_FreeValue(ctx, err); JS_FreeValue(ctx, err);
JS_FreeValue(ctx, res2); JS_FreeValue(ctx, res2);
JS_FreeValue(ctx, resolving_funcs[0]); JS_FreeValue(ctx, resolving_funcs[0]);
@ -46138,7 +46138,7 @@ static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValue this_val
int res; int res;
value_wrapper_promise = js_promise_resolve(ctx, ctx->promise_ctor, value_wrapper_promise = js_promise_resolve(ctx, ctx->promise_ctor,
1, (JSValue *)&value, 0); 1, &value, 0);
if (JS_IsException(value_wrapper_promise)) { if (JS_IsException(value_wrapper_promise)) {
JS_FreeValue(ctx, value); JS_FreeValue(ctx, value);
goto reject; goto reject;
@ -46154,8 +46154,8 @@ static JSValue js_async_from_sync_iterator_next(JSContext *ctx, JSValue this_val
resolve_reject[1] = JS_UNDEFINED; resolve_reject[1] = JS_UNDEFINED;
res = perform_promise_then(ctx, value_wrapper_promise, res = perform_promise_then(ctx, value_wrapper_promise,
(JSValue *)resolve_reject, resolve_reject,
(JSValue *)resolving_funcs); resolving_funcs);
JS_FreeValue(ctx, resolve_reject[0]); JS_FreeValue(ctx, resolve_reject[0]);
JS_FreeValue(ctx, value_wrapper_promise); JS_FreeValue(ctx, value_wrapper_promise);
JS_FreeValue(ctx, resolving_funcs[0]); JS_FreeValue(ctx, resolving_funcs[0]);
@ -46959,7 +46959,7 @@ static JSValue js_date_constructor(JSContext *ctx, JSValue new_target,
} }
v = JS_ToPrimitive(ctx, argv[0], HINT_NONE); v = JS_ToPrimitive(ctx, argv[0], HINT_NONE);
if (JS_IsString(v)) { if (JS_IsString(v)) {
dv = js_Date_parse(ctx, JS_UNDEFINED, 1, (JSValue *)&v); dv = js_Date_parse(ctx, JS_UNDEFINED, 1, &v);
JS_FreeValue(ctx, v); JS_FreeValue(ctx, v);
if (JS_IsException(dv)) if (JS_IsException(dv))
return JS_EXCEPTION; return JS_EXCEPTION;
@ -47788,7 +47788,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
JS_PROP_HAS_GET | JS_PROP_HAS_SET | JS_PROP_HAS_GET | JS_PROP_HAS_SET |
JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE); JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE);
JS_FreeValue(ctx, obj1); JS_FreeValue(ctx, obj1);
JS_FreeValue(ctx, js_object_seal(ctx, JS_UNDEFINED, 1, (JSValue *)&ctx->throw_type_error, 1)); JS_FreeValue(ctx, js_object_seal(ctx, JS_UNDEFINED, 1, &ctx->throw_type_error, 1));
ctx->global_obj = JS_NewObject(ctx); ctx->global_obj = JS_NewObject(ctx);
ctx->global_var_obj = JS_NewObjectProto(ctx, JS_NULL); ctx->global_var_obj = JS_NewObjectProto(ctx, JS_NULL);
@ -48326,7 +48326,7 @@ static JSValue js_array_buffer_slice(JSContext *ctx,
} else { } else {
JSValue args[1]; JSValue args[1];
args[0] = JS_NewInt64(ctx, new_len); args[0] = JS_NewInt64(ctx, new_len);
new_obj = JS_CallConstructor(ctx, ctor, 1, (JSValue *)args); new_obj = JS_CallConstructor(ctx, ctor, 1, args);
JS_FreeValue(ctx, ctor); JS_FreeValue(ctx, ctor);
JS_FreeValue(ctx, args[0]); JS_FreeValue(ctx, args[0]);
} }
@ -49761,8 +49761,8 @@ static int js_TA_cmp_generic(const void *a, const void *b, void *opaque) {
cmp = (a_idx > b_idx) - (a_idx < b_idx); cmp = (a_idx > b_idx) - (a_idx < b_idx);
} }
done: done:
JS_FreeValue(ctx, (JSValue)argv[0]); JS_FreeValue(ctx, argv[0]);
JS_FreeValue(ctx, (JSValue)argv[1]); JS_FreeValue(ctx, argv[1]);
} }
return cmp; return cmp;
} }

View file

@ -588,7 +588,7 @@ static inline JSValue JS_DupValue(JSContext *ctx, JSValue v)
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v); JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
p->ref_count++; p->ref_count++;
} }
return (JSValue)v; return v;
} }
static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValue v) static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValue v)
@ -597,7 +597,7 @@ static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValue v)
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v); JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
p->ref_count++; p->ref_count++;
} }
return (JSValue)v; return v;
} }
JS_EXTERN int JS_ToBool(JSContext *ctx, JSValue val); /* return -1 for JS_EXCEPTION */ JS_EXTERN int JS_ToBool(JSContext *ctx, JSValue val); /* return -1 for JS_EXCEPTION */

View file

@ -508,7 +508,7 @@ static void *agent_start(void *arg)
NULL, NULL, TRUE); NULL, NULL, TRUE);
args[1] = JS_NewInt32(ctx, agent->broadcast_val); args[1] = JS_NewInt32(ctx, agent->broadcast_val);
ret_val = JS_Call(ctx, agent->broadcast_func, JS_UNDEFINED, ret_val = JS_Call(ctx, agent->broadcast_func, JS_UNDEFINED,
2, (JSValue *)args); 2, args);
JS_FreeValue(ctx, args[0]); JS_FreeValue(ctx, args[0]);
JS_FreeValue(ctx, args[1]); JS_FreeValue(ctx, args[1]);
if (JS_IsException(ret_val)) if (JS_IsException(ret_val))