- M1: async def -> 帧结构体 + create_/resume_ 状态机 + coro.coro_run 内联 - M2: async 参数、嵌套 await 提升 __await_N、If/While 内 await - M3: For 内 await(range->While)、coro_sleep 轮询挂起、coro_destroy 回池 - M4: raise 存码、await 子帧异常传播、coro_exception、coro_gather - M5/M6: try/except 链式匹配 + as e 绑定 + 异常类型码 - M7: try/finally、异常消息 msg 槽、自定义异常类、帧池复用
469 lines
25 KiB
Plaintext
469 lines
25 KiB
Plaintext
import string
|
||
import lib.core.CompilerFactory as CompilerFactory
|
||
import t, c
|
||
from stdint import *
|
||
import stdio
|
||
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.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.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.MatchGenMixin as MatchGenMixin
|
||
import lib.core.Gen.AssignGenMixin as AssignGenMixin
|
||
import lib.core.Gen.AsyncGenMixin as AsyncGenMixin
|
||
import lib.core.Gen.VarGenMixin as VarGenMixin
|
||
import lib.core.Gen.TranslatorGenMixin as TranslatorGenMixin
|
||
|
||
|
||
# ============================================================
|
||
# Generator - 生成器(双向引用组合架构)
|
||
#
|
||
# 不再 46 路多继承 Mixin;改为组合:Generator 持所有 GenMixin
|
||
# 子对象指针(永久池分配,全生命周期),每个 Mixin 持 Gen 回指。
|
||
# 跨子对象访问 = self.Gen.<Mixin 字段>.<字段/方法>(链式有风险,
|
||
# 统一用中间变量取子对象再访问)。高亮可推导(显式类型注解)。
|
||
# ============================================================
|
||
@t.NoVTable
|
||
class Generator:
|
||
"""生成器:持所有 GenMixin 子对象指针(双向引用组合)"""
|
||
|
||
# ---- 子对象指针(46 个,永久池) ----
|
||
BaseGen: BaseGenMixin.BaseGenMixin | t.CPtr
|
||
TypeGenBase: TypeGenBase.TypeGenBase | t.CPtr
|
||
TypeGen: TypeGenMixin.TypeGenMixin | t.CPtr
|
||
TypeGenCDef: TypeGenCDef.TypeGenCDef | t.CPtr
|
||
TypeGenCType: TypeGenCType.TypeGenCType | t.CPtr
|
||
TypeGenResolve: TypeGenResolve.TypeGenResolve | t.CPtr
|
||
TypeGenErr: TypeGenErr.TypeGenErr | t.CPtr
|
||
StructGen: StructGenMixin.StructGenMixin | t.CPtr
|
||
ExprGenBase: ExprGenBase.ExprGenBase | t.CPtr
|
||
ExprGen: ExprGenMixin.ExprGenMixin | t.CPtr
|
||
ExprGenConst: ExprGenConst.ExprGenConst | t.CPtr
|
||
ExprGenFstr: ExprGenFstr.ExprGenFstr | t.CPtr
|
||
ExprGenOps: ExprGenOps.ExprGenOps | t.CPtr
|
||
ExprGenCdef: ExprGenCdef.ExprGenCdef | t.CPtr
|
||
ExprGenName: ExprGenName.ExprGenName | t.CPtr
|
||
ExprGenAttr: ExprGenAttr.ExprGenAttr | t.CPtr
|
||
ExprGenCls: ExprGenCls.ExprGenCls | t.CPtr
|
||
CallGenBase: CallGenBase.CallGenBase | t.CPtr
|
||
CallGenCBuiltin: CallGenCBuiltin.CallGenCBuiltin | t.CPtr
|
||
CallGenLeafKit: CallGenLeafKit.CallGenLeafKit | t.CPtr
|
||
CallGenCtor: CallGenCtor.CallGenCtor | t.CPtr
|
||
CallGenCall: CallGenCall.CallGenCall | t.CPtr
|
||
CallGen: CallGenMixin.CallGenMixin | t.CPtr
|
||
CallGenDispatch: CallGenDispatch.CallGenDispatch | t.CPtr
|
||
CallGenLib: CallGenLib.CallGenLib | t.CPtr
|
||
CallGenVt: CallGenVt.CallGenVt | t.CPtr
|
||
CallGenVa: CallGenVa.CallGenVa | t.CPtr
|
||
CallGenProp: CallGenProp.CallGenProp | t.CPtr
|
||
CallGenFd: CallGenFd.CallGenFd | t.CPtr
|
||
FuncGenBase: FuncGenBase.FuncGenBase | t.CPtr
|
||
FuncGenDef: FuncGenDef.FuncGenDef | t.CPtr
|
||
FuncGen: FuncGenMixin.FuncGenMixin | t.CPtr
|
||
ClassGenBase: ClassGenBase.ClassGenBase | t.CPtr
|
||
ClassGen: ClassGenMixin.ClassGenMixin | t.CPtr
|
||
ClassGenEnum: ClassGenEnum.ClassGenEnum | t.CPtr
|
||
ClassGenGeneric: ClassGenGeneric.ClassGenGeneric | t.CPtr
|
||
ClassGenVTable: ClassGenVTable.ClassGenVTable | t.CPtr
|
||
ClassGenDef: ClassGenDef.ClassGenDef | t.CPtr
|
||
ImportsGen: ImportsGenMixin.ImportsGenMixin | t.CPtr
|
||
StmtGenCif: StmtGenCifMixin.StmtGenCifMixin | t.CPtr
|
||
StmtGenDecl: StmtGenDeclMixin.StmtGenDeclMixin | t.CPtr
|
||
StmtGen: StmtGenMixin.StmtGenMixin | t.CPtr
|
||
MatchGen: MatchGenMixin.MatchGenMixin | t.CPtr
|
||
AssignGen: AssignGenMixin.AssignGenMixin | t.CPtr
|
||
AsyncGen: AsyncGenMixin.AsyncGenMixin | t.CPtr
|
||
VarGen: VarGenMixin.VarGenMixin | t.CPtr
|
||
TranslatorGen: TranslatorGenMixin.TranslatorGenMixin | t.CPtr
|
||
|
||
def __init__(self, pool: memhub.MemBuddy | t.CPtr):
|
||
if self is None:
|
||
return
|
||
# ---- alloc 46 个子对象 + 回指(永久池,fail-fast) ----
|
||
SubBaseGen: BaseGenMixin.BaseGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(BaseGenMixin.BaseGenMixin.__sizeof__())
|
||
if SubBaseGen is None:
|
||
stdio.printf("FAIL: BaseGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubBaseGen, 0, BaseGenMixin.BaseGenMixin.__sizeof__())
|
||
SubBaseGen.Gen = self
|
||
self.BaseGen = SubBaseGen
|
||
SubTypeGenBase: TypeGenBase.TypeGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenBase.TypeGenBase.__sizeof__())
|
||
if SubTypeGenBase is None:
|
||
stdio.printf("FAIL: TypeGenBase alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTypeGenBase, 0, TypeGenBase.TypeGenBase.__sizeof__())
|
||
SubTypeGenBase.Gen = self
|
||
self.TypeGenBase = SubTypeGenBase
|
||
SubTypeGen: TypeGenMixin.TypeGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenMixin.TypeGenMixin.__sizeof__())
|
||
if SubTypeGen is None:
|
||
stdio.printf("FAIL: TypeGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTypeGen, 0, TypeGenMixin.TypeGenMixin.__sizeof__())
|
||
SubTypeGen.Gen = self
|
||
self.TypeGen = SubTypeGen
|
||
SubTypeGenCDef: TypeGenCDef.TypeGenCDef | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenCDef.TypeGenCDef.__sizeof__())
|
||
if SubTypeGenCDef is None:
|
||
stdio.printf("FAIL: TypeGenCDef alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTypeGenCDef, 0, TypeGenCDef.TypeGenCDef.__sizeof__())
|
||
SubTypeGenCDef.Gen = self
|
||
self.TypeGenCDef = SubTypeGenCDef
|
||
SubTypeGenCType: TypeGenCType.TypeGenCType | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenCType.TypeGenCType.__sizeof__())
|
||
if SubTypeGenCType is None:
|
||
stdio.printf("FAIL: TypeGenCType alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTypeGenCType, 0, TypeGenCType.TypeGenCType.__sizeof__())
|
||
SubTypeGenCType.Gen = self
|
||
self.TypeGenCType = SubTypeGenCType
|
||
SubTypeGenResolve: TypeGenResolve.TypeGenResolve | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenResolve.TypeGenResolve.__sizeof__())
|
||
if SubTypeGenResolve is None:
|
||
stdio.printf("FAIL: TypeGenResolve alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTypeGenResolve, 0, TypeGenResolve.TypeGenResolve.__sizeof__())
|
||
SubTypeGenResolve.Gen = self
|
||
self.TypeGenResolve = SubTypeGenResolve
|
||
SubTypeGenErr: TypeGenErr.TypeGenErr | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenErr.TypeGenErr.__sizeof__())
|
||
if SubTypeGenErr is None:
|
||
stdio.printf("FAIL: TypeGenErr alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTypeGenErr, 0, TypeGenErr.TypeGenErr.__sizeof__())
|
||
SubTypeGenErr.Gen = self
|
||
self.TypeGenErr = SubTypeGenErr
|
||
SubStructGen: StructGenMixin.StructGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StructGenMixin.StructGenMixin.__sizeof__())
|
||
if SubStructGen is None:
|
||
stdio.printf("FAIL: StructGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubStructGen, 0, StructGenMixin.StructGenMixin.__sizeof__())
|
||
SubStructGen.Gen = self
|
||
self.StructGen = SubStructGen
|
||
SubExprGenBase: ExprGenBase.ExprGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenBase.ExprGenBase.__sizeof__())
|
||
if SubExprGenBase is None:
|
||
stdio.printf("FAIL: ExprGenBase alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenBase, 0, ExprGenBase.ExprGenBase.__sizeof__())
|
||
SubExprGenBase.Gen = self
|
||
self.ExprGenBase = SubExprGenBase
|
||
SubExprGen: ExprGenMixin.ExprGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenMixin.ExprGenMixin.__sizeof__())
|
||
if SubExprGen is None:
|
||
stdio.printf("FAIL: ExprGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGen, 0, ExprGenMixin.ExprGenMixin.__sizeof__())
|
||
SubExprGen.Gen = self
|
||
self.ExprGen = SubExprGen
|
||
SubExprGenConst: ExprGenConst.ExprGenConst | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenConst.ExprGenConst.__sizeof__())
|
||
if SubExprGenConst is None:
|
||
stdio.printf("FAIL: ExprGenConst alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenConst, 0, ExprGenConst.ExprGenConst.__sizeof__())
|
||
SubExprGenConst.Gen = self
|
||
self.ExprGenConst = SubExprGenConst
|
||
SubExprGenFstr: ExprGenFstr.ExprGenFstr | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenFstr.ExprGenFstr.__sizeof__())
|
||
if SubExprGenFstr is None:
|
||
stdio.printf("FAIL: ExprGenFstr alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenFstr, 0, ExprGenFstr.ExprGenFstr.__sizeof__())
|
||
SubExprGenFstr.Gen = self
|
||
self.ExprGenFstr = SubExprGenFstr
|
||
SubExprGenOps: ExprGenOps.ExprGenOps | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenOps.ExprGenOps.__sizeof__())
|
||
if SubExprGenOps is None:
|
||
stdio.printf("FAIL: ExprGenOps alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenOps, 0, ExprGenOps.ExprGenOps.__sizeof__())
|
||
SubExprGenOps.Gen = self
|
||
self.ExprGenOps = SubExprGenOps
|
||
SubExprGenCdef: ExprGenCdef.ExprGenCdef | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenCdef.ExprGenCdef.__sizeof__())
|
||
if SubExprGenCdef is None:
|
||
stdio.printf("FAIL: ExprGenCdef alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenCdef, 0, ExprGenCdef.ExprGenCdef.__sizeof__())
|
||
SubExprGenCdef.Gen = self
|
||
self.ExprGenCdef = SubExprGenCdef
|
||
SubExprGenName: ExprGenName.ExprGenName | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenName.ExprGenName.__sizeof__())
|
||
if SubExprGenName is None:
|
||
stdio.printf("FAIL: ExprGenName alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenName, 0, ExprGenName.ExprGenName.__sizeof__())
|
||
SubExprGenName.Gen = self
|
||
self.ExprGenName = SubExprGenName
|
||
SubExprGenAttr: ExprGenAttr.ExprGenAttr | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenAttr.ExprGenAttr.__sizeof__())
|
||
if SubExprGenAttr is None:
|
||
stdio.printf("FAIL: ExprGenAttr alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenAttr, 0, ExprGenAttr.ExprGenAttr.__sizeof__())
|
||
SubExprGenAttr.Gen = self
|
||
self.ExprGenAttr = SubExprGenAttr
|
||
SubExprGenCls: ExprGenCls.ExprGenCls | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenCls.ExprGenCls.__sizeof__())
|
||
if SubExprGenCls is None:
|
||
stdio.printf("FAIL: ExprGenCls alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubExprGenCls, 0, ExprGenCls.ExprGenCls.__sizeof__())
|
||
SubExprGenCls.Gen = self
|
||
self.ExprGenCls = SubExprGenCls
|
||
SubCallGenBase: CallGenBase.CallGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenBase.CallGenBase.__sizeof__())
|
||
if SubCallGenBase is None:
|
||
stdio.printf("FAIL: CallGenBase alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenBase, 0, CallGenBase.CallGenBase.__sizeof__())
|
||
SubCallGenBase.Gen = self
|
||
self.CallGenBase = SubCallGenBase
|
||
SubCallGenCBuiltin: CallGenCBuiltin.CallGenCBuiltin | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenCBuiltin.CallGenCBuiltin.__sizeof__())
|
||
if SubCallGenCBuiltin is None:
|
||
stdio.printf("FAIL: CallGenCBuiltin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenCBuiltin, 0, CallGenCBuiltin.CallGenCBuiltin.__sizeof__())
|
||
SubCallGenCBuiltin.Gen = self
|
||
self.CallGenCBuiltin = SubCallGenCBuiltin
|
||
SubCallGenLeafKit: CallGenLeafKit.CallGenLeafKit | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenLeafKit.CallGenLeafKit.__sizeof__())
|
||
if SubCallGenLeafKit is None:
|
||
stdio.printf("FAIL: CallGenLeafKit alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenLeafKit, 0, CallGenLeafKit.CallGenLeafKit.__sizeof__())
|
||
SubCallGenLeafKit.Gen = self
|
||
self.CallGenLeafKit = SubCallGenLeafKit
|
||
SubCallGenCtor: CallGenCtor.CallGenCtor | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenCtor.CallGenCtor.__sizeof__())
|
||
if SubCallGenCtor is None:
|
||
stdio.printf("FAIL: CallGenCtor alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenCtor, 0, CallGenCtor.CallGenCtor.__sizeof__())
|
||
SubCallGenCtor.Gen = self
|
||
self.CallGenCtor = SubCallGenCtor
|
||
SubCallGenCall: CallGenCall.CallGenCall | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenCall.CallGenCall.__sizeof__())
|
||
if SubCallGenCall is None:
|
||
stdio.printf("FAIL: CallGenCall alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenCall, 0, CallGenCall.CallGenCall.__sizeof__())
|
||
SubCallGenCall.Gen = self
|
||
self.CallGenCall = SubCallGenCall
|
||
SubCallGen: CallGenMixin.CallGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenMixin.CallGenMixin.__sizeof__())
|
||
if SubCallGen is None:
|
||
stdio.printf("FAIL: CallGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGen, 0, CallGenMixin.CallGenMixin.__sizeof__())
|
||
SubCallGen.Gen = self
|
||
self.CallGen = SubCallGen
|
||
SubCallGenDispatch: CallGenDispatch.CallGenDispatch | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenDispatch.CallGenDispatch.__sizeof__())
|
||
if SubCallGenDispatch is None:
|
||
stdio.printf("FAIL: CallGenDispatch alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenDispatch, 0, CallGenDispatch.CallGenDispatch.__sizeof__())
|
||
SubCallGenDispatch.Gen = self
|
||
self.CallGenDispatch = SubCallGenDispatch
|
||
SubCallGenLib: CallGenLib.CallGenLib | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenLib.CallGenLib.__sizeof__())
|
||
if SubCallGenLib is None:
|
||
stdio.printf("FAIL: CallGenLib alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenLib, 0, CallGenLib.CallGenLib.__sizeof__())
|
||
SubCallGenLib.Gen = self
|
||
self.CallGenLib = SubCallGenLib
|
||
SubCallGenVt: CallGenVt.CallGenVt | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenVt.CallGenVt.__sizeof__())
|
||
if SubCallGenVt is None:
|
||
stdio.printf("FAIL: CallGenVt alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenVt, 0, CallGenVt.CallGenVt.__sizeof__())
|
||
SubCallGenVt.Gen = self
|
||
self.CallGenVt = SubCallGenVt
|
||
SubCallGenVa: CallGenVa.CallGenVa | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenVa.CallGenVa.__sizeof__())
|
||
if SubCallGenVa is None:
|
||
stdio.printf("FAIL: CallGenVa alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenVa, 0, CallGenVa.CallGenVa.__sizeof__())
|
||
SubCallGenVa.Gen = self
|
||
self.CallGenVa = SubCallGenVa
|
||
SubCallGenProp: CallGenProp.CallGenProp | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenProp.CallGenProp.__sizeof__())
|
||
if SubCallGenProp is None:
|
||
stdio.printf("FAIL: CallGenProp alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenProp, 0, CallGenProp.CallGenProp.__sizeof__())
|
||
SubCallGenProp.Gen = self
|
||
self.CallGenProp = SubCallGenProp
|
||
SubCallGenFd: CallGenFd.CallGenFd | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenFd.CallGenFd.__sizeof__())
|
||
if SubCallGenFd is None:
|
||
stdio.printf("FAIL: CallGenFd alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubCallGenFd, 0, CallGenFd.CallGenFd.__sizeof__())
|
||
SubCallGenFd.Gen = self
|
||
self.CallGenFd = SubCallGenFd
|
||
SubFuncGenBase: FuncGenBase.FuncGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(FuncGenBase.FuncGenBase.__sizeof__())
|
||
if SubFuncGenBase is None:
|
||
stdio.printf("FAIL: FuncGenBase alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubFuncGenBase, 0, FuncGenBase.FuncGenBase.__sizeof__())
|
||
SubFuncGenBase.Gen = self
|
||
self.FuncGenBase = SubFuncGenBase
|
||
SubFuncGenDef: FuncGenDef.FuncGenDef | t.CPtr = CompilerFactory.get_perm_pool().alloc(FuncGenDef.FuncGenDef.__sizeof__())
|
||
if SubFuncGenDef is None:
|
||
stdio.printf("FAIL: FuncGenDef alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubFuncGenDef, 0, FuncGenDef.FuncGenDef.__sizeof__())
|
||
SubFuncGenDef.Gen = self
|
||
self.FuncGenDef = SubFuncGenDef
|
||
SubFuncGen: FuncGenMixin.FuncGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(FuncGenMixin.FuncGenMixin.__sizeof__())
|
||
if SubFuncGen is None:
|
||
stdio.printf("FAIL: FuncGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubFuncGen, 0, FuncGenMixin.FuncGenMixin.__sizeof__())
|
||
SubFuncGen.Gen = self
|
||
self.FuncGen = SubFuncGen
|
||
SubClassGenBase: ClassGenBase.ClassGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenBase.ClassGenBase.__sizeof__())
|
||
if SubClassGenBase is None:
|
||
stdio.printf("FAIL: ClassGenBase alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubClassGenBase, 0, ClassGenBase.ClassGenBase.__sizeof__())
|
||
SubClassGenBase.Gen = self
|
||
self.ClassGenBase = SubClassGenBase
|
||
SubClassGen: ClassGenMixin.ClassGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenMixin.ClassGenMixin.__sizeof__())
|
||
if SubClassGen is None:
|
||
stdio.printf("FAIL: ClassGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubClassGen, 0, ClassGenMixin.ClassGenMixin.__sizeof__())
|
||
SubClassGen.Gen = self
|
||
self.ClassGen = SubClassGen
|
||
SubClassGenEnum: ClassGenEnum.ClassGenEnum | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenEnum.ClassGenEnum.__sizeof__())
|
||
if SubClassGenEnum is None:
|
||
stdio.printf("FAIL: ClassGenEnum alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubClassGenEnum, 0, ClassGenEnum.ClassGenEnum.__sizeof__())
|
||
SubClassGenEnum.Gen = self
|
||
self.ClassGenEnum = SubClassGenEnum
|
||
SubClassGenGeneric: ClassGenGeneric.ClassGenGeneric | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenGeneric.ClassGenGeneric.__sizeof__())
|
||
if SubClassGenGeneric is None:
|
||
stdio.printf("FAIL: ClassGenGeneric alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubClassGenGeneric, 0, ClassGenGeneric.ClassGenGeneric.__sizeof__())
|
||
SubClassGenGeneric.Gen = self
|
||
self.ClassGenGeneric = SubClassGenGeneric
|
||
SubClassGenVTable: ClassGenVTable.ClassGenVTable | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenVTable.ClassGenVTable.__sizeof__())
|
||
if SubClassGenVTable is None:
|
||
stdio.printf("FAIL: ClassGenVTable alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubClassGenVTable, 0, ClassGenVTable.ClassGenVTable.__sizeof__())
|
||
SubClassGenVTable.Gen = self
|
||
self.ClassGenVTable = SubClassGenVTable
|
||
SubClassGenDef: ClassGenDef.ClassGenDef | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenDef.ClassGenDef.__sizeof__())
|
||
if SubClassGenDef is None:
|
||
stdio.printf("FAIL: ClassGenDef alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubClassGenDef, 0, ClassGenDef.ClassGenDef.__sizeof__())
|
||
SubClassGenDef.Gen = self
|
||
self.ClassGenDef = SubClassGenDef
|
||
SubImportsGen: ImportsGenMixin.ImportsGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(ImportsGenMixin.ImportsGenMixin.__sizeof__())
|
||
if SubImportsGen is None:
|
||
stdio.printf("FAIL: ImportsGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubImportsGen, 0, ImportsGenMixin.ImportsGenMixin.__sizeof__())
|
||
SubImportsGen.Gen = self
|
||
self.ImportsGen = SubImportsGen
|
||
SubStmtGenCif: StmtGenCifMixin.StmtGenCifMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StmtGenCifMixin.StmtGenCifMixin.__sizeof__())
|
||
if SubStmtGenCif is None:
|
||
stdio.printf("FAIL: StmtGenCifMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubStmtGenCif, 0, StmtGenCifMixin.StmtGenCifMixin.__sizeof__())
|
||
SubStmtGenCif.Gen = self
|
||
self.StmtGenCif = SubStmtGenCif
|
||
SubStmtGenDecl: StmtGenDeclMixin.StmtGenDeclMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StmtGenDeclMixin.StmtGenDeclMixin.__sizeof__())
|
||
if SubStmtGenDecl is None:
|
||
stdio.printf("FAIL: StmtGenDeclMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubStmtGenDecl, 0, StmtGenDeclMixin.StmtGenDeclMixin.__sizeof__())
|
||
SubStmtGenDecl.Gen = self
|
||
self.StmtGenDecl = SubStmtGenDecl
|
||
SubStmtGen: StmtGenMixin.StmtGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StmtGenMixin.StmtGenMixin.__sizeof__())
|
||
if SubStmtGen is None:
|
||
stdio.printf("FAIL: StmtGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubStmtGen, 0, StmtGenMixin.StmtGenMixin.__sizeof__())
|
||
SubStmtGen.Gen = self
|
||
self.StmtGen = SubStmtGen
|
||
SubMatchGen: MatchGenMixin.MatchGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(MatchGenMixin.MatchGenMixin.__sizeof__())
|
||
if SubMatchGen is None:
|
||
stdio.printf("FAIL: MatchGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubMatchGen, 0, MatchGenMixin.MatchGenMixin.__sizeof__())
|
||
SubMatchGen.Gen = self
|
||
self.MatchGen = SubMatchGen
|
||
SubAssignGen: AssignGenMixin.AssignGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(AssignGenMixin.AssignGenMixin.__sizeof__())
|
||
if SubAssignGen is None:
|
||
stdio.printf("FAIL: AssignGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubAssignGen, 0, AssignGenMixin.AssignGenMixin.__sizeof__())
|
||
SubAssignGen.Gen = self
|
||
self.AssignGen = SubAssignGen
|
||
SubVarGen: VarGenMixin.VarGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(VarGenMixin.VarGenMixin.__sizeof__())
|
||
if SubVarGen is None:
|
||
stdio.printf("FAIL: VarGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubVarGen, 0, VarGenMixin.VarGenMixin.__sizeof__())
|
||
SubVarGen.Gen = self
|
||
self.VarGen = SubVarGen
|
||
SubTranslatorGen: TranslatorGenMixin.TranslatorGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(TranslatorGenMixin.TranslatorGenMixin.__sizeof__())
|
||
if SubTranslatorGen is None:
|
||
stdio.printf("FAIL: TranslatorGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubTranslatorGen, 0, TranslatorGenMixin.TranslatorGenMixin.__sizeof__())
|
||
SubTranslatorGen.Gen = self
|
||
self.TranslatorGen = SubTranslatorGen
|
||
SubAsyncGen: AsyncGenMixin.AsyncGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(AsyncGenMixin.AsyncGenMixin.__sizeof__())
|
||
if SubAsyncGen is None:
|
||
stdio.printf("FAIL: AsyncGenMixin alloc failed\n")
|
||
stdlib.exit(1)
|
||
string.memset(SubAsyncGen, 0, AsyncGenMixin.AsyncGenMixin.__sizeof__())
|
||
SubAsyncGen.Gen = self
|
||
self.AsyncGen = SubAsyncGen
|
||
|
||
# ---- 初始化各子对象字段(Init* 方法内联调用) ----
|
||
SubBaseGen.InitBaseGen(pool)
|
||
SubTypeGenBase.InitTypeGen()
|
||
SubCallGenBase.InitCallGen()
|
||
SubStructGen.InitStructGen()
|
||
SubClassGenBase.InitClassGen()
|
||
SubExprGenBase.InitExprGen()
|
||
SubImportsGen.InitImportsGen()
|
||
SubStmtGenCif.InitStmtGen()
|
||
SubAssignGen.InitAssignGen()
|
||
|
||
|
||
# ============================================================
|
||
# 全局生成器单例(组合架构兼容层)
|
||
# ============================================================
|
||
_g_gen: Generator | t.CPtr = None
|