feat: finished variables declaration / assign
This commit is contained in:
@@ -7,6 +7,7 @@ typedef enum
|
||||
|
||||
FZL_TYPE_STRING,
|
||||
FZL_TYPE_CHAR,
|
||||
FZL_TYPE_BOOL,
|
||||
|
||||
FZL_TYPE_INT8,
|
||||
FZL_TYPE_UINT8,
|
||||
@@ -16,10 +17,8 @@ typedef enum
|
||||
FZL_TYPE_UINT32,
|
||||
FZL_TYPE_INT64,
|
||||
FZL_TYPE_UINT64,
|
||||
FZL_TYPE_INT, // machine word int
|
||||
FZL_TYPE_UINT, // machine word unsigned int
|
||||
|
||||
FZL_TYPE_BOOL
|
||||
FZL_TYPE_INT, // machine word int
|
||||
FZL_TYPE_UINT // machine word unsigned int
|
||||
} fzl_type_t;
|
||||
|
||||
#endif // FZL_TYPES_H
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/utils/fzl_const_pool.h>
|
||||
#include <compiler/utils/fzl_symtable.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -26,6 +27,9 @@ typedef struct
|
||||
uint64_t *ops;
|
||||
size_t op_count;
|
||||
size_t op_remainder;
|
||||
|
||||
fzl_symtable_t *syms[64];
|
||||
size_t sym_top;
|
||||
} fzl_walker_t;
|
||||
|
||||
// Allocate new walker
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef FZL_SYMTABLE_H
|
||||
#define FZL_SYMTABLE_H
|
||||
|
||||
#include <common/fzl_types.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.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;
|
||||
} 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);
|
||||
|
||||
// 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
|
||||
+4
-1
@@ -27,7 +27,7 @@ typedef struct
|
||||
size_t ctop;
|
||||
|
||||
// Environment stack
|
||||
fzl_vm_env_t estack[256];
|
||||
fzl_vm_env_t *estack[256];
|
||||
size_t etop;
|
||||
} fzl_vm_t;
|
||||
|
||||
@@ -40,6 +40,9 @@ int fzl_vm_run(fzl_vm_t *vm);
|
||||
// Get last VM error message
|
||||
char *fzl_vm_geterror();
|
||||
|
||||
// Print opcodes sequence
|
||||
void fzl_vm_print_ops(fzl_vm_t *vm);
|
||||
|
||||
// Free VM
|
||||
void fzl_freevm(fzl_vm_t *vm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user