Files
fz-lang/include/compiler/utils/fzl_symtable.h
T
2026-10-15 02:23:43 +03:00

47 lines
902 B
C

#ifndef FZL_SYMTABLE_H
#define FZL_SYMTABLE_H
#include <common/fzl_types.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef enum
{
FZL_SYMTABLE_RESULT_OK,
FZL_SYMTABLE_RESULT_ERR,
FZL_SYMTABLE_RESULT_EXISTS
} fzl_symtable_res_t;
// Symbols table entry descriptor
typedef struct
{
char *name;
fzl_type_t type;
size_t ip;
} fzl_sym_t;
// Symbols table descriptor
typedef struct
{
size_t size;
size_t remainder;
fzl_sym_t *symbols;
} fzl_symtable_t;
// Allocate new symbtable
fzl_symtable_t *fzl_mksymt();
// Put new entry into symtable
fzl_symtable_res_t fzl_symt_put(fzl_symtable_t *symt, char *name,
fzl_type_t type, uint64_t ip);
// Get entry from specified symtable
bool fzl_symt_get(fzl_symtable_t *symt, char *name, fzl_sym_t *res);
// Free symbtable
void fzl_freesymt(fzl_symtable_t *symt);
#endif // FZL_SYMTABLE_H