#ifndef AMALGAM_COMPILER_H #define AMALGAM_COMPILER_H #include "std/misc.h" #include "std/buffer.h" #include "std/buffer_view.h" #include "std/scoped_allocator.h" #include "std/thread.h" #include "compiler_options.h" #include "ast.h" #include "program.h" #define AMAL_COMPILER_OK 0 /* General error */ #define AMAL_COMPILER_ERR -1 typedef struct { LhsExpr *i8; LhsExpr *i16; LhsExpr *i32; LhsExpr *i64; LhsExpr *u8; LhsExpr *u16; LhsExpr *u32; LhsExpr *u64; LhsExpr *isize; LhsExpr *usize; LhsExpr *f32; LhsExpr *f64; LhsExpr *str; } amal_default_types; struct amal_compiler { amal_default_types default_types; amal_compiler_options options; amal_program *program; ScopedAllocator allocator; Scope root_scope; Buffer/**/ parsers; Buffer/**/ queued_files; HashMap/**/ file_scopes; ParserThreadData *threads; int usable_thread_count; bool started; 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. 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_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); #endif