diff --git a/vm/backend/tb.c b/vm/backend/tb.c index cfe5ae5e..81bf18e8 100644 --- a/vm/backend/tb.c +++ b/vm/backend/tb.c @@ -38,14 +38,17 @@ size_t vm_tb_ptr_len = 0; void **vm_tb_ptr_globals = NULL; size_t vm_tb_ptr_alloc = 0; +// void GC_add_roots(void *, void *); + TB_Node *vm_tb_ptr_name(vm_tb_state_t *state, const char *name, void *value) { - if (value != NULL) { - if (vm_tb_ptr_len + 1 >= vm_tb_ptr_alloc) { - vm_tb_ptr_alloc = (vm_tb_ptr_len + 1) * 2; - vm_tb_ptr_globals = vm_realloc(vm_tb_ptr_globals, sizeof(void *) * vm_tb_ptr_alloc); - } - vm_tb_ptr_globals[vm_tb_ptr_len++] = value; - } + // if (value != NULL) { + // if (vm_tb_ptr_len + 1 >= vm_tb_ptr_alloc) { + // vm_tb_ptr_alloc = (vm_tb_ptr_len + 1) * 2; + // vm_tb_ptr_globals = vm_realloc(vm_tb_ptr_globals, sizeof(void *) * vm_tb_ptr_alloc); + // GC_add_roots(vm_tb_ptr_globals, &vm_tb_ptr_globals[vm_tb_ptr_alloc]); + // } + // vm_tb_ptr_globals[vm_tb_ptr_len++] = value; + // } return tb_inst_uint(state->fun, TB_TYPE_PTR, (uint64_t)value); } diff --git a/vm/config.h b/vm/config.h index b1315b06..d0fb957a 100644 --- a/vm/config.h +++ b/vm/config.h @@ -4,6 +4,7 @@ #define VM_USE_DUMP 1 #define VM_NO_TAILCALL 1 +#define VM_FORMAT_FLOAT "%.14g" struct vm_config_t; typedef struct vm_config_t vm_config_t; diff --git a/vm/std/io.c b/vm/std/io.c index ac6f207a..140f2a69 100644 --- a/vm/std/io.c +++ b/vm/std/io.c @@ -100,11 +100,11 @@ void vm_io_print_lit(vm_io_buffer_t *out, vm_std_value_t value) { break; } case VM_TAG_F32: { - vm_io_buffer_format(out, "%f", value.value.f32); + vm_io_buffer_format(out, VM_FORMAT_FLOAT, value.value.f32); break; } case VM_TAG_F64: { - vm_io_buffer_format(out, "%f", value.value.f64); + vm_io_buffer_format(out, VM_FORMAT_FLOAT, value.value.f64); break; } case VM_TAG_FFI: { @@ -172,12 +172,12 @@ void vm_io_debug(vm_io_buffer_t *out, size_t indent, const char *prefix, vm_std_ } case VM_TAG_F32: { vm_indent(out, indent, prefix); - vm_io_buffer_format(out, "%f\n", value.value.f32); + vm_io_buffer_format(out, VM_FORMAT_FLOAT "\n", value.value.f32); break; } case VM_TAG_F64: { vm_indent(out, indent, prefix); - vm_io_buffer_format(out, "%f\n", value.value.f64); + vm_io_buffer_format(out, VM_FORMAT_FLOAT "\n", value.value.f64); break; } case VM_TAG_STR: { @@ -285,7 +285,7 @@ void vm_io_debug(vm_io_buffer_t *out, size_t indent, const char *prefix, vm_std_ .value = p.val_val, }; char buf[64]; - snprintf(buf, 63, "%f = ", p.key_val.f64); + snprintf(buf, 63, VM_FORMAT_FLOAT " = ", p.key_val.f64); vm_io_debug(out, indent + 1, buf, val, &next); break; } diff --git a/vm/std/std.c b/vm/std/std.c index addd6507..bcba9205 100644 --- a/vm/std/std.c +++ b/vm/std/std.c @@ -209,11 +209,11 @@ void vm_value_buffer_tostring(vm_io_buffer_t *buf, vm_std_value_t value) { break; } case VM_TAG_F32: { - vm_io_buffer_format(buf, "%f", value.value.f32); + vm_io_buffer_format(buf, VM_FORMAT_FLOAT, value.value.f32); break; } case VM_TAG_F64: { - vm_io_buffer_format(buf, "%f", value.value.f64); + vm_io_buffer_format(buf, VM_FORMAT_FLOAT, value.value.f64); break; } case VM_TAG_STR: {