Cthulhu  0.2.10
Cthulhu compiler collection
common.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #pragma once
4 
5 #include "cthulhu/tree/tree.h"
6 
7 typedef enum tree_tags_t
8 {
9 #define TREE_TAG(ID, NAME, TAGS) ID = (TAGS),
10 #include "cthulhu/tree/tree.inc"
11 } tree_tags_t;
12 
14 bool kind_has_tag(tree_kind_t kind, tree_tags_t tags);
15 
17 bool tree_has_tag(const tree_t *tree, tree_tags_t tags);
18 
19 CT_LOCAL tree_t *tree_new(tree_kind_t kind, const node_t *node, const tree_t *type);
20 CT_LOCAL tree_t *tree_decl(tree_kind_t kind, const node_t *node, const tree_t *type, const char *name, tree_quals_t quals);
21 
22 #define TREE_EXPECT(SELF, KIND) CTASSERTF(tree_is(SELF, KIND), "expected %s, got %s", tree_kind_to_string(KIND), tree_to_string(SELF))
23 #define TREE_EXPECT_NOT(SELF, KIND) CTASSERTF(!tree_is(SELF, KIND), "expected not %s, got %s", tree_kind_to_string(KIND), tree_to_string(SELF))
CT_LOCAL tree_t * tree_decl(tree_kind_t kind, const node_t *node, const tree_t *type, const char *name, tree_quals_t quals)
Definition: tree.c:35
CT_CONSTFN CT_LOCAL bool kind_has_tag(tree_kind_t kind, tree_tags_t tags)
Definition: context.c:17
tree_tags_t
Definition: common.h:8
CT_LOCAL tree_t * tree_new(tree_kind_t kind, const node_t *node, const tree_t *type)
Definition: tree.c:22
CT_CONSTFN CT_LOCAL bool tree_has_tag(const tree_t *tree, tree_tags_t tags)
Definition: context.c:24
#define CT_CONSTFN
mark a function as const, has no side effects and always returns the same value for the same argument...
Definition: analyze.h:227
#define CT_LOCAL
Definition: compiler.h:166
tree_quals_t
all type qualifiers
Definition: ops.h:25
tree_kind_t
all tree node types
Definition: ops.h:17
a position in a source file
Definition: node.h:23
Definition: tree.h:67