aboutsummaryrefslogtreecommitdiff
path: root/include/program.h
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-24 00:48:40 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit7212ea877ed85d3b85af90c902639df44fc493f2 (patch)
treec76d73e9882a832f82cef977efb6fb26fb0e4984 /include/program.h
parentd6f368a3f400fea3e89280262a8147e7ce5d855c (diff)
Add exported variable (only functions for now), export main func, start execution from main func
Diffstat (limited to 'include/program.h')
-rw-r--r--include/program.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/include/program.h b/include/program.h
index 075bfca..e3a4ac9 100644
--- a/include/program.h
+++ b/include/program.h
@@ -31,13 +31,10 @@
#define AMAL_PROGRAM_INSTRUCTION_INVALID_EXTERN_FUNC_INDEX -19
#define AMAL_PROGRAM_NO_SUCH_EXTERNAL_FUNCTION -20
#define AMAL_PROGRAM_EXTERN_FUNC_ALREADY_EXISTS -21
-
-#define AMAL_PROGRAM_MAGIC_NUMBER (u32)0xdec05eba
-#define AMAL_PROGRAM_MAJOR_VERSION 1
-#define AMAL_PROGRAM_MINOR_VERSION 0
-#define AMAL_PROGRAM_PATCH_VERSION 0
-
-#define AMAL_PROGRAM_NUM_REGISTERS 256
+#define AMAL_PROGRAM_INVALID_EXPORTED_FUNCTIONS -22
+#define AMAL_PROGRAM_INVALID_EXPORTED_FUNCTIONS_SIZE -23
+#define AMAL_PROGRAM_INSTRUCTION_INVALID_EXPORTED_FUNC_INDEX -24
+#define AMAL_PROGRAM_NO_MAIN_FUNC -25
#define AMAL_PROGRAM_ARGS_SIZE_VARARGS -1
@@ -53,12 +50,17 @@ typedef struct {
u8 *intermediates_start; /* Reference inside @data */
u8 *strings_start; /* Reference inside @data */
u8 *extern_funcs_start; /* Reference inside @data */
+ u8 *exported_funcs; /* Reference inside @data */
+ u8 *exported_funcs_end; /* Reference inside @data */
+
usize read_index;
+ u32 main_func_instruction_offset;
u16 num_intermediates;
u16 num_strings;
u16 num_functions;
u16 num_extern_functions;
+ u16 num_exported_functions;
ArenaAllocator allocator; /* Owned. Used by @extern_funcs_map */
HashMapType(BufferView, ProgramExternFunc) extern_funcs_map;