12.8 切片 1:寄存器码骨架(MOVE/LOADK/RET)。

- Codegen.h/cpp:帧寄存器(0 起声明序)、常量表、函数表、小端映像拼装
- 切片 1 范围:PROGRAM 标量 + 字面量 LOADK + 变量 MOVE + RET;其余构造报 codegen error
- codegen_test:23 断言(用例 01 空 MAIN 出 RET、02 LOADK r0/r1 + 常量表),ctest 9/9
This commit is contained in:
2026-08-21 11:32:31 +08:00
parent d296a9215e
commit 66359a0a26
5 changed files with 486 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
/**
* @file Codegen.h
* @brief 寄存器码生成(12.8,切片 1MOVE / LOADK / RET
* @author
* @date 2026-08-21
*/
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include "compiler/Linker.h"
#include "compiler/Parser.h"
#include "compiler/Project.h"
namespace compiler {
// 编译工程为 .stb 映像字节(在链接 + 类型检查成功后调用)。
// 失败返回 falseerr 前缀 "codegen error"。
bool codegen_project(const Project& proj, const std::vector<SourceUnit>& units,
const LinkResult& link, std::vector<uint8_t>* image,
std::string* err);
}