From 1dd53ce54c2008e3a11a636a496853cf6f9a5d65 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 24 Jan 2020 09:11:53 +0100 Subject: Convert hash map to gc, implement more instructions and call command --- include/program.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'include/program.h') diff --git a/include/program.h b/include/program.h index c097c7b..5c4737b 100644 --- a/include/program.h +++ b/include/program.h @@ -2,16 +2,35 @@ #define TSL_PROGRAM_H #include "std/buffer.h" -#include "std/hash_map.h" +#include "std_gc/hash_map.h" +#include "string_view.h" #include "value.h" -#define TSL_STACK_MAX_SIZE 255 +typedef enum { + TSL_STACK_VALUE_TYPE_NUMBER, + TSL_STACK_VALUE_TYPE_BOOL, + TSL_STACK_VALUE_TYPE_STRING, + TSL_STACK_VALUE_TYPE_FUNCTION, + TSL_STACK_VALUE_TYPE_VARIABLE, + TSL_STACK_VALUE_TYPE_NULL, + TSL_STACK_VALUE_TYPE_COMMAND_ARG +} TslStackValueType; + +typedef struct { + union { + int integer; + double number; + TslBool boolean; + TslStringView str; + } data; + TslStackValueType type; +} TslStackValue; typedef struct { TslBuffer /*TslBytecode*/ function_bytecode_list; - TslHashMap /*TslStringView, TslValue*/ variables; - TslValue stack_values[TSL_STACK_MAX_SIZE]; - size_t stack_index; + /* Allocated with GC and is the root object of the program. When this is deallocated, the whole program is deallocated */ + TslHashMap /*TslStringView, TslValue*/ *variables; + TslBuffer /*TslStackValue*/ stack_values; } TslProgram; typedef enum { -- cgit v1.2.3