refactor(gen): 修复 CallGen 拆分后 undefined symbol(顶层改 1 级继承 + 跨 Mixin 走 HandlesExprCall 委托)
This commit is contained in:
1 parent
ef979d4435
commit
8d9ff96f61
6 files changed
+4144
-3391
No files matched your search
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+290
-3390
File diff suppressed because it is too large.
Load diff
@@ -7,6 +7,9 @@ import lib.core.Gen.TypeGenMixin as TypeGenMixin
|
||||
import lib.core.Gen.StructGenMixin as StructGenMixin
|
||||
import lib.core.Gen.ExprGenMixin as ExprGenMixin
|
||||
import lib.core.Gen.CallGenMixin as CallGenMixin
|
||||
import lib.core.Gen.CallGenBase as CallGenBase
|
||||
import lib.core.Gen.CallGenLeafKit as CallGenLeafKit
|
||||
import lib.core.Gen.CallGenCBuiltin as CallGenCBuiltin
|
||||
import lib.core.Gen.FuncGenMixin as FuncGenMixin
|
||||
import lib.core.Gen.ClassGenMixin as ClassGenMixin
|
||||
import lib.core.Gen.ImportsGenMixin as ImportsGenMixin
|
||||
@@ -33,7 +36,9 @@ import lib.core.Handles.HandlesExprCall as HandlesExprCall
|
||||
@t.NoVTable
|
||||
class Generator(BaseGenMixin.BaseGenMixin, TypeGenMixin.TypeGenMixin,
|
||||
StructGenMixin.StructGenMixin, ExprGenMixin.ExprGenMixin,
|
||||
CallGenMixin.CallGenMixin, FuncGenMixin.FuncGenMixin,
|
||||
CallGenMixin.CallGenMixin, CallGenBase.CallGenBase,
|
||||
CallGenLeafKit.CallGenLeafKit, CallGenCBuiltin.CallGenCBuiltin,
|
||||
FuncGenMixin.FuncGenMixin,
|
||||
ClassGenMixin.ClassGenMixin, ImportsGenMixin.ImportsGenMixin,
|
||||
StmtGenMixin.StmtGenMixin, AssignGenMixin.AssignGenMixin,
|
||||
VarGenMixin.VarGenMixin, TranslatorGenMixin.TranslatorGenMixin):
|
||||
|
||||
@@ -1766,3 +1766,53 @@ def NewExprCallHandle(pool: memhub.MemBuddy | t.CPtr,
|
||||
if g is not None:
|
||||
return g.NewExprCallHandle(pool, trans)
|
||||
return None
|
||||
|
||||
|
||||
# ============================================================
|
||||
# _make_vtable_ref_i8 / _emit_eh_guarded_call / _translate_isinstance
|
||||
# (追加91:CallGenMixin 拆分后顶层经委托调用 CallGenLeafKit 方法——
|
||||
# TPV self 调用仅支持 1 级父类,跨 Mixin 统一走 _g_gen 委托)
|
||||
# ============================================================
|
||||
def _make_vtable_ref_i8(pool: memhub.MemBuddy | t.CPtr,
|
||||
builder: llvmlite.IRBuilder | t.CPtr,
|
||||
mod: llvmlite.LLVMModule | t.CPtr,
|
||||
class_name: str,
|
||||
trans: HT.Translator | t.CPtr = None) -> llvmlite.Value | t.CPtr:
|
||||
"""构造类 vtable 地址引用(i8*)(委托到 gen._make_vtable_ref_i8)"""
|
||||
import lib.core.Gen.Generator as Generator
|
||||
g: Generator.Generator | t.CPtr = (Generator.Generator | t.CPtr)(t.CVoid(_g_gen, t.CPtr))
|
||||
if g is not None:
|
||||
return g._make_vtable_ref_i8(pool, builder, mod, class_name, trans)
|
||||
return None
|
||||
|
||||
|
||||
def _emit_eh_guarded_call(builder: llvmlite.IRBuilder | t.CPtr,
|
||||
pool: memhub.MemBuddy | t.CPtr,
|
||||
mod: llvmlite.LLVMModule | t.CPtr,
|
||||
trans: HT.Translator | t.CPtr,
|
||||
func: llvmlite.Function | t.CPtr,
|
||||
call_name: str,
|
||||
head: llvmlite.Value | t.CPtr,
|
||||
count: int,
|
||||
ret_ty: llvmlite.LLVMType | t.CPtr,
|
||||
is_variadic: int) -> llvmlite.Value | t.CPtr:
|
||||
"""带 try-except EH 检测的函数调用(委托到 gen._emit_eh_guarded_call)"""
|
||||
import lib.core.Gen.Generator as Generator
|
||||
g: Generator.Generator | t.CPtr = (Generator.Generator | t.CPtr)(t.CVoid(_g_gen, t.CPtr))
|
||||
if g is not None:
|
||||
return g._emit_eh_guarded_call(builder, pool, mod, trans, func, call_name, head, count, ret_ty, is_variadic)
|
||||
return None
|
||||
|
||||
|
||||
def _translate_isinstance(pool: memhub.MemBuddy | t.CPtr,
|
||||
builder: llvmlite.IRBuilder | t.CPtr,
|
||||
mod: llvmlite.LLVMModule | t.CPtr,
|
||||
obj_node: ast.AST | t.CPtr,
|
||||
cls_node: ast.AST | t.CPtr,
|
||||
trans: HT.Translator | t.CPtr = None) -> llvmlite.Value | t.CPtr:
|
||||
"""翻译 isinstance()(委托到 gen._translate_isinstance)"""
|
||||
import lib.core.Gen.Generator as Generator
|
||||
g: Generator.Generator | t.CPtr = (Generator.Generator | t.CPtr)(t.CVoid(_g_gen, t.CPtr))
|
||||
if g is not None:
|
||||
return g._translate_isinstance(pool, builder, mod, obj_node, cls_node, trans)
|
||||
return None
|
||||
Reference in new issue
Block a user