fix(sizeof,parse): 尺寸链去静默兜底,解析报错可定位,补 C 解析器缺口
StructGen: _get_struct_size/_get_align 去 opaque→8/ptr_size、未知→4 兜底并补 VectorType;LiteralStructType.fields→.elements(llvmlite 无 fields,必然 AttributeError) HandlesClassDef: union 载荷尺寸经不存在的 ir.DataLayout 静默退化成 8 字节;HandlesExprCall/ExprBuiltin: sizeof 各静默 0 分支改 fail-fast,数组元素 sizeof 统一走 _get_struct_size HandlesFor: nonlocal struct/array 堆分配不再退化成 malloc(8) vast/vast_c: 补一元 * / & 解析,装饰器后 extern/export 分派修复,C 侧报错带 token 与行号;StubGen.Converter: 宏展开丢尾随空行修 .pyi 缩进非法 其余为 rawptr 迁移 / fail-fast 口径等历史改动一并入库
This commit is contained in:
1 parent
53a345a59a
commit
c83fc752c6
53 files changed
+6238
-887
No files matched your search
@@ -9,6 +9,7 @@ import traceback
|
||||
from lib.Projectrans.Utils import compute_sha1, get_file_dependencies, find_reachable_files_from_entries, parse_python_file
|
||||
from lib.Projectrans.DeclarationGenerator import DeclarationGenerator
|
||||
from lib.core.VLogger import get_logger as _vlog
|
||||
from lib.core.SymbolUtils import ExpandSoftKeywords
|
||||
from lib.constants.config import mode as _ConfigMode
|
||||
from lib.includes import t
|
||||
from StubGen import PythonToStubConverter
|
||||
@@ -383,6 +384,11 @@ class Phase1Generator:
|
||||
|
||||
用于 .stub.ll 缓存依赖校验:当依赖的 include SHA1 变化时,
|
||||
当前 include 的 .stub.ll 缓存应失效(因为类型引用的 SHA1 前缀会变化)。
|
||||
|
||||
签名同时纳入 includes/builtins.vp:它是注解类型解析的隐式输入
|
||||
(不在任何模块的 import 闭包,但其 CTypedef 参与签名/字段类型解析),
|
||||
其内容变化必须让所有 .stub.ll 失效——否则旧声明(如 sizet 曾被解析成
|
||||
%"{mod}.sizet"* 假结构体)会被缓存继续引用,源码修复不生效。
|
||||
"""
|
||||
if not self._include_dep_graph or not self._include_file_map:
|
||||
return ''
|
||||
@@ -400,6 +406,11 @@ class Phase1Generator:
|
||||
if DepSha1:
|
||||
Result.add(DepSha1)
|
||||
Queue.extend(self._include_dep_graph.get(DepMod, set()))
|
||||
BuiltinsInfo: tuple[str, str, str] | None = self._include_file_map.get('builtins')
|
||||
if BuiltinsInfo is not None:
|
||||
BuiltinsSha1: str = self._get_sha1(BuiltinsInfo[0])
|
||||
if BuiltinsSha1:
|
||||
Result.add(BuiltinsSha1)
|
||||
return '|'.join(sorted(Result))
|
||||
|
||||
def _ReadStubDep(self, stub_path: str) -> str:
|
||||
@@ -510,7 +521,9 @@ class Phase1Generator:
|
||||
"""
|
||||
result: dict[str, str] = {}
|
||||
try:
|
||||
tree = ast.parse(content)
|
||||
# `.vp` 源码须先过 Viper 软关键字层(`enum X:` / `fn` 等)再解析,
|
||||
# 否则 SyntaxError 被吞成"无 docstring",与主翻译路径口径不一致。
|
||||
tree = ast.parse(ExpandSoftKeywords(content), '<Phase1Generator:_extract_docstrings>')
|
||||
except SyntaxError:
|
||||
return result
|
||||
for node in tree.body:
|
||||
|
||||
Reference in new issue
Block a user