46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
#ifndef __SPL_SEMA_H__
|
|
#define __SPL_SEMA_H__
|
|
|
|
#include "spl_ast.h"
|
|
#include "spl_attr.h"
|
|
#include "spl_diag.h"
|
|
#include "spl_lang_type.h"
|
|
#include "spl_layout.h"
|
|
#include "spl_mpa.h"
|
|
#include "spl_scope.h"
|
|
#include "spl_type.h"
|
|
|
|
typedef struct spl_module_loader spl_module_loader_t;
|
|
struct spl_module_loader {
|
|
/* 从 from_fname 所在目录解析 path;返回该文件的 ast(已 init + parse)。
|
|
失败(文件不存在 / parse 错误 / 环)返回 NULL。
|
|
loader 拥有 ast 的生命周期;sema 不负责释放。 */
|
|
spl_ast_t *(*load)(void *user, const char *from_fname, const char *path, spl_diag_t *diag);
|
|
void *user;
|
|
};
|
|
|
|
typedef struct {
|
|
spl_ast_t *ast;
|
|
spl_lang_type_t *type;
|
|
spl_layout_t *layout; /* 由 splc0 拥有并解析;sema 仅借用 */
|
|
spl_scope_t *scope;
|
|
spl_symbol_t root;
|
|
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;
|
|
const spl_module_loader_t *loader;
|
|
spl_diag_t *diag;
|
|
} spl_sema_t;
|
|
|
|
void spl_sema_init(spl_sema_t *sema, spl_ast_t *ast, spl_lang_type_t *type,
|
|
spl_layout_t *layout, spl_scope_t *scope, spl_attr_t *attr);
|
|
void spl_sema_drop(spl_sema_t *sema);
|
|
|
|
void spl_sema_run_module(spl_sema_t *sema, spl_ast_node_ref_t module_ref);
|
|
void spl_sema_run(spl_sema_t *sema);
|
|
void spl_sema_dump(spl_sema_t *sema);
|
|
|
|
#endif /* __SPL_SEMA_H__ */
|