aboutsummaryrefslogtreecommitdiff
path: root/include/compiler.h
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-07-17 19:23:16 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit84e65c63e7482590d535e86f7660a00ae8a0cecb (patch)
treec79de87b7136e96b977003db85d43e5e676bbfc1 /include/compiler.h
parent85c654a102701958d3748e82ecac9c1bc4dbbcba (diff)
Start on amal program
Fix mutex issue in lhs expr which can cause a deadlock when a file has an error and throws and doesn't close the mutex and another thread waits for that mutex. The mutex can instead be removed and ignore race conditions which are uncommon. This should improve memory usage and performance.
Diffstat (limited to 'include/compiler.h')
-rw-r--r--include/compiler.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/compiler.h b/include/compiler.h
index 3a31ad9..0ae8532 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -8,6 +8,7 @@
#include "std/thread.h"
#include "compiler_options.h"
#include "ast.h"
+#include "program.h"
#define AMAL_COMPILER_OK 0
/* General error */
@@ -32,6 +33,7 @@ typedef struct {
struct amal_compiler {
amal_default_types default_types;
amal_compiler_options options;
+ amal_program *program;
ScopedAllocator allocator;
Scope root_scope;
Buffer/*<Parser*>*/ parsers;
@@ -40,22 +42,19 @@ struct amal_compiler {
ParserThreadData *threads;
int usable_thread_count;
bool started;
- bool used;
amal_mutex mutex;
int generic_work_object_index;
};
void amal_compiler_options_init(amal_compiler_options *self);
-/* If @options is NULL, then default values are used */
-CHECK_RESULT int amal_compiler_init(amal_compiler *self, const amal_compiler_options *options);
-CHECK_RESULT int amal_compiler_deinit(amal_compiler *self);
/*
-This function creates a copy of @filepath in the same thread it's called from
-so it doesn't have to survive longer than this function call.
+ If @options is NULL, then default values are used.
+ You should run @amal_program_deinit even @amal_compiler_load_file fails, to cleanup memory.
+ This function creates a copy of @filepath so it doesn't have to survive longer than this function call.
+ The file has to be in utf-8 format and it can optionally have utf-8 BOM.
*/
-CHECK_RESULT int amal_compiler_load_file(amal_compiler *self, const char *filepath);
+CHECK_RESULT int amal_compiler_load_file(amal_compiler_options *options, amal_program *program, const char *filepath);
CHECK_RESULT int amal_compiler_internal_load_file(amal_compiler *self, const char *filepath, FileScopeReference **file_scope);
-/* TODO: amal_compiler_unload_file */
#endif