wip: working on generator
- Feat: add typedefs' branches
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/internals/gen.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// Type aliasing
|
||||
bool gen_alias(fzl_gen_t *gen, fzl_node_t *node)
|
||||
{
|
||||
if (!gen || !node)
|
||||
return false;
|
||||
|
||||
fzl_type_t type;
|
||||
char typecn[256];
|
||||
memset(typecn, 0, sizeof(typecn));
|
||||
|
||||
bool resolved = gen_resolve_type(gen, node->token, &type, typecn);
|
||||
if (!resolved)
|
||||
return false;
|
||||
|
||||
ssize_t slot = gen_resolve_extern_type(gen, typecn);
|
||||
if (slot == -1)
|
||||
type_buf.alias_target =
|
||||
(fzl_extern_type_ref_t){.is_primitive = true, .primitive = type};
|
||||
else
|
||||
type_buf.alias_target =
|
||||
(fzl_extern_type_ref_t){.is_primitive = false, .type_slot = slot};
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user