wip: working on extern
- Feat: stabilize extern header - Feat: add externs to walker - Feat: add extern node walking logic
This commit is contained in:
+36
-22
@@ -2,68 +2,82 @@
|
||||
#define FZL_EXTERN_H
|
||||
|
||||
#include <common/fzl_types.h>
|
||||
#include <stdbool.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
|
||||
// Type reference descriptor
|
||||
typedef struct
|
||||
{
|
||||
bool is_primitive;
|
||||
union
|
||||
{
|
||||
fzl_type_t primitive;
|
||||
size_t type_slot;
|
||||
};
|
||||
} fzl_extern_type_ref_t;
|
||||
|
||||
// Structure field descriptor
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
fzl_type_t type;
|
||||
fzl_extern_type_ref_t type;
|
||||
} fzl_extern_struct_field_t;
|
||||
|
||||
// Extern symbol type descriptor
|
||||
typedef struct fzl_extern_type
|
||||
// Type descriptor
|
||||
typedef struct
|
||||
{
|
||||
size_t lib_slot;
|
||||
char *name;
|
||||
fzl_extern_kind_t kind;
|
||||
char *symbol_name;
|
||||
char *used_name;
|
||||
|
||||
union
|
||||
{
|
||||
// Structure data
|
||||
// Structure
|
||||
struct
|
||||
{
|
||||
fzl_extern_struct_field_t **fields;
|
||||
fzl_extern_struct_field_t *fields;
|
||||
size_t fields_count;
|
||||
} structure;
|
||||
|
||||
// Reference
|
||||
struct fzl_extern_type *ref_of;
|
||||
// Pointer (ref)
|
||||
fzl_extern_type_ref_t ref_target;
|
||||
|
||||
// Aliasing type
|
||||
fzl_type_t alias;
|
||||
|
||||
// Primitive type
|
||||
// NOTE: same type as `.alias` just for readable format
|
||||
fzl_type_t primitive;
|
||||
// Alias
|
||||
fzl_extern_type_ref_t alias_target;
|
||||
};
|
||||
} fzl_extern_type_t;
|
||||
|
||||
// Extern symbol function descriptor
|
||||
// Function argument descriptor
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
fzl_extern_type_ref_t type;
|
||||
bool is_out;
|
||||
} fzl_extern_arg_t;
|
||||
|
||||
// Function descriptor
|
||||
typedef struct
|
||||
{
|
||||
size_t lib_slot;
|
||||
char *symbol_name;
|
||||
char *used_name;
|
||||
|
||||
fzl_extern_type_t *ret_type;
|
||||
bool has_return;
|
||||
fzl_extern_type_ref_t ret_type;
|
||||
|
||||
fzl_extern_type_t **args;
|
||||
fzl_extern_arg_t *args;
|
||||
size_t args_count;
|
||||
} fzl_extern_fn_t;
|
||||
|
||||
// External library descriptor
|
||||
// Library descriptor
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef FZL_WALKER_H
|
||||
#define FZL_WALKER_H
|
||||
|
||||
#include <common/fzl_extern.h>
|
||||
#include <common/fzl_opcodes.h>
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
@@ -73,6 +74,15 @@ typedef struct
|
||||
|
||||
fzl_ctable_t *classes[64];
|
||||
size_t classes_count;
|
||||
|
||||
fzl_extern_lib_t extern_libs[64];
|
||||
size_t extern_libs_count;
|
||||
|
||||
fzl_extern_type_t extern_types[256];
|
||||
size_t extern_types_count;
|
||||
|
||||
fzl_extern_fn_t extern_fns[256];
|
||||
size_t extern_fns_count;
|
||||
} fzl_walker_t;
|
||||
|
||||
// Allocate new walker
|
||||
|
||||
Reference in New Issue
Block a user