summaryrefslogtreecommitdiffhomepage
path: root/lexer.h
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-04-21 15:07:16 +0200
committerJo-Philipp Wich <jo@mein.io>2021-04-25 20:48:40 +0200
commit35af4ba4fc21a4b2357c50e6b02a2e3e4b236e88 (patch)
tree445f9fdf2e96e490cd681dca36d5cc9912474ed3 /lexer.h
parentf2c4b79feaffd7b2fdb4041f47c9cd0f4cc3bc6e (diff)
treewide: rework internal data type system
Instead of relying on json_object values internally, use custom types to represent the different ucode value types which brings a number of advantages compared to the previous approach: - Due to the use of tagged pointers, small integer, string and bool values can be stored directly in the pointer addresses, vastly reducing required heap memory - Ability to create circular data structures such as `let o; o = { test: o };` - Ability to register custom `tostring()` function through prototypes - Initial mark/sweep GC implementation to tear down circular object graphs on VM deinit The change also paves the way for possible future extensions such as constant variables and meta methods for custom ressource types. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lexer.h')
-rw-r--r--lexer.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/lexer.h b/lexer.h
index 820a986..f023fb6 100644
--- a/lexer.h
+++ b/lexer.h
@@ -18,6 +18,7 @@
#define __LEXER_H_
#include "source.h"
+#include "types.h"
typedef enum {
@@ -121,7 +122,7 @@ typedef enum {
typedef struct {
uc_tokentype_t type;
- json_object *val;
+ uc_value_t *uv;
size_t pos;
} uc_token;
@@ -170,6 +171,6 @@ uc_token *uc_lexer_next_token(uc_lexer *lex, bool no_regexp);
bool utf8enc(char **out, int *rem, int code);
const char *
-uc_get_tokenname(int type);
+uc_get_tokenname(unsigned type);
#endif /* __LEXER_H_ */