From 01052811be08444458576dda994d15f8823560ea Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 25 Jun 2024 23:25:29 +0300 Subject: initial rewrite to use ejit + Doesn't actually link yet due to missing stuff from ejit, will have to add them (tomorrow?) --- include/posthaste/ast.h | 8 ++++---- include/posthaste/compile.h | 8 -------- include/posthaste/interpret.h | 8 -------- include/posthaste/lower.h | 13 +++---------- 4 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 include/posthaste/compile.h delete mode 100644 include/posthaste/interpret.h (limited to 'include') diff --git a/include/posthaste/ast.h b/include/posthaste/ast.h index c47e28c..64e987f 100644 --- a/include/posthaste/ast.h +++ b/include/posthaste/ast.h @@ -68,10 +68,10 @@ enum type_kind { /* used by lower.c, defined here to avoid circular dependencies */ struct loc { - /* is this a local location? 1 local, 0 global */ - uint32_t l : 1; - /* offset within either local stack or global array */ - uint32_t o : 31; + /* offset within either local stack */ + uintptr_t s; + /* offset within global array */ + uintptr_t g; }; /* where a node was generated from in the source file */ diff --git a/include/posthaste/compile.h b/include/posthaste/compile.h deleted file mode 100644 index e149ac6..0000000 --- a/include/posthaste/compile.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POSTHASTE_COMPILE_H -#define POSTHASTE_COMPILE_H - -/* stuff related to compiling bytecode to machine code */ - -void compile(); - -#endif /* POSTHASTE_COMPILE_H */ diff --git a/include/posthaste/interpret.h b/include/posthaste/interpret.h deleted file mode 100644 index 50bdbf3..0000000 --- a/include/posthaste/interpret.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POSTHASTE_INTERPRET_H -#define POSTHASTE_INTERPRET_H - -/* stuff related to interpreting our bytecode */ - -void interpret(); - -#endif /* POSTHASTE_INTERPRET_H */ diff --git a/include/posthaste/lower.h b/include/posthaste/lower.h index d5b1d7d..f7699ec 100644 --- a/include/posthaste/lower.h +++ b/include/posthaste/lower.h @@ -5,6 +5,7 @@ #include #include +#include enum insn_kind { LABEL, /* no-op during interpretation, @@ -77,19 +78,11 @@ struct fn { /* maximum stack pointer value to know how much stack space to allocate */ size_t max_sp; - /* instruction buffer */ - struct vec insns; - /* used by jit */ /* how many formal parameters */ size_t params; - /* machine code buffer, for whatever reason seems to commonly be called 'arena' - * in JIT compilers, just following the convention here*/ - void *arena; - - /* size of arena */ - size_t size; + struct ejit_func *f; }; int lower_ast(struct ast *tree); @@ -101,7 +94,7 @@ void destroy_lowering(); static inline bool is_null_loc(struct loc l) { - return l.l == 0 && l.o == 1; + return l.g == 1 && l.s == 0; } #endif /* POSTHASTE_LOWER_H */ -- cgit v1.2.3