aboutsummaryrefslogtreecommitdiff
path: root/include/program.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/program.h')
-rw-r--r--include/program.h29
1 files changed, 24 insertions, 5 deletions
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 {