stage1 重写进行代码设计并重构 提供diag替换老旧错误处理
This commit is contained in:
1 parent
7cbe2d2b9a
commit
e4347cc3ea
14 files changed
+983
-526
No files matched your search
+9
-6
@@ -2,11 +2,11 @@
|
||||
#define __SPL_SEMA_H__
|
||||
|
||||
#include "spl_ast.h"
|
||||
#include "spl_attr.h"
|
||||
#include "spl_diag.h"
|
||||
#include "spl_mpa.h"
|
||||
#include "spl_type.h"
|
||||
|
||||
#include "spl_attr.h"
|
||||
|
||||
typedef enum {
|
||||
SPL_SYMBOL_KIND_ERROR,
|
||||
SPL_SYMBOL_KIND_VAR,
|
||||
@@ -14,6 +14,7 @@ typedef enum {
|
||||
SPL_SYMBOL_KIND_FN,
|
||||
SPL_SYMBOL_KIND_TYPE,
|
||||
} spl_symbol_kind_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
spl_symbol_kind_t kind;
|
||||
@@ -21,11 +22,13 @@ typedef struct {
|
||||
} spl_symbol_t;
|
||||
|
||||
typedef usize spl_scope_id_t; /* 0 is error */
|
||||
|
||||
typedef struct {
|
||||
spl_scope_id_t parent;
|
||||
MAP(const char *, spl_symbol_t) symbols;
|
||||
} spl_scope_node_t;
|
||||
typedef VEC(spl_scope_node_t) spl_scope_node_vec_t;
|
||||
|
||||
typedef struct {
|
||||
spl_scope_node_vec_t scopes;
|
||||
spl_scope_id_t root_scope;
|
||||
@@ -34,24 +37,24 @@ typedef struct {
|
||||
|
||||
void spl_scope_init(spl_scope_t *scope);
|
||||
void spl_scope_drop(spl_scope_t *scope);
|
||||
|
||||
spl_scope_id_t spl_scope_alloc(spl_scope_t *scope);
|
||||
bool spl_scope_insert(spl_scope_t *scope, spl_scope_id_t id, spl_symbol_t symbol);
|
||||
typedef VEC(const char *) spl_symbol_path_t;
|
||||
bool spl_scope_find(spl_scope_t *scop, const char *symbol_name, spl_symbol_t *out);
|
||||
|
||||
typedef VEC(const char *) spl_symbol_path_t;
|
||||
|
||||
typedef struct {
|
||||
spl_ast_t *ast;
|
||||
spl_type_t *type;
|
||||
spl_scope_t *scope;
|
||||
spl_symbol_t root;
|
||||
int error_count;
|
||||
spl_scope_id_t store_scope;
|
||||
spl_attr_t *attr;
|
||||
spl_lang_type_id_t current_aggregate_lang;
|
||||
spl_lang_type_id_t current_fn_ret_tid;
|
||||
spl_lang_type_id_t current_loop_break_tid;
|
||||
spl_symbol_path_t label_stack;
|
||||
|
||||
spl_diag_t *diag;
|
||||
} spl_sema_t;
|
||||
|
||||
void spl_sema_init(spl_sema_t *sema, spl_ast_t *ast, spl_type_t *type, spl_scope_t *scope,
|
||||
|
||||
Reference in new issue
Block a user