Files
ViperC/App/lib/Stub/StubMerger/__init__.vp
T
TermiNexus 0f4aeeceff 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 全通过。
2026-10-05 13:38:22 +08:00

60 lines
2.5 KiB
Plaintext

import t, c
from stdint import *
import memhub
import string
import stdlib
import mlirlite
import w32.win32file as win32file
import w32.win32base as win32base
import w32.fileio as fileio
import viperlib
import sys
import ast
import lib.core.VLogger as VLogger
import lib.core.IncludesScanner as IncludesScanner
import lib.core.Gen.Translator as HandlesTranslator
import lib.Phase.BuildPipeline as BuildPipeline
import lib.Stub.StubGen.VpiReader as VpiReader
import lib.Projectrans.Utils as Utils
import lib.Projectrans.Config as Config
# 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.
# Global mbuddy pointer
_mbuddy: memhub.MemBuddy*
# Max includes SHA1 entries (for filtering)
define MAX_INCLUDES_SHA1 = 1024
# 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
# Max includes entries
define MAX_INCLUDES = 1024
# 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
# 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
# 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
# Max rel_path length
define MAX_REL_PATH_LEN = 256
# Max includes-root path length (absolute path, multi-includes)
define MAX_INC_DIR_LEN = 512