#ifndef TSL_PROGRAM_H #define TSL_PROGRAM_H #include "std/buffer.h" #include "std_gc/hash_map.h" #include "string_view.h" #include "value.h" typedef enum { TSL_STACK_VALUE_TYPE_NUMBER, TSL_STACK_VALUE_TYPE_BOOL, TSL_STACK_VALUE_TYPE_STRING, TSL_STACK_VALUE_TYPE_NULL, TSL_STACK_VALUE_TYPE_FUNCTION, TSL_STACK_VALUE_TYPE_VARIABLE_NAME, TSL_STACK_VALUE_TYPE_VARIABLE, TSL_STACK_VALUE_TYPE_LIST, TSL_STACK_VALUE_TYPE_MAP, TSL_STACK_VALUE_TYPE_INDEX } TslStackValueType; typedef struct { union { int integer; double number; TslBool boolean; TslStringView str; TslValue variable; } data; TslStackValueType type; } TslStackValue; typedef struct { TslBuffer /*TslBytecode*/ function_bytecode_list; /* 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 { TSL_PROGRAM_RESULT_ERR, TSL_PROGRAM_RESULT_OK } TslProgramResult; void tsl_program_init(TslProgram *self); void tsl_program_deinit(TslProgram *self); TslProgramResult tsl_program_run(TslProgram *self); #endif /* TSL_PROGRAM_H */