From 7212ea877ed85d3b85af90c902639df44fc493f2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 24 Aug 2019 00:48:40 +0200 Subject: Add exported variable (only functions for now), export main func, start execution from main func --- include/program.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'include/program.h') 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; -- cgit v1.2.3