stage1 - 全面重构 stage1 编译器架构:类型系统(arena + items)、IR 发射层(spl_emit.h/c)、统一所有 emit 调用点。
- 实现 as 类型转换运算符、修复 &&/|| 短路求值 bug。 - 在 splc1.spl 中实现 Vec/Map/Emit 基础库(~50 个方法)。 - 修复实例方法调用中 self 参数被错误丢弃的 bug。
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* spl_comp.c — SPL compiler main logic and codegen helpers */
|
||||
|
||||
#include "spl_comp.h"
|
||||
#include "spl_lex_util.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -61,10 +62,8 @@ void spl_comp_reset(spl_comp_t *ctx) {
|
||||
ctx->addr_of_mode = 0;
|
||||
free(ctx->break_patches);
|
||||
ctx->break_patches = NULL;
|
||||
vec_free(ctx->emit.call_fixups);
|
||||
vec_init(ctx->emit.call_fixups);
|
||||
vec_free(ctx->emit.call_fixup_funcs);
|
||||
vec_init(ctx->emit.call_fixup_funcs);
|
||||
vec_free(ctx->emit.fixups);
|
||||
vec_init(ctx->emit.fixups);
|
||||
}
|
||||
|
||||
void spl_comp_error(spl_comp_t *ctx, const char *fmt, ...) {
|
||||
@@ -172,8 +171,7 @@ int spl_lookup_func(spl_comp_t *ctx, const char *name) {
|
||||
if (items) {
|
||||
vec_for(*items, j) {
|
||||
spl_type_item_t *it = &vec_at(*items, j);
|
||||
if (it->item_kind == ITEM_METHOD && it->name &&
|
||||
strcmp(it->name, name) == 0)
|
||||
if (it->item_kind == ITEM_METHOD && it->name && strcmp(it->name, name) == 0)
|
||||
return it->method.func_idx;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user