Files
spl/stage1/spl_builtin.h
2026-08-06 19:26:30 +08:00

44 lines
1.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* spl_builtin.h — 内置函数集中注册表
*
* @builtin 名称/类别/参数/返回类型的单一事实来源。
* sema类型推导与 ast2irIR 发射)各自按 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__ */