docs(tpv): R11 注释与 docstring 英文化并压缩到 2 行内
按 wiki/新规范:注释只讲作用、不掺杂历史原因、避免超长、尽可能英文(含三引号 __doc__)。全文 79 个 .vp:# 注释 16269 行(中文 13808)与 docstring(中文 1381 处)全部改英文;超 2 行的注释块(2093)与 docstring(397)全部压到 2 行。运行时可见文本未动(fatal_error/VLogger 的中文报错文案、stdio.printf 的横幅格式串)。校验:屏蔽注释与三引号后逐行比对各文件代码骨架,0 漂移。验证:自举重建 153.48s 通过(跨模块内联完成);TPV 顺序回归 77/77 全通过。
This commit is contained in:
1 parent
a2874a14e6
commit
0f4aeeceff
79 files changed
+10090
-20352
No files matched your search
@@ -19,47 +19,41 @@ import lib.Projectrans.Utils as Utils
|
||||
import lib.Projectrans.Config as Config
|
||||
|
||||
|
||||
# ============================================================
|
||||
# StubMerger - stub 声明合并模块(Phase2 核心)
|
||||
#
|
||||
# 从 temp 目录加载所有 .stub.ll,把依赖模块的声明合并到主 IR 的 target triple 之后,使链接器能解析跨模块符号引用。
|
||||
# 合并策略:扫描 temp 目录收集 {sha1}.stub.ll → 读取内容 → 过滤去重(避免重复声明)→ 插入主 IR。
|
||||
# ============================================================
|
||||
# StubMerger - merges dependency stub declarations into the main IR (Phase2 core):
|
||||
# collect {sha1}.stub.ll from temp, dedup, then insert after the target triple so cross-module symbols link.
|
||||
|
||||
# 全局 mbuddy 指针
|
||||
# Global mbuddy pointer
|
||||
_mbuddy: memhub.MemBuddy*
|
||||
|
||||
# 最大 includes SHA1 数(用于过滤)
|
||||
# Max includes SHA1 entries (for filtering)
|
||||
define MAX_INCLUDES_SHA1 = 1024
|
||||
# stub/text 读取缓冲区大小
|
||||
# 1MB 不够:ast/parser.vp 的 text.ll >1MB,读取本地 text.ll 单次截断
|
||||
# → 尾部丢字(opt: "end of file in global variable name")。
|
||||
# Stub/text read buffer size. 1MB is too small: text.ll files exceed 1MB, so a single
|
||||
# truncated read drops trailing data (opt: "end of file in global variable name").
|
||||
define STUB_READ_BUF_SIZE = 8388608
|
||||
# 最大 includes 条目数
|
||||
# Max includes entries
|
||||
define MAX_INCLUDES = 1024
|
||||
# 可达性分析 worklist/processed 缓冲区大小(8192 不够:递归扫描 source_dir
|
||||
# 后 worklist 含全部 App 文件 imports 的拼接 + BFS 依赖展开,追加82 溢出)
|
||||
# Reachability worklist/processed buffer size. 8192 is too small: after scanning
|
||||
# source_dir it holds all App imports plus BFS expansion, overflowing on append 82.
|
||||
define REACH_WORKLIST_BUF = 65536
|
||||
|
||||
# 全局 SHA1 映射存储器(内存中,不依赖 _sha1_map.txt 文件)
|
||||
# Phase1 扫描完成后填充,供所有函数使用
|
||||
_sha1_store_arr: bytes # SHA1 数组(每个 17 字节,MAX_INCLUDES 个)
|
||||
_sha1_store_mod: bytes # 模块名数组(每个 64 字节,MAX_INCLUDES 个)
|
||||
_sha1_store_rel: bytes # 相对路径数组(每个 256 字节,MAX_INCLUDES 个)
|
||||
_sha1_store_incdir: bytes # 所属 includes 根目录数组(每个 512 字节,MAX_INCLUDES 个,多 includes 支持)
|
||||
_sha1_store_count: int # 条目数
|
||||
# Global SHA1 map store (in memory, no dependency on _sha1_map.txt).
|
||||
# Filled after the Phase1 scan and shared by all functions.
|
||||
_sha1_store_arr: bytes # SHA1 array (17 bytes each, MAX_INCLUDES entries)
|
||||
_sha1_store_mod: bytes # Module-name array (64 bytes each, MAX_INCLUDES entries)
|
||||
_sha1_store_rel: bytes # Relative-path array (256 bytes each, MAX_INCLUDES entries)
|
||||
_sha1_store_incdir: bytes # Owning includes-root array (512 bytes each, MAX_INCLUDES entries, multi-includes)
|
||||
_sha1_store_count: int # Entry count
|
||||
|
||||
# includes 依赖内存存储(不依赖 deps.txt 过程文件)
|
||||
# Phase B+ 前用 declare_only 翻译所有 includes 文件,提取 _imported_modules 存入此处
|
||||
# _BuildReachableSha1Set 从此处读取依赖,不读 deps.txt
|
||||
_includes_deps_sha1: bytes # SHA1 数组(每个 17 字节,MAX_INCLUDES 个)
|
||||
_includes_deps_str: bytes # 依赖字符串数组(每个 512 字节,MAX_INCLUDES 个)
|
||||
_includes_deps_count: int # 条目数
|
||||
# In-memory includes dependency store (no dependency on the deps.txt file).
|
||||
# Before Phase B+ all includes are translated in declare_only mode; _BuildReachableSha1Set reads deps from here.
|
||||
_includes_deps_sha1: bytes # SHA1 array (17 bytes each, MAX_INCLUDES entries)
|
||||
_includes_deps_str: bytes # Dependency-string array (512 bytes each, MAX_INCLUDES entries)
|
||||
_includes_deps_count: int # Entry count
|
||||
|
||||
# 单条依赖字符串最大长度
|
||||
# Max length of a single dependency string
|
||||
define MAX_DEPS_STR_LEN = 512
|
||||
|
||||
# rel_path 最大长度
|
||||
# Max rel_path length
|
||||
define MAX_REL_PATH_LEN = 256
|
||||
# includes 根目录最大长度(绝对路径,多 includes 支持)
|
||||
# Max includes-root path length (absolute path, multi-includes)
|
||||
define MAX_INC_DIR_LEN = 512
|
||||
Reference in new issue
Block a user