aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-06-25 23:25:29 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-06-25 23:25:29 +0300
commit01052811be08444458576dda994d15f8823560ea (patch)
treec52f2d72ef0ef703e755fcf05ee5d3a02f050acc /include
parent449ca1e570aa421992bbe98c6928def1ba8896fd (diff)
downloadposthaste-01052811be08444458576dda994d15f8823560ea.tar.gz
posthaste-01052811be08444458576dda994d15f8823560ea.zip
initial rewrite to use ejit
+ Doesn't actually link yet due to missing stuff from ejit, will have to add them (tomorrow?)
Diffstat (limited to 'include')
-rw-r--r--include/posthaste/ast.h8
-rw-r--r--include/posthaste/compile.h8
-rw-r--r--include/posthaste/interpret.h8
-rw-r--r--include/posthaste/lower.h13
4 files changed, 7 insertions, 30 deletions
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 <posthaste/ast.h>
#include <posthaste/vec.h>
+#include <ejit/ejit.h>
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 */