77 const size_t local[] = { eCtuTagModules };
78 search_t search_local = { local,
sizeof(local) /
sizeof(
size_t) };
80 if (it != NULL) {
return it; }
82 const size_t global[] = { eCtuTagImports };
83 search_t search_global = { global,
sizeof(global) /
sizeof(
size_t) };
87 if (imported != NULL) { *imported =
true; }
96 const size_t tags[] = { eCtuTagImports };
97 search_t search = { tags,
sizeof(tags) /
sizeof(
size_t) };
103 const size_t tags[] = { eCtuTagTypes };
104 search_t search = { tags,
sizeof(tags) /
sizeof(
size_t) };
110 const size_t tags[] = { eCtuTagAttribs };
111 search_t search = { tags,
sizeof(tags) /
sizeof(
size_t) };
117 const size_t tags[] = { eCtuTagValues, eCtuTagFunctions };
118 search_t search = { tags,
sizeof(tags) /
sizeof(
size_t) };
124 const size_t tags[] = { eCtuTagLabels };
125 search_t search = { tags,
sizeof(tags) /
sizeof(
size_t) };
168 static tree_t *gBoolType = NULL;
169 static tree_t *gVoidType = NULL;
170 static tree_t *gOpaqueType = NULL;
171 static tree_t *gStringType = NULL;
173 static tree_t *gLetter = NULL;
175 #define DIGIT_TYPE(DIGIT, SIGN) gIntTypes[(DIGIT) * eSignTotal + (SIGN)]
182 static tree_t *make_bool_type(
const node_t *node,
const char *name)
187 static tree_t *make_str_type(
const node_t *node,
const char *name)
192 static tree_t *make_void_type(
const node_t *node,
const char *name)
197 static tree_t *make_opaque_type(
const node_t *node,
const char *name)
222 {
"char", eDigitChar, eSignSigned },
223 {
"uchar", eDigitChar, eSignUnsigned },
225 {
"short", eDigitShort, eSignSigned },
226 {
"ushort", eDigitShort, eSignUnsigned },
228 {
"int", eDigitInt, eSignSigned },
229 {
"uint", eDigitInt, eSignUnsigned },
231 {
"long", eDigitLong, eSignSigned },
232 {
"ulong", eDigitLong, eSignUnsigned },
234 {
"isize", eDigitSize, eSignSigned },
235 {
"usize", eDigitSize, eSignUnsigned },
238 {
"ptrdiff", eDigitPtr, eSignSigned },
239 {
"uptrdiff", eDigitPtr, eSignUnsigned },
241 {
"int8", eDigit8, eSignSigned },
242 {
"uint8", eDigit8, eSignUnsigned },
244 {
"int16", eDigit16, eSignSigned },
245 {
"uint16", eDigit16, eSignUnsigned },
247 {
"int32", eDigit32, eSignSigned },
248 {
"uint32", eDigit32, eSignUnsigned },
250 {
"int64", eDigit64, eSignSigned },
251 {
"uint64", eDigit64, eSignUnsigned },
253 {
"intfast8", eDigitFast8, eSignSigned },
254 {
"uintfast8", eDigitFast8, eSignUnsigned },
256 {
"intfast16", eDigitFast16, eSignSigned },
257 {
"uintfast16", eDigitFast16, eSignUnsigned },
259 {
"intfast32", eDigitFast32, eSignSigned },
260 {
"uintfast32", eDigitFast32, eSignUnsigned },
262 {
"intfast64", eDigitFast64, eSignSigned },
263 {
"uintfast64", eDigitFast64, eSignUnsigned },
265 {
"intleast8", eDigitLeast8, eSignSigned },
266 {
"uintleast8", eDigitLeast8, eSignUnsigned },
268 {
"intleast16", eDigitLeast16, eSignSigned },
269 {
"uintleast16", eDigitLeast16, eSignUnsigned },
271 {
"intleast32", eDigitLeast32, eSignSigned },
272 {
"uintleast32", eDigitLeast32, eSignUnsigned },
274 {
"intleast64", eDigitLeast64, eSignSigned },
275 {
"uintleast64", eDigitLeast64, eSignUnsigned },
277 {
"float", eDigitFloat, eSignDefault },
278 {
"double", eDigitDouble, eSignDefault },
289 for (
size_t i = 0; i <
sizeof(kDigitInfo) /
sizeof(
digit_info_t); i++)
296 ctu_add_decl(root, eCtuTagTypes,
"bool", make_bool_type(node,
"bool"));
297 ctu_add_decl(root, eCtuTagTypes,
"str", make_str_type(node,
"str"));
298 ctu_add_decl(root, eCtuTagTypes,
"void", make_void_type(node,
"void"));
299 ctu_add_decl(root, eCtuTagTypes,
"opaque", make_opaque_type(node,
"opaque"));
CT_PUREFN CT_TREE_API const node_t * tree_get_node(const tree_t *tree)
CT_TREE_API void tree_set_qualifiers(tree_t *tree, tree_quals_t qualifiers)
CT_EVENTS_API event_builder_t evt_symbol_shadowed(logger_t *logger, const char *name, const node_t *prev, const node_t *next)
signal that a declaration would shadow a previous declaration
#define CTASSERT(expr)
assert a condition, prints the condition as a message
CT_UTIL_API void * util_select_decl(tree_t *sema, search_t search, const char *name)
search for a declaration by name in a set of tags
CT_TREE_API tree_t * tree_type_bool(const node_t *node, const char *name)
create a bool type, this is a type that has only two values, true and false
CT_TREE_API tree_t * tree_type_pointer(const node_t *node, const char *name, const tree_t *pointer, size_t length)
create a pointer type
CT_TREE_API tree_t * tree_type_opaque(const node_t *node, const char *name)
create an opaque pointer type
CT_TREE_API tree_t * tree_type_digit(const node_t *node, const char *name, digit_t digit, sign_t sign)
create a digit type
CT_TREE_API tree_t * tree_type_unit(const node_t *node, const char *name)
create a unit type, this is a type that has only one value. equivilent to void
void * tree_module_set(tree_t *self, size_t tag, const char *name, void *value)
set a declaration in the current module
void * tree_module_get(tree_t *self, size_t tag, const char *name)
recursively search for a declaration in a module
void ctu_init_attribs(tree_t *sema, arena_t *arena)
void ctu_rt_mod(language_runtime_t *runtime, tree_t *root)
void ctu_add_decl(tree_t *sema, ctu_tag_t tag, const char *name, tree_t *decl)
tree_t * ctu_get_int_type(digit_t digit, sign_t sign)
ctu_attrib_t * ctu_get_attrib(tree_t *sema, const char *name)
ctu_sema_t ctu_sema_nested(ctu_sema_t *parent, tree_t *sema, tree_t *decl, vector_t *block)
tree_t * ctu_get_char_type(void)
tree_t * ctu_get_loop(tree_t *sema, const char *name)
ctu_sema_t ctu_sema_init(tree_t *sema, tree_t *decl, vector_t *block)
tree_t * ctu_get_namespace(tree_t *sema, const char *name, bool *imported)
tree_t * ctu_get_type(tree_t *sema, const char *name)
void ctu_set_current_loop(ctu_sema_t *sema, tree_t *loop)
tree_t * ctu_get_import(tree_t *sema, const char *name)
ctu_sema_t ctu_sema_child(ctu_sema_t *sema)
tree_t * ctu_get_decl(tree_t *sema, const char *name)
#define DIGIT_TYPE(DIGIT, SIGN)
tree_t * ctu_get_void_type(void)
tree_t * ctu_get_bool_type(void)
tree_t * ctu_current_loop(ctu_sema_t *sema)
logger_t * ctu_sema_reports(ctu_sema_t *sema)
vector_t * block
current statement block
tree_t * decl
current decl
tree_t * current_loop
current loop
tree_t * sema
current scope
arena_t * arena
default memory arena
a position in a source file
a generic vector of pointers