From 6bc52441237fe182c05703d3a7e1d93d208ce5e7 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 26 Apr 2024 19:03:48 +0300 Subject: rewrite interpeter --- src/compile.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'src/compile.c') diff --git a/src/compile.c b/src/compile.c index 11b75a5..dd4c73d 100644 --- a/src/compile.c +++ b/src/compile.c @@ -4,12 +4,11 @@ #include #include +#include #include #include -#define UNUSED(x) (void)x - static void compile_fn(struct fn *f); static void *alloc_arena(size_t size) @@ -393,19 +392,7 @@ static void compile_load_day(jit_state_t *j, struct insn i) static int64_t load_weekday(int64_t i0) { struct tm time = tm_from_date((ph_date_t)i0); - - const char *day = "Sunday"; - switch (time.tm_wday) { - case 0: day = "Sunday"; break; - case 1: day = "Monday"; break; - case 2: day = "Tuesday"; break; - case 3: day = "Wednesday"; break; - case 4: day = "Thursday"; break; - case 5: day = "Friday"; break; - case 6: day = "Saturday"; break; - } - - return (int64_t)day; + return (int64_t)time.tm_wday; } static void compile_load_weekday(jit_state_t *j, struct insn i) @@ -638,16 +625,3 @@ void compile() struct fn *f = find_fn(0); compile_fn(f); } - -void execute_compilation() -{ - struct fn *f = find_fn(0); - void (*p)(int64_t *globals) = f->arena; - - struct vec globals = vec_create(sizeof(int64_t)); - vec_reserve(&globals, 65535); - - p(globals.buf); - - vec_destroy(&globals); -} -- cgit v1.2.3