stage1 初步实现
This commit is contained in:
43
stage1/spl_builtin.h
Normal file
43
stage1/spl_builtin.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* spl_builtin.h — 内置函数集中注册表
|
||||
*
|
||||
* @builtin 名称/类别/参数/返回类型的单一事实来源。
|
||||
* sema(类型推导)与 ast2ir(IR 发射)各自按 kind 分发实现。
|
||||
*/
|
||||
#ifndef __SPL_BUILTIN_H__
|
||||
#define __SPL_BUILTIN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SPL_BUILTIN_SIZE_OF, /* @sizeof(T) -> usize */
|
||||
SPL_BUILTIN_BITSIZE_OF, /* @bitsizeof(T) -> usize */
|
||||
SPL_BUILTIN_ALIGN_OF, /* @alignof(T) -> usize */
|
||||
SPL_BUILTIN_OFFSET_OF, /* @offsetof(T, field) -> usize */
|
||||
SPL_BUILTIN_FIELD_COUNT, /* @field_count(T) -> usize */
|
||||
SPL_BUILTIN_DBG, /* @dbg(args...) -> void */
|
||||
SPL_BUILTIN_ASSERT, /* @assert(cond) -> void */
|
||||
SPL_BUILTIN_IMPORT, /* @import(path) -> 模块 (预留) */
|
||||
SPL_BUILTIN_COUNT
|
||||
} spl_builtin_kind_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
spl_builtin_kind_t kind;
|
||||
int min_args; /* 参数个数下限 */
|
||||
int max_args; /* 参数个数上限,-1 = 不限 */
|
||||
int ret_is_void; /* 1 = void 返回 */
|
||||
} spl_builtin_t;
|
||||
|
||||
/* 按名称查找内置;未注册返回 NULL */
|
||||
const spl_builtin_t *spl_builtin_lookup(const char *name);
|
||||
|
||||
/* 内置总数 */
|
||||
int spl_builtin_count(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SPL_BUILTIN_H__ */
|
||||
Reference in New Issue
Block a user