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
@@ -110,7 +110,7 @@ class TransPyC:
|
||||
f.write('')
|
||||
|
||||
# 解析AST并提取符号
|
||||
tree: ast.Module = ast.parse(content)
|
||||
tree: ast.Module = ast.parse(content, SymbolFile.FilePath or '<TransPyC:PreProcessSymbol>')
|
||||
|
||||
if debug:
|
||||
with open(DebugFile, 'a', encoding=SymbolFile.encoding) as f:
|
||||
@@ -449,8 +449,8 @@ class TransPyC:
|
||||
self.translator.OriginalLines = Content.split('\n')
|
||||
self.translator.Content = Content
|
||||
|
||||
# 解析Python代码为AST
|
||||
Tree: ast.Module = ast.parse(Content)
|
||||
# 解析Python代码为AST
|
||||
Tree: ast.Module = ast.parse(Content, InputFile)
|
||||
|
||||
# 解析文件以提取类型信息(用于 EmbeddedAssignments)
|
||||
self.translator.ParsePythonFile(InputFile, encoding)
|
||||
@@ -538,13 +538,13 @@ class TransPyC:
|
||||
self.translator.OriginalLines = self.code.split('\n')
|
||||
|
||||
# 解析Python代码为AST
|
||||
Tree: ast.Module = ast.parse(self.code)
|
||||
Tree: ast.Module = ast.parse(self.code, SourceFilename or '<TransPyC:Convert>')
|
||||
|
||||
# 从源代码直接预扫描 import 语句,注册别名
|
||||
# 注意:不能依赖 Tree 中的 import 节点,因为 ParsePythonFile 可能修改了 AST
|
||||
if not getattr(self.translator, '_ImportedModules', None):
|
||||
self.translator._ImportedModules = set()
|
||||
_prescan_tree: ast.Module = ast.parse(self.code)
|
||||
_prescan_tree: ast.Module = ast.parse(self.code, SourceFilename or '<TransPyC:Convert>')
|
||||
for _node in ast.iter_child_nodes(_prescan_tree):
|
||||
if isinstance(_node, ast.Import):
|
||||
for _alias in _node.names:
|
||||
|
||||
Reference in new issue
Block a user