aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-09 12:59:07 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-09 12:59:07 +0300
commit451111dc51df69580d04c9965f70531f50e3d509 (patch)
tree379a7123f2588f149021c896118ce0ded4f5a9cc /src/ast.c
parentf86cb1e9ec6cb562d1d0ebf4b0fd7119296ff10d (diff)
downloadek-451111dc51df69580d04c9965f70531f50e3d509.tar.gz
ek-451111dc51df69580d04c9965f70531f50e3d509.zip
add initial ufcs checks
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c81
1 files changed, 9 insertions, 72 deletions
diff --git a/src/ast.c b/src/ast.c
index 49010c6..6677513 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -161,6 +161,12 @@ void ast_append(struct ast *list, struct ast *elem)
cur->n = elem;
}
+struct ast *ast_prepend(struct ast *list, struct ast *elem)
+{
+ elem->n = list;
+ return elem;
+}
+
void type_append(struct type *list, struct type *elem)
{
struct type *cur = list;
@@ -170,48 +176,10 @@ void type_append(struct type *list, struct type *elem)
cur->n = elem;
}
-static const char *binop_symbol(enum ast_kind op)
+struct type *type_prepend(struct type *list, struct type *elem)
{
- switch (op) {
- case AST_ADD: return "+";
- case AST_SUB: return "-";
- case AST_MUL: return "*";
- case AST_DIV: return "/";
- case AST_REM: return "%";
- case AST_LOR: return "||";
- case AST_LAND: return "&&";
- case AST_LSHIFT: return "<<";
- case AST_RSHIFT: return ">>";
- case AST_ASSIGN_ADD: return "+=";
- case AST_ASSIGN_SUB: return "-=";
- case AST_ASSIGN_MUL: return "*=";
- case AST_ASSIGN_DIV: return "/=";
- case AST_ASSIGN_REM: return "%=";
- case AST_ASSIGN_LSHIFT: return "<<=";
- case AST_ASSIGN_RSHIFT: return ">>=";
- case AST_LT: return "<";
- case AST_GT: return ">";
- case AST_LE: return "<=";
- case AST_GE: return ">=";
- case AST_NE: return "!=";
- case AST_EQ: return "==";
- default:
- }
-
- return "UNKNOWN";
-}
-
-static const char *unop_symbol(enum ast_kind op)
-{
- switch (op) {
- case AST_NEG: return "-";
- case AST_LNOT: return "!";
- case AST_REF: return "&";
- case AST_DEREF: return "*";
- default:
- }
-
- return "UNKNOWN";
+ elem->n = list;
+ return elem;
}
static void dump(int depth, const char *fmt, ...)
@@ -227,37 +195,6 @@ static void dump(int depth, const char *fmt, ...)
va_end(args);
}
-static void dump_flags(struct ast *node)
-{
- if (node->scope)
- printf(" %zu:", node->scope->number);
-
- enum ast_flags flags = node->f;
- if (flags & AST_FLAG_MUTABLE)
- printf(" MUT");
-
- if (flags & AST_FLAG_CONST)
- printf(" CONST");
-
- if (flags & AST_FLAG_EXTERN)
- printf(" EXTERN");
-
- if (flags & AST_FLAG_VARIADIC)
- printf(" VARIADIC");
-
- if (flags & AST_FLAG_DELAYED)
- printf(" DELAYED");
-
- if (flags & AST_FLAG_PUBLIC)
- printf(" PUB");
-
- if (flags & AST_FLAG_UNTYPED)
- printf(" UNTYPED");
-
- if (flags & AST_FLAG_FALLTHROUGH)
- printf(" FALLTHROUGH");
-}
-
const char *primitive_str(struct type *type)
{
switch (type->k) {