summaryrefslogtreecommitdiffhomepage
path: root/compiler.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 /compiler.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 'compiler.h')
-rw-r--r--compiler.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler.h b/compiler.h
index 53ff987..7b241ff 100644
--- a/compiler.h
+++ b/compiler.h
@@ -28,8 +28,8 @@
#endif
#include "source.h"
-#include "object.h"
#include "lexer.h"
+#include "types.h"
#include "util.h"
typedef enum {
@@ -72,14 +72,14 @@ struct uc_patchlist {
typedef struct uc_patchlist uc_patchlist;
typedef struct {
- json_object *name;
+ uc_value_t *name;
ssize_t depth;
size_t from;
bool captured;
} uc_local;
typedef struct {
- json_object *name;
+ uc_value_t *name;
size_t index;
bool local;
} uc_upval;
@@ -93,7 +93,7 @@ typedef struct {
uc_lexer lex;
uc_token prev, curr;
bool synchronizing;
- char *error;
+ uc_stringbuf_t *error;
} uc_parser;
struct uc_compiler {
@@ -101,7 +101,7 @@ struct uc_compiler {
uc_locals locals;
uc_upvals upvals;
uc_patchlist *patchlist;
- uc_function *function;
+ uc_value_t *function;
uc_parser *parser;
size_t scope_depth, current_srcpos, last_insn;
bool statement_emitted;
@@ -115,6 +115,6 @@ typedef struct {
uc_precedence_t precedence;
} uc_parse_rule;
-uc_function *uc_compile(uc_parse_config *config, uc_source *source, char **errp);
+uc_function_t *uc_compile(uc_parse_config *config, uc_source *source, char **errp);
#endif /* __COMPILER_H_ */