From fc7edb22079845ccd548e2034ff7193ca54f47ea Mon Sep 17 00:00:00 2001 From: c Date: Sat, 27 Apr 2024 09:59:47 -0400 Subject: Doer things. --- src/tree.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/tree.c') diff --git a/src/tree.c b/src/tree.c index 35c8a3f..916936d 100644 --- a/src/tree.c +++ b/src/tree.c @@ -229,6 +229,28 @@ void tree_swp_call(tree_t* t0, tree_t* t1) { } } +int tree_type_str(tree_type_t tree_type, char* str) { + switch (tree_type) { + case TREE_TYPE_LINT: + return !strcmp("int", str); + case TREE_TYPE_LSTR: + return !strcmp("str", str); + default: + DIE("Invalid primitive type."); + } +} + +char* tree_type2str(tree_type_t tree_type) { + switch (tree_type) { + case TREE_TYPE_LINT: + return "int"; + case TREE_TYPE_LSTR: + return "str"; + default: + DIE("Invalid primitive type."); + } +} + /* Every time I think there's a problem with the parser, it turns out it's just this stupid tree print function. Now it works. Never touching it -- cgit v1.2.3