summaryrefslogtreecommitdiffhomepage
path: root/vm.c
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 /vm.c
parentbf8522625f55fa2657dee3b9356b20fa0dba725f (diff)
treewide: replace a number of unnecessary type casts
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c13
1 files changed, 8 insertions, 5 deletions
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);