char time_buf[128] = {0};
time_t now = time(NULL);
strftime(time_buf, 128, "%X", localtime(&now));
- bh_printf("\e[1;1H\e[30;104m [BUILT] %s \e[0m", time_buf);
+ bh_printf("\e[1;1H\e[30;105m Onyx " VERSION " \e[30;104m Built %s \e[0m", time_buf);
i32 errors = bh_arr_length(context.errors.errors);
if (errors == 0) {
- bh_printf("\e[30;102m [ERRORS] 0 \e[0m");
+ bh_printf("\e[30;102m Errors 0 \e[0m");
} else {
- bh_printf("\e[30;101m [ERRORS] %d \e[0m", errors);
+ bh_printf("\e[30;101m Error%s %d \e[0m", bh_num_plural(errors), errors);
}
watches = bh_file_watch_new();
#load "./logging"
#load "./gc"
+use core.memory
+use core.intrinsics.types {type_is_function}
+
as_allocator :: #match {
macro (a: Allocator) => a
}
return out;
}
+#doc """
+ Copies the internal closure data of a function to the provided allocator,
+ and returns the new closed function.
+"""
+copy_closure :: (f: $F/type_is_function, a: Allocator) -> F {
+ if !f.closure do return f;
+
+ new_closure := raw_alloc(a, f.closure_size);
+ memory.copy(new_closure, f.closure, f.closure_size);
+
+ return F.{ f.__funcidx, new_closure, f.closure_size };
+}
+
TEMPORARY_ALLOCATOR_SIZE :: 1 << 16; // 16Kb
// The global heap allocator, set up upon program intialization.