wip: working on extern

- Ref: move extern header into common scope
- Feat: add extern symbols descriptors
- Feat: add `is_out` flag in declaration node
This commit is contained in:
samsonium
2026-11-02 19:24:09 +03:00
parent 8975d2fece
commit 6a035a71eb
3 changed files with 74 additions and 16 deletions
+72
View File
@@ -0,0 +1,72 @@
#ifndef FZL_EXTERN_H
#define FZL_EXTERN_H
#include <common/fzl_types.h>
#include <stddef.h>
// External library entry types
typedef enum
{
FZL_EXTERN_KIND_PRIMITIVE,
FZL_EXTERN_KIND_HANDLE,
FZL_EXTERN_KIND_STRUCT,
FZL_EXTERN_KIND_REF,
FZL_EXTERN_KIND_ALIAS,
} fzl_extern_kind_t;
// External library structure field descriptor
typedef struct
{
char *name;
fzl_type_t type;
} fzl_extern_struct_field_t;
// Extern symbol type descriptor
typedef struct fzl_extern_type
{
size_t lib_slot;
fzl_extern_kind_t kind;
char *symbol_name;
char *used_name;
union
{
// Structure data
struct
{
fzl_extern_struct_field_t **fields;
size_t fields_count;
} structure;
// Reference
struct fzl_extern_type *ref_of;
// Aliasing type
fzl_type_t alias;
// Primitive type
// NOTE: same type as `.alias` just for readable format
fzl_type_t primitive;
};
} fzl_extern_type_t;
// Extern symbol function descriptor
typedef struct
{
size_t lib_slot;
char *symbol_name;
char *used_name;
fzl_extern_type_t *ret_type;
fzl_extern_type_t **args;
size_t args_count;
} fzl_extern_fn_t;
// External library descriptor
typedef struct
{
char *name;
} fzl_extern_lib_t;
#endif // FZL_EXTERN_H
+2
View File
@@ -3,6 +3,7 @@
#include <compiler/fzl_reader.h>
#include <compiler/fzl_token.h>
#include <stdbool.h>
#include <stddef.h>
// AST node type
@@ -106,6 +107,7 @@ typedef struct fzl_node
{
fzl_token_t *type;
struct fzl_node *identifier;
bool is_out;
} var;
// Conditional blocks
-16
View File
@@ -1,16 +0,0 @@
#ifndef FZL_EXTERN_H
#define FZL_EXTERN_H
// Library symbol descriptor
typedef struct
{
//
} fzl_extern_item_t;
// External library descriptor
typedef struct
{
//
} fzl_extern_lib_t;
#endif // FZL_EXTERN_H