stage1 实现更多ast2ir 修复bug 提供内置操作

This commit is contained in:
zzy committed 2026-09-11 19:26:48 +08:00
1 parent ab6e99c958
commit 49ccdec3dd
10 files changed
+396 -76

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
#ifndef __SPL_INTRIN_H__
#define __SPL_INTRIN_H__
#include "../stage0/include/utils.h"
#include "spl_type.h"
typedef enum {
SPL_INTRIN_NONE = 0,
SPL_INTRIN_SIZEOF,
SPL_INTRIN_ALIGNOF,
SPL_INTRIN_ASSERT,
SPL_INTRIN_LEN,
} spl_intrin_t;
typedef enum {
SPL_INTRIN_FORM_CALL = 1, /* @sizeof(...) @assert(...) */
SPL_INTRIN_FORM_FIELD = 2, /* recv.len */
} spl_intrin_form_t;
typedef enum {
SPL_INTRIN_RESULT_UNIT,
SPL_INTRIN_RESULT_BOOL,
SPL_INTRIN_RESULT_USIZE,
} spl_intrin_result_t;
typedef struct {
const char *name;
spl_intrin_t kind;
spl_intrin_form_t form;
int min_args; /* FIELD 形态忽略 */
int max_args; /* -1 = variadic */
spl_intrin_result_t result;
} spl_intrin_info_t;
/* 统一入口:名字 → 枚举。name 允许带或不带 '@'。 */
spl_intrin_t spl_intrin_lookup_call(const char *name);
/* 统一入口:字段形态,按接收者类型分派。 */
spl_intrin_t spl_intrin_lookup_field(spl_lang_type_kind_t recv_kind, const char *field);
/* 从枚举取得元数据,SEMA/AST2IR 都从这里读。 */
const spl_intrin_info_t *spl_intrin_info(spl_intrin_t kind);
/* ---- 与 IR 侧共享的类型布局约定 ---- */
#define SPL_SLICE_PTR_FIELD_IDX 0
#define SPL_SLICE_LEN_FIELD_IDX 1
#endif /* __SPL_INTRIN_H__ */