Skip to content

Commit 1db884b

Browse files
authored
Unify JS_DumpValue functions (#349)
- merge `JS_DumpValue(ctx, val)` and `JS_DumpValueShort(rt, val)` as `JS_DumpValue(rt, val)` - remove unused `JS_PrintValue(ctx, val)`
1 parent b8a2cf4 commit 1db884b

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

quickjs.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,19 +1029,15 @@ static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen,
10291029
static JSValue JS_EvalObject(JSContext *ctx, JSValue this_obj,
10301030
JSValue val, int flags, int scope_idx);
10311031
JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...);
1032-
static __maybe_unused void JS_DumpAtoms(JSRuntime *rt);
1033-
static __maybe_unused void JS_DumpString(JSRuntime *rt,
1034-
const JSString *p);
1032+
1033+
static __maybe_unused void JS_DumpString(JSRuntime *rt, const JSString *p);
10351034
static __maybe_unused void JS_DumpObjectHeader(JSRuntime *rt);
10361035
static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p);
10371036
static __maybe_unused void JS_DumpGCObject(JSRuntime *rt, JSGCObjectHeader *p);
1038-
static __maybe_unused void JS_DumpValueShort(JSRuntime *rt,
1039-
JSValue val);
1040-
static __maybe_unused void JS_DumpValue(JSContext *ctx, JSValue val);
1041-
static __maybe_unused void JS_PrintValue(JSContext *ctx,
1042-
const char *str,
1043-
JSValue val);
1037+
static __maybe_unused void JS_DumpValue(JSRuntime *rt, JSValue val);
1038+
static __maybe_unused void JS_DumpAtoms(JSRuntime *rt);
10441039
static __maybe_unused void JS_DumpShapes(JSRuntime *rt);
1040+
10451041
static JSValue js_function_apply(JSContext *ctx, JSValue this_val,
10461042
int argc, JSValue *argv, int magic);
10471043
static void js_array_finalizer(JSRuntime *rt, JSValue val);
@@ -5476,7 +5472,7 @@ void __JS_FreeValueRT(JSRuntime *rt, JSValue v)
54765472
if (tag == JS_TAG_OBJECT) {
54775473
JS_DumpObject(rt, JS_VALUE_GET_OBJ(v));
54785474
} else {
5479-
JS_DumpValueShort(rt, v);
5475+
JS_DumpValue(rt, v);
54805476
printf("\n");
54815477
}
54825478
}
@@ -11572,7 +11568,7 @@ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p)
1157211568
switch (p->class_id) {
1157311569
case JS_CLASS_ARRAY:
1157411570
case JS_CLASS_ARGUMENTS:
11575-
JS_DumpValueShort(rt, p->u.array.u.values[i]);
11571+
JS_DumpValue(rt, p->u.array.u.values[i]);
1157611572
break;
1157711573
case JS_CLASS_UINT8C_ARRAY:
1157811574
case JS_CLASS_INT8_ARRAY:
@@ -11617,7 +11613,7 @@ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p)
1161711613
js_autoinit_get_id(pr),
1161811614
(void *)pr->u.init.opaque);
1161911615
} else {
11620-
JS_DumpValueShort(rt, pr->u.value);
11616+
JS_DumpValue(rt, pr->u.value);
1162111617
}
1162211618
is_first = FALSE;
1162311619
}
@@ -11633,11 +11629,11 @@ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p)
1163311629
printf(" Closure:");
1163411630
for(i = 0; i < b->closure_var_count; i++) {
1163511631
printf(" ");
11636-
JS_DumpValueShort(rt, var_refs[i]->value);
11632+
JS_DumpValue(rt, var_refs[i]->value);
1163711633
}
1163811634
if (p->u.func.home_object) {
1163911635
printf(" HomeObject: ");
11640-
JS_DumpValueShort(rt, JS_MKPTR(JS_TAG_OBJECT, p->u.func.home_object));
11636+
JS_DumpValue(rt, JS_MKPTR(JS_TAG_OBJECT, p->u.func.home_object));
1164111637
}
1164211638
}
1164311639
}
@@ -11676,8 +11672,7 @@ static __maybe_unused void JS_DumpGCObject(JSRuntime *rt, JSGCObjectHeader *p)
1167611672
}
1167711673
}
1167811674

11679-
static __maybe_unused void JS_DumpValueShort(JSRuntime *rt,
11680-
JSValue val)
11675+
static __maybe_unused void JS_DumpValue(JSRuntime *rt, JSValue val)
1168111676
{
1168211677
uint32_t tag = JS_VALUE_GET_NORM_TAG(val);
1168311678
const char *str;
@@ -11759,21 +11754,6 @@ static __maybe_unused void JS_DumpValueShort(JSRuntime *rt,
1175911754
}
1176011755
}
1176111756

11762-
static __maybe_unused void JS_DumpValue(JSContext *ctx,
11763-
JSValue val)
11764-
{
11765-
JS_DumpValueShort(ctx->rt, val);
11766-
}
11767-
11768-
static __maybe_unused void JS_PrintValue(JSContext *ctx,
11769-
const char *str,
11770-
JSValue val)
11771-
{
11772-
printf("%s=", str);
11773-
JS_DumpValueShort(ctx->rt, val);
11774-
printf("\n");
11775-
}
11776-
1177711757
/* return -1 if exception (proxy case) or TRUE/FALSE */
1177811758
int JS_IsArray(JSContext *ctx, JSValue val)
1177911759
{
@@ -27722,7 +27702,7 @@ static void dump_byte_code(JSContext *ctx, int pass,
2772227702
has_pool_idx:
2772327703
printf(" %u: ", idx);
2772427704
if (idx < cpool_count) {
27725-
JS_DumpValue(ctx, cpool[idx]);
27705+
JS_DumpValue(ctx->rt, cpool[idx]);
2772627706
}
2772727707
break;
2772827708
case OP_FMT_atom:
@@ -45740,7 +45720,7 @@ static JSValue js_promise_resolve_function_call(JSContext *ctx,
4574045720
resolution = JS_UNDEFINED;
4574145721
#ifdef DUMP_PROMISE
4574245722
printf("js_promise_resolving_function_call: is_reject=%d resolution=", is_reject);
45743-
JS_DumpValue(ctx, resolution);
45723+
JS_DumpValue(ctx->rt, resolution);
4574445724
printf("\n");
4574545725
#endif
4574645726
if (is_reject || !JS_IsObject(resolution)) {

0 commit comments

Comments
 (0)