aboutsummaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-20 10:47:49 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-20 10:47:49 +0300
commit8a98b46ef2b5673fcdf0a9a466857a5de044dfc5 (patch)
treeae548496da015f3319760479e09cfe5a0b1eba5d /src/core.c
parent1cc7990ef7d5483d0434dda412f2d88e0b17df27 (diff)
downloadposthaste-8a98b46ef2b5673fcdf0a9a466857a5de044dfc5.tar.gz
posthaste-8a98b46ef2b5673fcdf0a9a466857a5de044dfc5.zip
add lightening jit
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/core.c b/src/core.c
index c50860e..44aa130 100644
--- a/src/core.c
+++ b/src/core.c
@@ -3,6 +3,7 @@
#include <limits.h>
#include <errno.h>
+#include <posthaste/compile.h>
#include <posthaste/execute.h>
#include <posthaste/parser.h>
#include <posthaste/debug.h>
@@ -12,16 +13,6 @@
#include <posthaste/core.h>
#include <posthaste/ast.h>
-/**
- * Read whole file into a buffer and return pointer to buffer.
- * Possibly kind of silly to have both \p file and \p f.
- * Apparently there's no standardized way to get the file name of a
- * file pointer.
- *
- * @param fname Name of file to read.
- * @param f File pointer.
- * @return Pointer to buffer with file contents.
- */
static char *read_file(const char *fname, FILE *f)
{
fseek(f, 0, SEEK_END);
@@ -91,12 +82,14 @@ int run(const char *fname)
goto out;
}
- if (lower_ast(ast)) {
- ret = -1;
- goto out;
- }
+ lower_ast(ast);
+#ifdef JIT
+ compile(ast);
+ execute_compilation();
+#else
execute();
+#endif
out:
free((void *)buf);