Some simple information syncing
This commit is contained in:
@@ -88,6 +88,10 @@ def translate_children(trans: HT.Translator | t.CPtr,
|
||||
if child is None: continue
|
||||
kd: int = child.kind()
|
||||
|
||||
# _declare_only == 0 时,_translate_module_level 已预处理导入语句,
|
||||
# 此处跳过避免重复处理(from_imports 条目重复)
|
||||
if trans._declare_only == 0 and (kd == ast.ASTKind.Import or kd == ast.ASTKind.ImportFrom):
|
||||
continue
|
||||
if kd == ast.ASTKind.Import:
|
||||
trans.ImportsH.HandleImport(child)
|
||||
elif kd == ast.ASTKind.ImportFrom:
|
||||
@@ -97,10 +101,6 @@ def translate_children(trans: HT.Translator | t.CPtr,
|
||||
# Phase 1a 声明模式:只注册 CExport/State 函数到全局表(解决翻译顺序依赖)
|
||||
# Phase 1b 全量翻译:正常翻译函数体
|
||||
if trans._declare_only == 0:
|
||||
fd_dbg: ast.FunctionDef | t.CPtr = (ast.FunctionDef | t.CPtr)(child)
|
||||
if fd_dbg is not None and fd_dbg.name is not None:
|
||||
stdio.printf("[DBG] TR func=%s\n", fd_dbg.name)
|
||||
stdio.fflush(0)
|
||||
added: int = HandlesFunctions.translate_function_def(trans, child)
|
||||
added_total += added
|
||||
elif trans._declare_only == 1:
|
||||
@@ -109,10 +109,6 @@ def translate_children(trans: HT.Translator | t.CPtr,
|
||||
# ClassDef 在模块级直接处理(不需要 builder)
|
||||
# _declare_only=2(import扫描模式)时跳过,只处理 import 依赖
|
||||
if trans._declare_only != 2:
|
||||
cd_dbg: ast.ClassDef | t.CPtr = (ast.ClassDef | t.CPtr)(child)
|
||||
if cd_dbg is not None and cd_dbg.name is not None:
|
||||
stdio.printf("[DBG] TR class=%s\n", cd_dbg.name)
|
||||
stdio.fflush(0)
|
||||
HandlesClassDef.translate_class_def(trans, child)
|
||||
elif trans._declare_only == 0 and trans._cur_builder is not None:
|
||||
# 有 builder → 委托 HandlesBody 分派
|
||||
|
||||
Reference in New Issue
Block a user