diff --git a/App/lib/Phase/BuildPipeline.vp b/App/lib/Phase/BuildPipeline.vp index 6240d9a..f7c2e1c 100644 --- a/App/lib/Phase/BuildPipeline.vp +++ b/App/lib/Phase/BuildPipeline.vp @@ -23,7 +23,7 @@ import lib.Stub.StubMerger as StubMerger import lib.Stub.StubGen.Converter as StubConverter import lib.Projectrans.Config as Config import lib.core.Gen.Generator as GenGenerator -import lib.core.Gen.ExprGenCls as ExprGenCls +import lib.core.Gen.Expr.ExprGenCls as ExprGenCls import lib.Stub.StubMerger.StubMergerCollect as StubMergerCollect # ============================================================ diff --git a/App/lib/core/Gen/AsyncGenMixin.vp b/App/lib/core/Gen/AsyncGenMixin.vp index d7137d8..50350ab 100644 --- a/App/lib/core/Gen/AsyncGenMixin.vp +++ b/App/lib/core/Gen/AsyncGenMixin.vp @@ -13,7 +13,7 @@ import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT import lib.core.Handles.HandlesExpr as HandlesExpr import lib.core.Handles.HandlesExprCall as HandlesExprCall -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/CallGenBase.vp b/App/lib/core/Gen/Call/CallGenBase.vp similarity index 100% rename from App/lib/core/Gen/CallGenBase.vp rename to App/lib/core/Gen/Call/CallGenBase.vp diff --git a/App/lib/core/Gen/CallGenCBuiltin.vp b/App/lib/core/Gen/Call/CallGenCBuiltin.vp similarity index 98% rename from App/lib/core/Gen/CallGenCBuiltin.vp rename to App/lib/core/Gen/Call/CallGenCBuiltin.vp index cf748d2..1be4494 100644 --- a/App/lib/core/Gen/CallGenCBuiltin.vp +++ b/App/lib/core/Gen/Call/CallGenCBuiltin.vp @@ -18,7 +18,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/CallGenCall.vp b/App/lib/core/Gen/Call/CallGenCall.vp similarity index 98% rename from App/lib/core/Gen/CallGenCall.vp rename to App/lib/core/Gen/Call/CallGenCall.vp index 8d61363..0177519 100644 --- a/App/lib/core/Gen/CallGenCall.vp +++ b/App/lib/core/Gen/Call/CallGenCall.vp @@ -18,7 +18,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase import lib.core.Handles.ExprCallTable as ExprCallTable @@ -950,8 +950,8 @@ class CallGenCall(CallGenBase.CallGenBase): call_ret_ty = frt_g found_func = spec_found_g gen_done = 1 - # mixin_hit:跨模块 Mixin 兜底已锁定定义类与返回类型,跳过 - # text.ll/vpi/pending 重查段,直接构造 {sha1}.{class}.{method} 调用名 + # mixin_hit:跨模块 Mixin 兜底已锁定定义类与返回类型,跳过 + # text.ll/vpi/pending 重查段,直接构造 {sha1}.{class}.{method} 调用名 if gen_done == 0 and mixin_hit == 0: # 尝试从 text.ll 查找实际返回类型 # 避免指针返回值被默认 i32 导致 inttoptr 截断 diff --git a/App/lib/core/Gen/CallGenCtor.vp b/App/lib/core/Gen/Call/CallGenCtor.vp similarity index 98% rename from App/lib/core/Gen/CallGenCtor.vp rename to App/lib/core/Gen/Call/CallGenCtor.vp index 7b708a5..c0a6947 100644 --- a/App/lib/core/Gen/CallGenCtor.vp +++ b/App/lib/core/Gen/Call/CallGenCtor.vp @@ -18,7 +18,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase import lib.core.Handles.ExprCallTable as ExprCallTable diff --git a/App/lib/core/Gen/CallGenDispatch.vp b/App/lib/core/Gen/Call/CallGenDispatch.vp similarity index 98% rename from App/lib/core/Gen/CallGenDispatch.vp rename to App/lib/core/Gen/Call/CallGenDispatch.vp index 85df4e3..911b99a 100644 --- a/App/lib/core/Gen/CallGenDispatch.vp +++ b/App/lib/core/Gen/Call/CallGenDispatch.vp @@ -1,7 +1,7 @@ import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator -import lib.core.Gen.ExprGenCls as ExprGenCls -import lib.core.Gen.ExprGenName as ExprGenName +import lib.core.Gen.Expr.ExprGenCls as ExprGenCls +import lib.core.Gen.Expr.ExprGenName as ExprGenName import t, c from stdint import * import ast @@ -21,7 +21,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ @@ -921,6 +921,40 @@ class CallGenDispatch(CallGenBase.CallGenBase): translate_call 会误判"未命中"继续走跨模块函数路径(把对象名 当模块名查 SHA1 → "跨模块调用 'buf.__before_init__' 找不到模块 SHA1")。 """ + # REnum.kind() 编译期转 __tag 读取(位置 0 i32): + # REnum 无 kind 方法(源码无、编译器不生成),此前 .kind() 被方法查找 + # 兜底误绑到 ast.AST.kind(this 偏移,语义错误)。此处直接翻译为 + # bitcast obj 到 i32* + load —— 零函数调用,返回变体 tag。 + if cl.func is not None and cl.func.kind() == ast.ASTKind.Attribute: + rk_at: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(cl.func) + if rk_at is not None and rk_at.attr is not None \ + and string.strcmp(rk_at.attr, "kind") == 0: + rk_obj: llvmlite.Value | t.CPtr = self.Gen.ExprGen.translate_value( + builder, pool, mod, rk_at.value, None, 0, trans) + if rk_obj is not None and rk_obj.Ty is not None: + rk_ty: llvmlite.LLVMType | t.CPtr = rk_obj.Ty + rk_load: int = 0 + if self.Gen.ExprGenBase.is_ptr_type(rk_ty) != 0: + rk_pointee: llvmlite.LLVMType | t.CPtr = rk_ty.Pointee + # 联合简化双指针(Ptr(Ptr(Struct)))→ 解一层 + load + if rk_pointee is not None \ + and self.Gen.ExprGenBase.is_ptr_type(rk_pointee) != 0: + rk_pointee = rk_pointee.Pointee + rk_load = 1 + rk_cls: str = self.Gen.StructGen.get_class_name_by_type(pool, rk_pointee) + if rk_cls is not None \ + and self.Gen.ClassGenEnum._is_renum_class_name(rk_cls) != 0: + rk_val: llvmlite.Value | t.CPtr = rk_obj + if rk_load != 0: + rk_val = llvmlite.build_load(builder, rk_ty, rk_obj) + if rk_val is not None: + if hit_box is not None: + hit_box[0] = 1 + rk_i32p: llvmlite.LLVMType | t.CPtr = llvmlite.Ptr( + pool, llvmlite.Int32(pool)) + rk_cast: llvmlite.Value | t.CPtr = llvmlite.build_bitcast( + builder, rk_val, rk_i32p) + return llvmlite.build_load(builder, rk_i32p, rk_cast) # 检测类名静态/类方法调用: ClassName.method(args) # 当 cl.func 是 Attribute、value 是已注册结构体类名(非普通变量)时, # 且方法带 @staticmethod/@classmethod 元数据,走静态调用路径 diff --git a/App/lib/core/Gen/CallGenFd.vp b/App/lib/core/Gen/Call/CallGenFd.vp similarity index 97% rename from App/lib/core/Gen/CallGenFd.vp rename to App/lib/core/Gen/Call/CallGenFd.vp index 0024457..b1f90ef 100644 --- a/App/lib/core/Gen/CallGenFd.vp +++ b/App/lib/core/Gen/Call/CallGenFd.vp @@ -18,7 +18,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/CallGenLeafKit.vp b/App/lib/core/Gen/Call/CallGenLeafKit.vp similarity index 97% rename from App/lib/core/Gen/CallGenLeafKit.vp rename to App/lib/core/Gen/Call/CallGenLeafKit.vp index cbd9ff6..4701306 100644 --- a/App/lib/core/Gen/CallGenLeafKit.vp +++ b/App/lib/core/Gen/Call/CallGenLeafKit.vp @@ -18,7 +18,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenCBuiltin as CallGenCBuiltin +import lib.core.Gen.Call.CallGenCBuiltin as CallGenCBuiltin # ============================================================ diff --git a/App/lib/core/Gen/CallGenLib.vp b/App/lib/core/Gen/Call/CallGenLib.vp similarity index 97% rename from App/lib/core/Gen/CallGenLib.vp rename to App/lib/core/Gen/Call/CallGenLib.vp index 62aedd4..97242ec 100644 --- a/App/lib/core/Gen/CallGenLib.vp +++ b/App/lib/core/Gen/Call/CallGenLib.vp @@ -17,7 +17,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/CallGenMixin.vp b/App/lib/core/Gen/Call/CallGenMixin.vp similarity index 99% rename from App/lib/core/Gen/CallGenMixin.vp rename to App/lib/core/Gen/Call/CallGenMixin.vp index 886f4ef..7d0367f 100644 --- a/App/lib/core/Gen/CallGenMixin.vp +++ b/App/lib/core/Gen/Call/CallGenMixin.vp @@ -19,7 +19,7 @@ import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory import lib.Stub.StubGen.VpiReader as VpiReader -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase import lib.core.Handles.ExprCallTable as ExprCallTable diff --git a/App/lib/core/Gen/CallGenProp.vp b/App/lib/core/Gen/Call/CallGenProp.vp similarity index 97% rename from App/lib/core/Gen/CallGenProp.vp rename to App/lib/core/Gen/Call/CallGenProp.vp index d008d40..0b2553f 100644 --- a/App/lib/core/Gen/CallGenProp.vp +++ b/App/lib/core/Gen/Call/CallGenProp.vp @@ -18,7 +18,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/CallGenVa.vp b/App/lib/core/Gen/Call/CallGenVa.vp similarity index 97% rename from App/lib/core/Gen/CallGenVa.vp rename to App/lib/core/Gen/Call/CallGenVa.vp index 85864b5..d90e9c0 100644 --- a/App/lib/core/Gen/CallGenVa.vp +++ b/App/lib/core/Gen/Call/CallGenVa.vp @@ -17,7 +17,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/CallGenVt.vp b/App/lib/core/Gen/Call/CallGenVt.vp similarity index 97% rename from App/lib/core/Gen/CallGenVt.vp rename to App/lib/core/Gen/Call/CallGenVt.vp index 761bab4..1932be0 100644 --- a/App/lib/core/Gen/CallGenVt.vp +++ b/App/lib/core/Gen/Call/CallGenVt.vp @@ -1,6 +1,6 @@ import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator -import lib.core.Gen.ExprGenAttr as ExprGenAttr +import lib.core.Gen.Expr.ExprGenAttr as ExprGenAttr import t, c from stdint import * import ast @@ -20,7 +20,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/ClassGenBase.vp b/App/lib/core/Gen/Class/ClassGenBase.vp similarity index 100% rename from App/lib/core/Gen/ClassGenBase.vp rename to App/lib/core/Gen/Class/ClassGenBase.vp diff --git a/App/lib/core/Gen/ClassGenDef.vp b/App/lib/core/Gen/Class/ClassGenDef.vp similarity index 98% rename from App/lib/core/Gen/ClassGenDef.vp rename to App/lib/core/Gen/Class/ClassGenDef.vp index be50b8e..fb8ab52 100644 --- a/App/lib/core/Gen/ClassGenDef.vp +++ b/App/lib/core/Gen/Class/ClassGenDef.vp @@ -13,7 +13,7 @@ import lib.core.Handles.HandlesTranslator as HT import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.ClassGenBase as ClassGenBase +import lib.core.Gen.Class.ClassGenBase as ClassGenBase # ============================================================ diff --git a/App/lib/core/Gen/ClassGenEnum.vp b/App/lib/core/Gen/Class/ClassGenEnum.vp similarity index 97% rename from App/lib/core/Gen/ClassGenEnum.vp rename to App/lib/core/Gen/Class/ClassGenEnum.vp index cd93746..bec3572 100644 --- a/App/lib/core/Gen/ClassGenEnum.vp +++ b/App/lib/core/Gen/Class/ClassGenEnum.vp @@ -13,7 +13,7 @@ import lib.core.Handles.HandlesTranslator as HT import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.ClassGenBase as ClassGenBase +import lib.core.Gen.Class.ClassGenBase as ClassGenBase # ============================================================ diff --git a/App/lib/core/Gen/ClassGenGeneric.vp b/App/lib/core/Gen/Class/ClassGenGeneric.vp similarity index 97% rename from App/lib/core/Gen/ClassGenGeneric.vp rename to App/lib/core/Gen/Class/ClassGenGeneric.vp index 56ac5a7..85d94e0 100644 --- a/App/lib/core/Gen/ClassGenGeneric.vp +++ b/App/lib/core/Gen/Class/ClassGenGeneric.vp @@ -13,7 +13,7 @@ import lib.core.Handles.HandlesTranslator as HT import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.ClassGenBase as ClassGenBase +import lib.core.Gen.Class.ClassGenBase as ClassGenBase import lib.Stub.StubMerger.StubMergerStore as StubMergerStore diff --git a/App/lib/core/Gen/ClassGenMixin.vp b/App/lib/core/Gen/Class/ClassGenMixin.vp similarity index 91% rename from App/lib/core/Gen/ClassGenMixin.vp rename to App/lib/core/Gen/Class/ClassGenMixin.vp index 69283fe..e5ec2e3 100644 --- a/App/lib/core/Gen/ClassGenMixin.vp +++ b/App/lib/core/Gen/Class/ClassGenMixin.vp @@ -11,7 +11,7 @@ import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.ClassGenBase as ClassGenBase +import lib.core.Gen.Class.ClassGenBase as ClassGenBase # ============================================================ # ClassGenMixin - 类定义/继承/泛型/vtable/enum/union/renum diff --git a/App/lib/core/Gen/ClassGenVTable.vp b/App/lib/core/Gen/Class/ClassGenVTable.vp similarity index 99% rename from App/lib/core/Gen/ClassGenVTable.vp rename to App/lib/core/Gen/Class/ClassGenVTable.vp index 774f6bc..4f0746c 100644 --- a/App/lib/core/Gen/ClassGenVTable.vp +++ b/App/lib/core/Gen/Class/ClassGenVTable.vp @@ -13,7 +13,7 @@ import lib.core.Handles.HandlesTranslator as HT import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.ClassGenBase as ClassGenBase +import lib.core.Gen.Class.ClassGenBase as ClassGenBase import lib.core.Handles.ExprCallTable as ExprCallTable diff --git a/App/lib/core/Gen/ExprGenAttr.vp b/App/lib/core/Gen/Expr/ExprGenAttr.vp similarity index 98% rename from App/lib/core/Gen/ExprGenAttr.vp rename to App/lib/core/Gen/Expr/ExprGenAttr.vp index 9ac1431..bb978c4 100644 --- a/App/lib/core/Gen/ExprGenAttr.vp +++ b/App/lib/core/Gen/Expr/ExprGenAttr.vp @@ -22,7 +22,7 @@ import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase # ============================================================ # ExprGenAttr - ExprGenMixin 拆分(阶段 D):Attribute/属性访问/全局引用 @@ -1014,13 +1014,13 @@ class ExprGenAttr(ExprGenBase.ExprGenBase): if parent_class is None: return None # 在父类中查 at.attr 字段,返回其注解类名 - cur_sha1: str = None - if trans is not None: - cur_sha1 = trans.ModuleSha1 - lfi_pc: str = None - if trans is not None: - lfi_pc = trans._from_imports - fe: GenTypes.FieldEntry | t.CPtr = self.Gen.StructGen.lookup_field_by_class( + cur_sha1: str = None + if trans is not None: + cur_sha1 = trans.ModuleSha1 + lfi_pc: str = None + if trans is not None: + lfi_pc = trans._from_imports + fe: GenTypes.FieldEntry | t.CPtr = self.Gen.StructGen.lookup_field_by_class( parent_class, at.attr, cur_sha1, at, lfi_pc) if fe is None: return None diff --git a/App/lib/core/Gen/ExprGenBase.vp b/App/lib/core/Gen/Expr/ExprGenBase.vp similarity index 100% rename from App/lib/core/Gen/ExprGenBase.vp rename to App/lib/core/Gen/Expr/ExprGenBase.vp diff --git a/App/lib/core/Gen/ExprGenCdef.vp b/App/lib/core/Gen/Expr/ExprGenCdef.vp similarity index 97% rename from App/lib/core/Gen/ExprGenCdef.vp rename to App/lib/core/Gen/Expr/ExprGenCdef.vp index 7b82cd8..c98a1e4 100644 --- a/App/lib/core/Gen/ExprGenCdef.vp +++ b/App/lib/core/Gen/Expr/ExprGenCdef.vp @@ -18,7 +18,7 @@ import lib.core.VLogger as VLogger import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase import lib.Stub.StubMerger.StubMergerCollect as StubMergerCollect import lib.Stub.StubMerger.StubMergerStore as StubMergerStore diff --git a/App/lib/core/Gen/ExprGenCls.vp b/App/lib/core/Gen/Expr/ExprGenCls.vp similarity index 97% rename from App/lib/core/Gen/ExprGenCls.vp rename to App/lib/core/Gen/Expr/ExprGenCls.vp index f14eddf..fba389f 100644 --- a/App/lib/core/Gen/ExprGenCls.vp +++ b/App/lib/core/Gen/Expr/ExprGenCls.vp @@ -1,6 +1,6 @@ import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase import t, c from stdint import * import ast @@ -22,7 +22,7 @@ import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils import lib.Stub.StubGen.VpiReader as VpiReader -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase import lib.Stub.StubMerger.StubMergerStore as StubMergerStore diff --git a/App/lib/core/Gen/ExprGenConst.vp b/App/lib/core/Gen/Expr/ExprGenConst.vp similarity index 97% rename from App/lib/core/Gen/ExprGenConst.vp rename to App/lib/core/Gen/Expr/ExprGenConst.vp index 42fcdf7..98be476 100644 --- a/App/lib/core/Gen/ExprGenConst.vp +++ b/App/lib/core/Gen/Expr/ExprGenConst.vp @@ -19,7 +19,7 @@ import lib.core.VLogger as VLogger import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase # ============================================================ @@ -118,13 +118,13 @@ class ExprGenConst(ExprGenBase.ExprGenBase): # (HandlesExpr:"目标是 ptr 但值是 char → 走字符串路径"):物化为 # 1 字符字符串。否则 coerce inttoptr 把字符值当指针(如 '"'=0x22), # 运行期 strlen 访问低地址 → ASan 崩溃(二代编 StringTest PyI 生成根因)。 - # 1a 阶段(declare_only=1)不 LoadDepVpi(vpi 未预生成)→ 依赖函数 - # found_func=None → translate_call 缺省参数补全不生效 → translate_value - # 调用参数数 < define(如 target_ty 缺省)→ x64 ABI 被调方读第 9 参 - # 栈槽残留垃圾(0x4 等)。declare_only 不产出 IR,target_ty 无用, - # 未对齐(8 对齐失败)即视为垃圾跳过,避免 is_ptr_type 解引用崩溃 - # (SlotsBugTest 1a string.vp 崩溃根因;1b found_func 非 None 正常填充)。 - if target_ty is not None and (t.CUInt64T(target_ty) & 7) == 0 \ + # 1a 阶段(declare_only=1)不 LoadDepVpi(vpi 未预生成)→ 依赖函数 + # found_func=None → translate_call 缺省参数补全不生效 → translate_value + # 调用参数数 < define(如 target_ty 缺省)→ x64 ABI 被调方读第 9 参 + # 栈槽残留垃圾(0x4 等)。declare_only 不产出 IR,target_ty 无用, + # 未对齐(8 对齐失败)即视为垃圾跳过,避免 is_ptr_type 解引用崩溃 + # (SlotsBugTest 1a string.vp 崩溃根因;1b found_func 非 None 正常填充)。 + if target_ty is not None and (t.CUInt64T(target_ty) & 7) == 0 \ and self.is_ptr_type(target_ty) != 0: cbuf: bytes = stdlib.malloc(2) if cbuf is None: diff --git a/App/lib/core/Gen/ExprGenFstr.vp b/App/lib/core/Gen/Expr/ExprGenFstr.vp similarity index 97% rename from App/lib/core/Gen/ExprGenFstr.vp rename to App/lib/core/Gen/Expr/ExprGenFstr.vp index 92e81ab..c273a96 100644 --- a/App/lib/core/Gen/ExprGenFstr.vp +++ b/App/lib/core/Gen/Expr/ExprGenFstr.vp @@ -19,7 +19,7 @@ import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase # ============================================================ # f-string 翻译常量(与 ExprGenMixin 保持一致,本地副本避免跨模块 diff --git a/App/lib/core/Gen/ExprGenMixin.vp b/App/lib/core/Gen/Expr/ExprGenMixin.vp similarity index 97% rename from App/lib/core/Gen/ExprGenMixin.vp rename to App/lib/core/Gen/Expr/ExprGenMixin.vp index 5b89a50..ac221d6 100644 --- a/App/lib/core/Gen/ExprGenMixin.vp +++ b/App/lib/core/Gen/Expr/ExprGenMixin.vp @@ -17,7 +17,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.VLogger as VLogger import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase # ============================================================ diff --git a/App/lib/core/Gen/ExprGenName.vp b/App/lib/core/Gen/Expr/ExprGenName.vp similarity index 98% rename from App/lib/core/Gen/ExprGenName.vp rename to App/lib/core/Gen/Expr/ExprGenName.vp index 1e3887c..f0f7e20 100644 --- a/App/lib/core/Gen/ExprGenName.vp +++ b/App/lib/core/Gen/Expr/ExprGenName.vp @@ -21,7 +21,7 @@ import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase # ============================================================ # ExprGenName - ExprGenMixin 拆分(阶段 D):Name/Subscript/下标访问 diff --git a/App/lib/core/Gen/ExprGenOps.vp b/App/lib/core/Gen/Expr/ExprGenOps.vp similarity index 98% rename from App/lib/core/Gen/ExprGenOps.vp rename to App/lib/core/Gen/Expr/ExprGenOps.vp index c9219fd..e805a03 100644 --- a/App/lib/core/Gen/ExprGenOps.vp +++ b/App/lib/core/Gen/Expr/ExprGenOps.vp @@ -20,7 +20,7 @@ import lib.Projectrans.Config as Config import lib.Projectrans.Utils as Utils -import lib.core.Gen.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase # ============================================================ # ExprGenOps - ExprGenMixin 拆分(阶段 D):比较/一元/布尔/binop 运算 diff --git a/App/lib/core/Gen/FuncGenBase.vp b/App/lib/core/Gen/Func/FuncGenBase.vp similarity index 97% rename from App/lib/core/Gen/FuncGenBase.vp rename to App/lib/core/Gen/Func/FuncGenBase.vp index 2791c4d..e58b6e9 100644 --- a/App/lib/core/Gen/FuncGenBase.vp +++ b/App/lib/core/Gen/Func/FuncGenBase.vp @@ -11,7 +11,7 @@ import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT import lib.core.Handles.HandlesExpr as HandlesExpr import lib.core.Handles.HandlesExprCall as HandlesExprCall -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ # FuncGenBase - FuncGenMixin 拆分(阶段 D):函数属性 / 命名 / mangle / create_function 基础工具 diff --git a/App/lib/core/Gen/FuncGenDef.vp b/App/lib/core/Gen/Func/FuncGenDef.vp similarity index 98% rename from App/lib/core/Gen/FuncGenDef.vp rename to App/lib/core/Gen/Func/FuncGenDef.vp index 8f38ecc..78d3bbe 100644 --- a/App/lib/core/Gen/FuncGenDef.vp +++ b/App/lib/core/Gen/Func/FuncGenDef.vp @@ -1,5 +1,5 @@ import lib.core.Gen.GenTypes as GenTypes -import lib.core.Gen.FuncGenMixin as FuncGenMixin +import lib.core.Gen.Func.FuncGenMixin as FuncGenMixin import t, c from stdint import * import ast @@ -14,7 +14,7 @@ import lib.core.Handles.HandlesTranslator as HT import lib.core.Handles.HandlesExpr as HandlesExpr import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.Handles.ExprCallTable as ExprCallTable -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/FuncGenMixin.vp b/App/lib/core/Gen/Func/FuncGenMixin.vp similarity index 99% rename from App/lib/core/Gen/FuncGenMixin.vp rename to App/lib/core/Gen/Func/FuncGenMixin.vp index 67f4bd7..af42d14 100644 --- a/App/lib/core/Gen/FuncGenMixin.vp +++ b/App/lib/core/Gen/Func/FuncGenMixin.vp @@ -12,7 +12,7 @@ import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT import lib.core.Handles.HandlesExpr as HandlesExpr import lib.core.Handles.HandlesExprCall as HandlesExprCall -import lib.core.Gen.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenBase as CallGenBase # ============================================================ diff --git a/App/lib/core/Gen/Generator.vp b/App/lib/core/Gen/Generator.vp index 60b7f33..f12b155 100644 --- a/App/lib/core/Gen/Generator.vp +++ b/App/lib/core/Gen/Generator.vp @@ -7,47 +7,47 @@ import stdlib import memhub import llvmlite import lib.core.Gen.BaseGenMixin as BaseGenMixin -import lib.core.Gen.TypeGenBase as TypeGenBase -import lib.core.Gen.TypeGenMixin as TypeGenMixin -import lib.core.Gen.TypeGenCDef as TypeGenCDef -import lib.core.Gen.TypeGenCType as TypeGenCType -import lib.core.Gen.TypeGenResolve as TypeGenResolve -import lib.core.Gen.TypeGenErr as TypeGenErr +import lib.core.Gen.Type.TypeGenBase as TypeGenBase +import lib.core.Gen.Type.TypeGenMixin as TypeGenMixin +import lib.core.Gen.Type.TypeGenCDef as TypeGenCDef +import lib.core.Gen.Type.TypeGenCType as TypeGenCType +import lib.core.Gen.Type.TypeGenResolve as TypeGenResolve +import lib.core.Gen.Type.TypeGenErr as TypeGenErr import lib.core.Gen.StructGenMixin as StructGenMixin -import lib.core.Gen.ExprGenBase as ExprGenBase -import lib.core.Gen.ExprGenMixin as ExprGenMixin -import lib.core.Gen.ExprGenConst as ExprGenConst -import lib.core.Gen.ExprGenFstr as ExprGenFstr -import lib.core.Gen.ExprGenOps as ExprGenOps -import lib.core.Gen.ExprGenCdef as ExprGenCdef -import lib.core.Gen.ExprGenName as ExprGenName -import lib.core.Gen.ExprGenAttr as ExprGenAttr -import lib.core.Gen.ExprGenCls as ExprGenCls -import lib.core.Gen.CallGenBase as CallGenBase -import lib.core.Gen.CallGenCBuiltin as CallGenCBuiltin -import lib.core.Gen.CallGenLeafKit as CallGenLeafKit -import lib.core.Gen.CallGenCtor as CallGenCtor -import lib.core.Gen.CallGenCall as CallGenCall -import lib.core.Gen.CallGenMixin as CallGenMixin -import lib.core.Gen.CallGenDispatch as CallGenDispatch -import lib.core.Gen.CallGenLib as CallGenLib -import lib.core.Gen.CallGenVt as CallGenVt -import lib.core.Gen.CallGenVa as CallGenVa -import lib.core.Gen.CallGenProp as CallGenProp -import lib.core.Gen.CallGenFd as CallGenFd -import lib.core.Gen.FuncGenBase as FuncGenBase -import lib.core.Gen.FuncGenDef as FuncGenDef -import lib.core.Gen.FuncGenMixin as FuncGenMixin -import lib.core.Gen.ClassGenBase as ClassGenBase -import lib.core.Gen.ClassGenMixin as ClassGenMixin -import lib.core.Gen.ClassGenEnum as ClassGenEnum -import lib.core.Gen.ClassGenGeneric as ClassGenGeneric -import lib.core.Gen.ClassGenVTable as ClassGenVTable -import lib.core.Gen.ClassGenDef as ClassGenDef +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenMixin as ExprGenMixin +import lib.core.Gen.Expr.ExprGenConst as ExprGenConst +import lib.core.Gen.Expr.ExprGenFstr as ExprGenFstr +import lib.core.Gen.Expr.ExprGenOps as ExprGenOps +import lib.core.Gen.Expr.ExprGenCdef as ExprGenCdef +import lib.core.Gen.Expr.ExprGenName as ExprGenName +import lib.core.Gen.Expr.ExprGenAttr as ExprGenAttr +import lib.core.Gen.Expr.ExprGenCls as ExprGenCls +import lib.core.Gen.Call.CallGenBase as CallGenBase +import lib.core.Gen.Call.CallGenCBuiltin as CallGenCBuiltin +import lib.core.Gen.Call.CallGenLeafKit as CallGenLeafKit +import lib.core.Gen.Call.CallGenCtor as CallGenCtor +import lib.core.Gen.Call.CallGenCall as CallGenCall +import lib.core.Gen.Call.CallGenMixin as CallGenMixin +import lib.core.Gen.Call.CallGenDispatch as CallGenDispatch +import lib.core.Gen.Call.CallGenLib as CallGenLib +import lib.core.Gen.Call.CallGenVt as CallGenVt +import lib.core.Gen.Call.CallGenVa as CallGenVa +import lib.core.Gen.Call.CallGenProp as CallGenProp +import lib.core.Gen.Call.CallGenFd as CallGenFd +import lib.core.Gen.Func.FuncGenBase as FuncGenBase +import lib.core.Gen.Func.FuncGenDef as FuncGenDef +import lib.core.Gen.Func.FuncGenMixin as FuncGenMixin +import lib.core.Gen.Class.ClassGenBase as ClassGenBase +import lib.core.Gen.Class.ClassGenMixin as ClassGenMixin +import lib.core.Gen.Class.ClassGenEnum as ClassGenEnum +import lib.core.Gen.Class.ClassGenGeneric as ClassGenGeneric +import lib.core.Gen.Class.ClassGenVTable as ClassGenVTable +import lib.core.Gen.Class.ClassGenDef as ClassGenDef import lib.core.Gen.ImportsGenMixin as ImportsGenMixin -import lib.core.Gen.StmtGenCifMixin as StmtGenCifMixin -import lib.core.Gen.StmtGenDeclMixin as StmtGenDeclMixin -import lib.core.Gen.StmtGenMixin as StmtGenMixin +import lib.core.Gen.Stmt.StmtGenCifMixin as StmtGenCifMixin +import lib.core.Gen.Stmt.StmtGenDeclMixin as StmtGenDeclMixin +import lib.core.Gen.Stmt.StmtGenMixin as StmtGenMixin import lib.core.Gen.MatchGenMixin as MatchGenMixin import lib.core.Gen.AssignGenMixin as AssignGenMixin import lib.core.Gen.AsyncGenMixin as AsyncGenMixin diff --git a/App/lib/core/Gen/MatchGenMixin.vp b/App/lib/core/Gen/MatchGenMixin.vp index 590ebec..9209440 100644 --- a/App/lib/core/Gen/MatchGenMixin.vp +++ b/App/lib/core/Gen/MatchGenMixin.vp @@ -1,33 +1,17 @@ -import lib.core.Gen.GenTypes as GenTypes -import lib.core.Gen.Generator as Generator import t, c from stdint import * import ast import llvmlite import memhub -import stdio import string import viperlib import lib.core.Handles.HandlesTranslator as HT -import lib.core.Handles.HandlesExpr as HandlesExpr +import lib.core.Gen.GenTypes as GenTypes +import lib.core.Gen.Generator as Generator # ============================================================ # MatchGenMixin - match 语句翻译 Mixin(P6 方法化) -# -# 从 HandlesMatch.vp 的 MatchHandle 类迁移(纯移动,逻辑零改动): -# Handle → translate_match(签名加 trans 首参,方法体 self.Trans → trans) -# 类内辅助方法 self._xxx → 保持 self.xxx,一并搬入成方法 -# 模块级辅助函数 _case_tail_unreachable → 搬入成方法 -# (原 HandlesMatch 模块级常量 MAX_MATCH_CASES/SCOPE_MATCH 一并复制) -# -# 迁移原则(与 P1-P6 一致,行为零变化): -# 1. 方法保留原逻辑,仅函数体内的 self.Trans 改为 trans 首参 -# 2. 外部模块调用(HandlesExpr.xxx/HandlesBody.xxx 等)保留模块前缀 -# 3. 原 HandlesMatch.translate_match 保留为"委托":本地模块级单例 _g_gen -# (BuildPipeline/main 注入)cast 成 Generator 类型 -# -# @t.NoVTable:静态绑定(方法沿 MRO 直接调用 + this 调整)。 # ============================================================ diff --git a/App/lib/core/Gen/StmtGenCifMixin.vp b/App/lib/core/Gen/Stmt/StmtGenCifMixin.vp similarity index 100% rename from App/lib/core/Gen/StmtGenCifMixin.vp rename to App/lib/core/Gen/Stmt/StmtGenCifMixin.vp diff --git a/App/lib/core/Gen/StmtGenDeclMixin.vp b/App/lib/core/Gen/Stmt/StmtGenDeclMixin.vp similarity index 97% rename from App/lib/core/Gen/StmtGenDeclMixin.vp rename to App/lib/core/Gen/Stmt/StmtGenDeclMixin.vp index aaf1d12..c6ca96a 100644 --- a/App/lib/core/Gen/StmtGenDeclMixin.vp +++ b/App/lib/core/Gen/Stmt/StmtGenDeclMixin.vp @@ -14,7 +14,7 @@ import lib.core.Handles.HandlesExpr as HandlesExpr import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory import lib.Projectrans.Config as Config -import lib.core.Gen.StmtGenCifMixin as StmtGenCifMixin +import lib.core.Gen.Stmt.StmtGenCifMixin as StmtGenCifMixin # ============================================================ diff --git a/App/lib/core/Gen/StmtGenMixin.vp b/App/lib/core/Gen/Stmt/StmtGenMixin.vp similarity index 97% rename from App/lib/core/Gen/StmtGenMixin.vp rename to App/lib/core/Gen/Stmt/StmtGenMixin.vp index a93f6be..8d8c643 100644 --- a/App/lib/core/Gen/StmtGenMixin.vp +++ b/App/lib/core/Gen/Stmt/StmtGenMixin.vp @@ -1,6 +1,6 @@ import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator -import lib.core.Gen.CallGenFd as CallGenFd +import lib.core.Gen.Call.CallGenFd as CallGenFd import t, c from stdint import * import ast @@ -16,7 +16,7 @@ import lib.core.Handles.HandlesExpr as HandlesExpr import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.CompilerFactory as CompilerFactory import lib.Projectrans.Config as Config -import lib.core.Gen.StmtGenDeclMixin as StmtGenDeclMixin +import lib.core.Gen.Stmt.StmtGenDeclMixin as StmtGenDeclMixin # ============================================================ diff --git a/App/lib/core/Gen/StructGenMixin.vp b/App/lib/core/Gen/StructGenMixin.vp index a3319a0..0290fdc 100644 --- a/App/lib/core/Gen/StructGenMixin.vp +++ b/App/lib/core/Gen/StructGenMixin.vp @@ -1,5 +1,3 @@ -import lib.core.Gen.GenTypes as GenTypes -import lib.core.Gen.Generator as Generator import t, c from stdint import * import memhub @@ -13,7 +11,8 @@ import viperlib import lib.core.CompilerFactory as CompilerFactory import lib.core.VLogger as VLogger import lib.Stub.StubMerger.StubMergerStore as StubMergerStore - +import lib.core.Gen.GenTypes as GenTypes +import lib.core.Gen.Generator as Generator # ============================================================ # StructGenMixin - 结构体注册/字段查找 Mixin(对象化 P2-2,wiki/14-oo-refactor.md) @@ -23,11 +22,6 @@ import lib.Stub.StubMerger.StubMergerStore as StubMergerStore # _visible_structs/_strict_visibility)→ 本类字段 # 模块级函数(register_struct/find_struct/lookup_field/...)→ 本类方法 # -# 迁移原则(与 TypeGenMixin P2-1 一致,行为零变化): -# 1. 方法保留原函数签名(含 pool 首参),仅函数体内的全局变量改为 self.字段 -# 2. HandlesStruct.vp 原函数保留为"委托":本地模块级单例 _g_gen(BuildPipeline -# /main 注入)cast 成 Generator 类型后调本类方法 -# 3. FieldEntry/StructEntry 类型保留在 HandlesStruct.vp(本类字段引用) # # @t.NoVTable:静态绑定(方法沿 MRO 直接调用 + this 调整,无 vtable 开销)。 # ============================================================ diff --git a/App/lib/core/Gen/TranslatorGenMixin.vp b/App/lib/core/Gen/TranslatorGenMixin.vp index e22cf82..558ddfd 100644 --- a/App/lib/core/Gen/TranslatorGenMixin.vp +++ b/App/lib/core/Gen/TranslatorGenMixin.vp @@ -5,12 +5,9 @@ import ast import llvmlite import memhub import string -import stdio -import stdlib import viperlib import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT -import lib.core.Handles.HandlesExprCall as HandlesExprCall import lib.core.Gen.GenTypes as GenTypes @@ -23,14 +20,6 @@ import lib.core.Gen.GenTypes as GenTypes # handle_module_level_var 等,原 HandlesMain.vp) # - global/nonlocal 名称管理辅助函数(原 HandlesTranslator.vp) # -# 迁移原则(与 P2-P5 一致,行为零变化): -# 1. 方法保留原函数签名(含 trans/pool 首参),仅函数体内的 -# 本模块函数调用改为 self.xxx(...) -# 2. 外部模块调用(HandlesType.xxx/HandlesVar.xxx 等)保留模块前缀 -# 3. HandlesMain/HandlesTranslator 原函数保留为"委托":本地模块级 -# 单例 _g_gen(BuildPipeline/main 注入)cast 成 Generator 类型 -# 4. 嵌套函数保持嵌套 -# # 常量(MAX_VARS/MAX_FUNCS/MAX_GLOBAL_NAMES)与原模块保持一致。 # @t.NoVTable:静态绑定(方法沿 MRO 直接调用 + this 调整)。 # ============================================================ diff --git a/App/lib/core/Gen/TypeGenBase.vp b/App/lib/core/Gen/Type/TypeGenBase.vp similarity index 99% rename from App/lib/core/Gen/TypeGenBase.vp rename to App/lib/core/Gen/Type/TypeGenBase.vp index 05d4c22..d248ed3 100644 --- a/App/lib/core/Gen/TypeGenBase.vp +++ b/App/lib/core/Gen/Type/TypeGenBase.vp @@ -1,4 +1,4 @@ -import lib.core.Gen.TypeGenMixin as TypeGenMixin +import lib.core.Gen.Type.TypeGenMixin as TypeGenMixin import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator import t, c diff --git a/App/lib/core/Gen/TypeGenCDef.vp b/App/lib/core/Gen/Type/TypeGenCDef.vp similarity index 97% rename from App/lib/core/Gen/TypeGenCDef.vp rename to App/lib/core/Gen/Type/TypeGenCDef.vp index 4256c08..8ed6816 100644 --- a/App/lib/core/Gen/TypeGenCDef.vp +++ b/App/lib/core/Gen/Type/TypeGenCDef.vp @@ -16,7 +16,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.TypeGenBase as TypeGenBase +import lib.core.Gen.Type.TypeGenBase as TypeGenBase # ============================================================ # TypeGenCDef - TypeGenMixin 拆分(阶段 D):CDefine 编译期常量表(register/lookup/is/set/clear) diff --git a/App/lib/core/Gen/TypeGenCType.vp b/App/lib/core/Gen/Type/TypeGenCType.vp similarity index 97% rename from App/lib/core/Gen/TypeGenCType.vp rename to App/lib/core/Gen/Type/TypeGenCType.vp index 571107b..f6e1e5f 100644 --- a/App/lib/core/Gen/TypeGenCType.vp +++ b/App/lib/core/Gen/Type/TypeGenCType.vp @@ -16,7 +16,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.TypeGenBase as TypeGenBase +import lib.core.Gen.Type.TypeGenBase as TypeGenBase # ============================================================ # TypeGenCType - TypeGenMixin 拆分(阶段 D):CTypedef 表(register/lookup/ScanCTypedefDeclarations/_eval_const_int_expr) diff --git a/App/lib/core/Gen/TypeGenErr.vp b/App/lib/core/Gen/Type/TypeGenErr.vp similarity index 99% rename from App/lib/core/Gen/TypeGenErr.vp rename to App/lib/core/Gen/Type/TypeGenErr.vp index c40ba8b..0b9acf5 100644 --- a/App/lib/core/Gen/TypeGenErr.vp +++ b/App/lib/core/Gen/Type/TypeGenErr.vp @@ -16,7 +16,7 @@ import lib.Stub.StubMerger as StubMerger import lib.core.CompilerFactory as CompilerFactory import lib.core.Handles.HandlesTranslator as HT -import lib.core.Gen.TypeGenBase as TypeGenBase +import lib.core.Gen.Type.TypeGenBase as TypeGenBase # ============================================================ diff --git a/App/lib/core/Gen/TypeGenMixin.vp b/App/lib/core/Gen/Type/TypeGenMixin.vp similarity index 93% rename from App/lib/core/Gen/TypeGenMixin.vp rename to App/lib/core/Gen/Type/TypeGenMixin.vp index 4938353..d6f0e32 100644 --- a/App/lib/core/Gen/TypeGenMixin.vp +++ b/App/lib/core/Gen/Type/TypeGenMixin.vp @@ -12,7 +12,7 @@ import w32.fileio as fileio import lib.core.CompilerFactory as CompilerFactory import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT -import lib.core.Gen.TypeGenBase as TypeGenBase +import lib.core.Gen.Type.TypeGenBase as TypeGenBase # ============================================================ diff --git a/App/lib/core/Gen/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp similarity index 98% rename from App/lib/core/Gen/TypeGenResolve.vp rename to App/lib/core/Gen/Type/TypeGenResolve.vp index 289c95d..0d6585d 100644 --- a/App/lib/core/Gen/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -1,7 +1,7 @@ import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator -import lib.core.Gen.TypeGenCType as TypeGenCType -import lib.core.Gen.TypeGenMixin as TypeGenMixin +import lib.core.Gen.Type.TypeGenCType as TypeGenCType +import lib.core.Gen.Type.TypeGenMixin as TypeGenMixin import t, c from stdint import * import ast @@ -20,7 +20,7 @@ import lib.Stub.StubMerger.StubMergerStore as StubMergerStore import lib.core.CompilerFactory as CompilerFactory -import lib.core.Gen.TypeGenBase as TypeGenBase +import lib.core.Gen.Type.TypeGenBase as TypeGenBase # ============================================================ # TypeGenResolve - TypeGenMixin 拆分(阶段 D):类型映射/注解解析(map_t_type/resolve_annotation_type 等) diff --git a/App/lib/core/Gen/VarGenMixin.vp b/App/lib/core/Gen/VarGenMixin.vp index 2071f3a..7748e84 100644 --- a/App/lib/core/Gen/VarGenMixin.vp +++ b/App/lib/core/Gen/VarGenMixin.vp @@ -17,17 +17,6 @@ import string # lookup_current/lookup_module_var/is_module_scope/get_or_create_sym) # → 本类方法。 # -# 迁移原则(与 P1-P5 一致,行为零变化): -# 1. 方法保留原函数签名(含 symtab/vars_ptr 等指针首参——self 是宿主 -# Generator,这些函数操作数据结构指针,self 可能少用,但为风格 -# 统一仍方法化) -# 2. 函数体原样搬入,本模块内部函数调用改为 self.xxx(...); -# 跨模块调用保留模块前缀(本模块无跨模块调用) -# 3. HandlesVar.vp 原函数保留为"一行委托":本地模块级单例 _g_gen -# (BuildPipeline/main 注入)cast 成 Generator 类型后调本类方法 -# 4. VarEntry/Scope/SymbolTable 数据结构类保留在 HandlesVar.vp -# (本类方法签名/函数体经 HandlesVar 前缀引用) -# # @t.NoVTable:静态绑定(方法沿 MRO 直接调用 + this 调整,无 vtable 开销)。 # ============================================================ diff --git a/App/lib/core/Handles/ExprCallTable.vp b/App/lib/core/Handles/ExprCallTable.vp index 176642a..db33e81 100644 --- a/App/lib/core/Handles/ExprCallTable.vp +++ b/App/lib/core/Handles/ExprCallTable.vp @@ -1,5 +1,5 @@ import lib.core.Gen.GenTypes as GenTypes -import lib.core.Gen.CallGenLeafKit as CallGenLeafKit +import lib.core.Gen.Call.CallGenLeafKit as CallGenLeafKit import t, c from stdint import * import ast diff --git a/App/lib/core/Handles/HandlesExpr.vp b/App/lib/core/Handles/HandlesExpr.vp index 5d15e0b..41dfb79 100644 --- a/App/lib/core/Handles/HandlesExpr.vp +++ b/App/lib/core/Handles/HandlesExpr.vp @@ -1,13 +1,13 @@ -import lib.core.Gen.ExprGenAttr as ExprGenAttr -import lib.core.Gen.ExprGenBase as ExprGenBase -import lib.core.Gen.ExprGenCdef as ExprGenCdef -import lib.core.Gen.ExprGenCls as ExprGenCls -import lib.core.Gen.ExprGenConst as ExprGenConst -import lib.core.Gen.ExprGenFstr as ExprGenFstr -import lib.core.Gen.ExprGenMixin as ExprGenMixin -import lib.core.Gen.ExprGenName as ExprGenName -import lib.core.Gen.ExprGenOps as ExprGenOps -import lib.core.Gen.FuncGenMixin as FuncGenMixin +import lib.core.Gen.Expr.ExprGenAttr as ExprGenAttr +import lib.core.Gen.Expr.ExprGenBase as ExprGenBase +import lib.core.Gen.Expr.ExprGenCdef as ExprGenCdef +import lib.core.Gen.Expr.ExprGenCls as ExprGenCls +import lib.core.Gen.Expr.ExprGenConst as ExprGenConst +import lib.core.Gen.Expr.ExprGenFstr as ExprGenFstr +import lib.core.Gen.Expr.ExprGenMixin as ExprGenMixin +import lib.core.Gen.Expr.ExprGenName as ExprGenName +import lib.core.Gen.Expr.ExprGenOps as ExprGenOps +import lib.core.Gen.Func.FuncGenMixin as FuncGenMixin import t, c from stdint import * import ast