summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-05-26 14:06:00 +0200
committerJo-Philipp Wich <jo@mein.io>2021-07-11 15:49:14 +0200
commit3974e71acc9c7316d9840b298f0c444b6040a269 (patch)
tree5fba43084ba9466cb3362c1c99eac82f5cd3132d
parentbf8522625f55fa2657dee3b9356b20fa0dba725f (diff)
treewide: replace a number of unnecessary type casts
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--types.c8
-rw-r--r--vm.c13
2 files changed, 12 insertions, 9 deletions
diff --git a/types.c b/types.c
index 706ffd1..520727a 100644
--- a/types.c
+++ b/types.c
@@ -162,9 +162,9 @@ ucv_gc_mark(uc_value_t *uv)
ucv_set_mark(uv);
for (i = 0; i < function->nupvals; i++)
- ucv_gc_mark((uc_value_t *)closure->upvals[i]);
+ ucv_gc_mark(&closure->upvals[i]->header);
- ucv_gc_mark((uc_value_t *)function);
+ ucv_gc_mark(&function->header);
break;
@@ -238,9 +238,9 @@ ucv_free(uc_value_t *uv, bool retain)
ref = &closure->ref;
for (i = 0; i < function->nupvals; i++)
- ucv_put_value((uc_value_t *)closure->upvals[i], retain);
+ ucv_put_value(&closure->upvals[i]->header, retain);
- ucv_put_value((uc_value_t *)function, retain);
+ ucv_put_value(&function->header, retain);
break;
case UC_RESSOURCE:
diff --git a/vm.c b/vm.c
index abea567..f990628 100644
--- a/vm.c
+++ b/vm.c
@@ -556,7 +556,7 @@ uc_dump_insn(uc_vm *vm, uint8_t *pos, enum insn_type insn)
uc_value_t *cnst = NULL;
size_t srcpos;
- srcpos = ucv_function_srcpos((uc_value_t *)frame->closure->function, pos - chunk->entries);
+ srcpos = ucv_function_srcpos(&frame->closure->function->header, pos - chunk->entries);
if (last_srcpos == 0 || last_source != frame->closure->function->source || srcpos != last_srcpos) {
buf = xprintbuf_new();
@@ -771,7 +771,7 @@ uc_vm_capture_stacktrace(uc_vm *vm, size_t i)
function = frame->closure->function;
off = (frame->ip - uc_vm_frame_chunk(frame)->entries) - 1;
- srcpos = ucv_function_srcpos((uc_value_t *)function, off);
+ srcpos = ucv_function_srcpos(&function->header, off);
ucv_object_add(entry, "filename", ucv_string_new(function->source->filename));
ucv_object_add(entry, "line", ucv_int64_new(uc_source_get_line(function->source, &srcpos)));
@@ -826,7 +826,7 @@ uc_vm_get_error_context(uc_vm *vm)
return NULL;
chunk = uc_vm_frame_chunk(frame);
- offset = ucv_function_srcpos((uc_value_t *)frame->closure->function, (frame->ip - chunk->entries) - 1);
+ offset = ucv_function_srcpos(&frame->closure->function->header, (frame->ip - chunk->entries) - 1);
stacktrace = uc_vm_capture_stacktrace(vm, i);
buf = ucv_stringbuf_new();
@@ -1956,8 +1956,11 @@ uc_vm_callframe_pop(uc_vm *vm)
ucv_put(uc_vm_stack_pop(vm));
/* release function */
- ucv_put((uc_value_t *)frame->closure);
- ucv_put((uc_value_t *)frame->cfunction);
+ if (frame->closure)
+ ucv_put(&frame->closure->header);
+
+ if (frame->cfunction)
+ ucv_put(&frame->cfunction->header);
/* release context */
ucv_put(frame->ctx);