aboutsummaryrefslogtreecommitdiff
path: root/src/include/doer.h
diff options
context:
space:
mode:
authorc2024-03-09 11:01:23 -0500
committerc2024-03-09 11:01:23 -0500
commit099fd363f7972ad7e1c48f5fd9ab83aa38a40ea2 (patch)
tree7a2b81f5fba6630ec5d1da469135539007c16f3c /src/include/doer.h
parent9a7e88e33213135da7c8fa3607ca455d997f4a39 (diff)
Introduced mortality.
Diffstat (limited to 'src/include/doer.h')
-rw-r--r--src/include/doer.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/include/doer.h b/src/include/doer.h
index afa80dd..429aa02 100644
--- a/src/include/doer.h
+++ b/src/include/doer.h
@@ -4,8 +4,9 @@
#include "util.h"
#include "tree.h"
+// Points to a part of the AST the doer wishes to remember.
typedef struct TARGET {
- char* name; // The name of the target (unique).
+// char* name; // The name of the target (unique).
tree_t* tree; // The tree to which the target refers.
struct TARGET* nxt; // The next target in the list.
} target_t;
@@ -40,17 +41,25 @@ void doer_destroy(doer_t* doer);
/* Built-in function. */
typedef struct BLINF {
- void (*fp)(doer_t*);
+ void (*fp)(doer_t*); // The callback function in C.
+ tree_type_t returnt; // The return type of the function.
+ tree_type_t* argts; // Array of the arguments' types.
char name[24];
} blinf_t;
void doer_add_target(doer_t* doer, target_t* target);
// Built-in functions.
+// `die`: dies. Does not accept any arguments, returns int (if a tree falls in
+// the forest, but it burns down before anyone can hear it, did it ever make a
+// sound at all?)
+void blin_die(doer_t* tree);
// `print`: print a string.
void blin_print(doer_t* tree);
+static tree_type_t blin_print_args[] = { TREE_TYPE_LSTR };
// `printl`: print a string, and add a newline.
void blin_printl(doer_t* tree);
+static tree_type_t blin_printl_args[] = { TREE_TYPE_LSTR };
void doer_do_block(doer_t* tree);
void doer_do_expr(doer_t* tree);
@@ -62,9 +71,10 @@ void doer_do_carg(doer_t* tree);
void doer_do_def(doer_t* tree);
void doer_do_call(doer_t* tree);
-const static blinf_t blinfs[] = {
- { blin_print, "print" },
- { blin_printl, "printl" }
+static blinf_t blinfs[] = {
+ { blin_die, TREE_TYPE_LINT, NULL, "die" },
+ { blin_print, TREE_TYPE_LSTR, blin_print_args, "print" },
+ { blin_printl, TREE_TYPE_LSTR, blin_printl_args, "printl" },
};
#endif