Files
TransPyC/Test/IsinstanceTest/App/geom_lib.vp
T
TermiNexus 1b89225130 feat(TPC): 拓展 isinstance 跨模块支持
vtable linkage 改默认外部强定义(含 initializer 自动归一为空),跨模块可引用 sha1.Class_Vtable;外部引用声明为 i8* 避免 array 类型不匹配;_ResolveVtableAddr 增加 CVTable 状态检查,NoVTable 类回退编译时静态判断避免坏引用。新增 geom_lib.vp 跨模块测试库,main.vp 增加跨模块继承/运行时多态/NoVTable 场景。
2026-08-10 19:16:27 +08:00

44 lines
759 B
Plaintext

import t
from t import CInt
# ============================================================
# 跨模块 isinstance 测试库
#
# 供 main.vp import 使用:验证 isinstance 对"定义在其他模块
# 的类"也能正确比较(对象 vtable 指针跨 obj 链接解析)。
# ============================================================
@t.CVTable
class Shape:
def area(self) -> CInt:
return 0
@t.CVTable
class Circle(Shape):
r: CInt
def __init__(self, r: CInt):
self.r = r
def area(self) -> CInt:
return self.r
@t.CVTable
class Square(Shape):
s: CInt
def __init__(self, s: CInt):
self.s = s
def area(self) -> CInt:
return self.s
@t.NoVTable
class PlainShape:
tag: CInt