refactor(tpv): 新语法 R10(反斜杠续行合并)+ 回退 R5(语义不等价)

- 反斜杠续行合并为单行(304 处),呼应"尽可能不换行"。
- 回退 c.DerefAs(p, v) → *p = v 两处(StructGenMixin):原写法是 bitcast 后
  store 指针位,新写法按 pointee 值类型赋值,类型不符(i8* → List 值),
  语义不等价,保留 c.DerefAs。

种子自举通过。
This commit is contained in:
TermiNexus committed 2026-10-04 22:56:27 +08:00
1 parent 185a2196ca
commit 30a3da4cd4
43 files changed
+305 -707

No files matched your search

+5 -10
View File
@@ -818,8 +818,7 @@ def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*,
stmt_pc0: ast.AST* = pre_children.get(pci0)
if stmt_pc0 is not None and stmt_pc0.kind() == ast.ASTKind.AnnAssign:
aa_pc0: ast.AnnAssign* = ast.AnnAssign*(stmt_pc0)
if aa_pc0.target is not None and aa_pc0.target.kind() == ast.ASTKind.Name \
and aa_pc0.annotation is not None:
if aa_pc0.target is not None and aa_pc0.target.kind() == ast.ASTKind.Name and aa_pc0.annotation is not None:
tgt_pc0: ast.Name* = ast.Name*(aa_pc0.target)
if tgt_pc0.id is not None and aa_pc0.annotation.kind() == ast.ASTKind.Attribute:
ann_pc0: ast.Attribute* = ast.Attribute*(aa_pc0.annotation)
@@ -835,8 +834,7 @@ def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*,
stmt_pc: ast.AST* = pre_children.get(pci)
if stmt_pc is not None and stmt_pc.kind() == ast.ASTKind.AnnAssign:
aa_pc: ast.AnnAssign* = ast.AnnAssign*(stmt_pc)
if aa_pc.target is not None and aa_pc.target.kind() == ast.ASTKind.Name \
and aa_pc.annotation is not None:
if aa_pc.target is not None and aa_pc.target.kind() == ast.ASTKind.Name and aa_pc.annotation is not None:
tgt_pc: ast.Name* = ast.Name*(aa_pc.target)
if tgt_pc.id is not None and aa_pc.annotation.kind() == ast.ASTKind.Attribute:
ann_pc: ast.Attribute* = ast.Attribute*(aa_pc.annotation)
@@ -1052,8 +1050,7 @@ def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*,
# UnaryOp(USub, Constant(1)) → -1
uop_cv: ast.UnaryOp* = ast.UnaryOp*(aa.value)
num_buf_u: bytes = mb.alloc(32)
if uop_cv.op == ast.OpKind.USub and uop_cv.operand is not None \
and uop_cv.operand.kind() == ast.ASTKind.Constant:
if uop_cv.op == ast.OpKind.USub and uop_cv.operand is not None and uop_cv.operand.kind() == ast.ASTKind.Constant:
uop_const: ast.Constant* = ast.Constant*(uop_cv.operand)
if uop_const.const_kind == ast.CONST_INT and num_buf_u is not None:
neg_val: int64 = -uop_const.int_val
@@ -1086,8 +1083,7 @@ def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*,
elif arg_kind == ast.ASTKind.UnaryOp:
uop_ca: ast.UnaryOp* = ast.UnaryOp*(first_arg)
num_buf_cu: bytes = mb.alloc(32)
if uop_ca.op == ast.OpKind.USub and uop_ca.operand is not None \
and uop_ca.operand.kind() == ast.ASTKind.Constant:
if uop_ca.op == ast.OpKind.USub and uop_ca.operand is not None and uop_ca.operand.kind() == ast.ASTKind.Constant:
uoc: ast.Constant* = ast.Constant*(uop_ca.operand)
if uoc.const_kind == ast.CONST_INT and num_buf_cu is not None:
neg_c_val: int64 = -uoc.int_val
@@ -1106,8 +1102,7 @@ def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*,
# 递归计算 BinOp 值
binop_val_bo: int64 = _eval_binop_int(first_arg)
num_buf_bo: bytes = mb.alloc(32)
if (binop_val_bo != 0 or _eval_binop_valid(first_arg) != 0) \
and num_buf_bo is not None:
if (binop_val_bo != 0 or _eval_binop_valid(first_arg) != 0) and num_buf_bo is not None:
viperlib.snprintf(num_buf_bo, 32, " = %lld", binop_val_bo)
pos = _PyiEmit(buf, buf_size, pos, num_buf_bo)
elif aa.value is not None and aa.value.kind() == ast.ASTKind.BinOp:
+26 -64
View File
@@ -409,10 +409,7 @@ def _cache_vpi_return_annots_text(vpi_buf: bytes, src_sha1: str) -> int:
# 无注解的特殊方法(构造/析构)跳过:它们有专门调用路径
skip_def: int = 0
if arrow_pos >= le and (
string.strcmp(mname_buf, "__init__") == 0 or \
string.strcmp(mname_buf, "__new__") == 0 or \
string.strcmp(mname_buf, "__before_init__") == 0 or \
string.strcmp(mname_buf, "__after_init__") == 0):
string.strcmp(mname_buf, "__init__") == 0 or string.strcmp(mname_buf, "__new__") == 0 or string.strcmp(mname_buf, "__before_init__") == 0 or string.strcmp(mname_buf, "__after_init__") == 0):
skip_def = 1
if skip_def == 0:
key_buf: bytes = stdlib.malloc(key_len + 1)
@@ -427,8 +424,7 @@ def _cache_vpi_return_annots_text(vpi_buf: bytes, src_sha1: str) -> int:
# 索引快速路径:索引可信(Built==Count)时一次探测判定
# 重复(命中即"首个注册优先"= 原线性扫描首个同名);
# 未命中 | 索引不可信 → 回退原线性扫描(正确性保证)。
if _g_vpi_ret_idx_built == _g_vpi_ret_count \
and _g_vpi_ret_idx is not None and _g_vpi_ret_idx_cap > 0:
if _g_vpi_ret_idx_built == _g_vpi_ret_count and _g_vpi_ret_idx is not None and _g_vpi_ret_idx_cap > 0:
if _vpi_idx_find(_g_vpi_ret_keys, VPI_KEY_LEN,
_g_vpi_ret_idx, _g_vpi_ret_idx_cap, key_buf) >= 0:
dup_key = 1
@@ -452,8 +448,7 @@ def _cache_vpi_return_annots_text(vpi_buf: bytes, src_sha1: str) -> int:
_g_vpi_ret_count += 1
# 同步索引:仅当插入前可信(Built==Count-1,含扩容
# 重建后)且插入成功;否则标记不可信(查找回退扫描)。
if _g_vpi_ret_idx_built == _g_vpi_ret_count - 1 \
and _vpi_idx_insert(_g_vpi_ret_idx, _g_vpi_ret_idx_cap,
if _g_vpi_ret_idx_built == _g_vpi_ret_count - 1 and _vpi_idx_insert(_g_vpi_ret_idx, _g_vpi_ret_idx_cap,
_g_vpi_ret_count - 1, key_buf) == 0:
_g_vpi_ret_idx_built = _g_vpi_ret_count
else:
@@ -652,8 +647,7 @@ def _cache_vpi_param_annots_text(vpi_buf: bytes, src_sha1: str) -> int:
# 索引快速路径:索引可信(Built==Count)时一次探测判定
# 重复(命中即"首个注册优先"= 原线性扫描首个同名);
# 未命中 | 索引不可信 → 回退原线性扫描(正确性保证)。
if _g_vpi_param_idx_built == _g_vpi_param_count \
and _g_vpi_param_idx is not None and _g_vpi_param_idx_cap > 0:
if _g_vpi_param_idx_built == _g_vpi_param_count and _g_vpi_param_idx is not None and _g_vpi_param_idx_cap > 0:
if _vpi_idx_find(_g_vpi_param_keys, VPI_PARAM_KEY_LEN,
_g_vpi_param_idx, _g_vpi_param_idx_cap, key_buf) >= 0:
dup_key = 1
@@ -677,8 +671,7 @@ def _cache_vpi_param_annots_text(vpi_buf: bytes, src_sha1: str) -> int:
_g_vpi_param_count += 1
# 同步索引:仅当插入前可信(Built==Count-1,含扩容
# 重建后)且插入成功;否则标记不可信(查找回退扫描)。
if _g_vpi_param_idx_built == _g_vpi_param_count - 1 \
and _vpi_idx_insert(_g_vpi_param_idx, _g_vpi_param_idx_cap,
if _g_vpi_param_idx_built == _g_vpi_param_count - 1 and _vpi_idx_insert(_g_vpi_param_idx, _g_vpi_param_idx_cap,
_g_vpi_param_count - 1, key_buf) == 0:
_g_vpi_param_idx_built = _g_vpi_param_count
else:
@@ -745,8 +738,7 @@ def _lookup_vpi_param_annots(src_sha1: str, cls_name: str, method_name: str) ->
# 扫描首个同名,首注册优先);未命中即"确无"(键表只追加、键文本注册后不改写,
# 索引随扩容整体重建且覆盖全表)⇒ 无需再线性扫描;索引不可信 → 回退线性扫描。
hit_p: int = -1
if _g_vpi_param_idx_built == _g_vpi_param_count \
and _g_vpi_param_idx is not None and _g_vpi_param_idx_cap > 0:
if _g_vpi_param_idx_built == _g_vpi_param_count and _g_vpi_param_idx is not None and _g_vpi_param_idx_cap > 0:
hit_p = _vpi_idx_find(_g_vpi_param_keys, VPI_PARAM_KEY_LEN,
_g_vpi_param_idx, _g_vpi_param_idx_cap, key_buf)
else:
@@ -779,8 +771,7 @@ def _resolve_vpi_param_annot_seg_template(pool: memhub.MemBuddy*,
i32_ty: mlirlite.LLVMType*,
i8_ptr_ty: mlirlite.LLVMType*) -> mlirlite.LLVMType*:
"""特化类 X[arg] 的参数注解段解析(模板 X[T] 注解 + T→arg 替换);未命中 None"""
if pool is None or src_sha1 is None or cls_name is None or method_name is None \
or _g_vpi_param_keys is None:
if pool is None or src_sha1 is None or cls_name is None or method_name is None or _g_vpi_param_keys is None:
return None
lbkt_t: str = string.strchr(cls_name, 91) # '[' = 91
if lbkt_t is None:
@@ -835,8 +826,7 @@ def _resolve_vpi_param_annot_seg_template(pool: memhub.MemBuddy*,
cur_seg_t += 1
seg_start_t: sizet = cur_t
seg_len_t: sizet = 0
while annots_t[seg_start_t + seg_len_t] != '\0' \
and annots_t[seg_start_t + seg_len_t] != '@':
while annots_t[seg_start_t + seg_len_t] != '\0' and annots_t[seg_start_t + seg_len_t] != '@':
seg_len_t += 1
if seg_len_t == 0:
break
@@ -955,8 +945,7 @@ def _resolve_vpi_param_annot_seg(pool: memhub.MemBuddy*,
cur_seg_p += 1
seg_start_p: sizet = cur_p
seg_len_p: sizet = 0
while prm_annots_p[seg_start_p + seg_len_p] != '\0' \
and prm_annots_p[seg_start_p + seg_len_p] != '@':
while prm_annots_p[seg_start_p + seg_len_p] != '\0' and prm_annots_p[seg_start_p + seg_len_p] != '@':
seg_len_p += 1
if seg_len_p == 0:
return None
@@ -1022,8 +1011,7 @@ def _ensure_vpi_ret_annot_loaded(src_sha1: str, temp_dir: str) -> int:
s1: int = src_sha1[1]
for pre_i in range(_g_vpi_ret_count):
pre_key: bytes = _g_vpi_ret_keys + pre_i * VPI_KEY_LEN
if pre_key[0] == s0 and pre_key[1] == s1 and \
string.strncmp(pre_key, src_sha1, sha1_len) == 0 and pre_key[sha1_len] == '.':
if pre_key[0] == s0 and pre_key[1] == s1 and string.strncmp(pre_key, src_sha1, sha1_len) == 0 and pre_key[sha1_len] == '.':
return 1
# 构造路径 {temp_dir}/{sha1[0:2]}/{sha1}.vpi(逐字符拼接,避免 %c 格式化问题)
td_len: sizet = string.strlen(temp_dir)
@@ -1122,8 +1110,7 @@ def _ensure_vpi_param_annot_loaded(src_sha1: str, temp_dir: str) -> int:
s1: int = src_sha1[1]
for pre_i in range(_g_vpi_param_count):
pre_key: bytes = _g_vpi_param_keys + pre_i * VPI_PARAM_KEY_LEN
if pre_key[0] == s0 and pre_key[1] == s1 and \
string.strncmp(pre_key, src_sha1, sha1_len) == 0 and pre_key[sha1_len] == '.':
if pre_key[0] == s0 and pre_key[1] == s1 and string.strncmp(pre_key, src_sha1, sha1_len) == 0 and pre_key[sha1_len] == '.':
return 1
# 构造路径 {temp_dir}/{sha1[0:2]}/{sha1}.vpi(逐字符拼接,避免 %c 格式化问题)
td_len: sizet = string.strlen(temp_dir)
@@ -1201,12 +1188,10 @@ def _subst_template_arg(annot: str, tparam: str, targ: str) -> str:
if p + tplen < alen:
next_ch = annot[p + tplen]
prev_ok: int = 1
if (prev_ch >= 'a' and prev_ch <= 'z') or (prev_ch >= 'A' and prev_ch <= 'Z') or \
(prev_ch >= '0' and prev_ch <= '9') or prev_ch == '_':
if (prev_ch >= 'a' and prev_ch <= 'z') or (prev_ch >= 'A' and prev_ch <= 'Z') or (prev_ch >= '0' and prev_ch <= '9') or prev_ch == '_':
prev_ok = 0
next_ok: int = 1
if (next_ch >= 'a' and next_ch <= 'z') or (next_ch >= 'A' and next_ch <= 'Z') or \
(next_ch >= '0' and next_ch <= '9') or next_ch == '_':
if (next_ch >= 'a' and next_ch <= 'z') or (next_ch >= 'A' and next_ch <= 'Z') or (next_ch >= '0' and next_ch <= '9') or next_ch == '_':
next_ok = 0
if prev_ok != 0 and next_ok != 0:
string.strncpy(out + opos, targ, tglen)
@@ -1249,8 +1234,7 @@ def _lookup_vpi_ret_annot(src_sha1: str, cls_name: str, method_name: str) -> str
# 不改写,索引随扩容整体重建且覆盖全表)⇒ 跳过精确线性扫描(下方泛型特化归一化
# 匹配兜底仍保留,其键形态不同、不依赖精确键命中);索引不可信 → 回退线性扫描。
hit_r: int = -1
if _g_vpi_ret_idx_built == _g_vpi_ret_count \
and _g_vpi_ret_idx is not None and _g_vpi_ret_idx_cap > 0:
if _g_vpi_ret_idx_built == _g_vpi_ret_count and _g_vpi_ret_idx is not None and _g_vpi_ret_idx_cap > 0:
hit_r = _vpi_idx_find(_g_vpi_ret_keys, VPI_KEY_LEN,
_g_vpi_ret_idx, _g_vpi_ret_idx_cap, key_buf)
else:
@@ -1286,10 +1270,7 @@ def _lookup_vpi_ret_annot(src_sha1: str, cls_name: str, method_name: str) -> str
gi: int
for gi in range(_g_vpi_ret_count):
gk: bytes = _g_vpi_ret_keys + gi * VPI_KEY_LEN
if string.strncmp(gk, src_sha1, sha1_len) == 0 and \
gk[sha1_len] == '.' and \
string.strncmp(gk + sha1_len + 1, base_v, base_len_v) == 0 and \
gk[sha1_len + 1 + base_len_v] == '[':
if string.strncmp(gk, src_sha1, sha1_len) == 0 and gk[sha1_len] == '.' and string.strncmp(gk + sha1_len + 1, base_v, base_len_v) == 0 and gk[sha1_len + 1 + base_len_v] == '[':
gklb: str = string.strchr(gk + sha1_len + 1 + base_len_v, ']')
if gklb is not None:
tparam_len_v: sizet = sizet(
@@ -1559,13 +1540,10 @@ def _resolve_vpi_ret_annot_str(pool: memhub.MemBuddy*,
while mk_e > mk_s and ret_annot[mk_e - 1] == ' ':
mk_e -= 1
mk_off_m: sizet = 0
if mk_e - mk_s >= 2 and (ret_annot[mk_s] == 't' or ret_annot[mk_s] == 'c') \
and ret_annot[mk_s + 1] == '.':
if mk_e - mk_s >= 2 and (ret_annot[mk_s] == 't' or ret_annot[mk_s] == 'c') and ret_annot[mk_s + 1] == '.':
mk_off_m = 2
mk_nlen: sizet = mk_e - mk_s - mk_off_m
if (mk_nlen == 5 and string.strncmp(ret_annot + mk_s + mk_off_m, "State", 5) == 0) \
or (mk_nlen == 7 and string.strncmp(ret_annot + mk_s + mk_off_m, "CExtern", 7) == 0) \
or (mk_nlen == 7 and string.strncmp(ret_annot + mk_s + mk_off_m, "CExport", 7) == 0):
if (mk_nlen == 5 and string.strncmp(ret_annot + mk_s + mk_off_m, "State", 5) == 0) or (mk_nlen == 7 and string.strncmp(ret_annot + mk_s + mk_off_m, "CExtern", 7) == 0) or (mk_nlen == 7 and string.strncmp(ret_annot + mk_s + mk_off_m, "CExport", 7) == 0):
return mlirlite.Void(pool)
has_cptr: int = 0
@@ -1652,8 +1630,7 @@ def _resolve_vpi_ret_annot_str(pool: memhub.MemBuddy*,
cptr_sub_ty = seg_ty_cs
elif string.strcmp(seg_buf, "t.CPtr") == 0 or string.strcmp(seg_buf, "CPtr") == 0:
has_cptr = 1
elif string.strcmp(seg_buf, "void") == 0 or string.strcmp(seg_buf, "CVoid") == 0 \
or string.strcmp(seg_buf, "void") == 0:
elif string.strcmp(seg_buf, "void") == 0 or string.strcmp(seg_buf, "CVoid") == 0 or string.strcmp(seg_buf, "void") == 0:
# 裸名 void 是 t.CVoid 的别名(用户 2026-10-01):必须与 CVoid 同处理,
# 否则会走 else 分支取到 first_td=1 → Ptr(Void) 这种非法类型
# (void* 应为 i8*,由下方 has_cptr 分支统一给出)。
@@ -1668,13 +1645,7 @@ def _resolve_vpi_ret_annot_str(pool: memhub.MemBuddy*,
# Ptr(first_ty) → `uint64*` 两侧不一致(定义 i8* vs declare i64*)。
if string.strchr(seg_buf, 46) is not None:
first_qual = 1
if string.strcmp(seg_buf, "int") == 0 or \
string.strcmp(seg_buf, "char") == 0 or \
string.strcmp(seg_buf, "str") == 0 or \
string.strcmp(seg_buf, "bytes") == 0 or \
string.strcmp(seg_buf, "bool") == 0 or \
string.strcmp(seg_buf, "float") == 0 or \
string.strcmp(seg_buf, "double") == 0:
if string.strcmp(seg_buf, "int") == 0 or string.strcmp(seg_buf, "char") == 0 or string.strcmp(seg_buf, "str") == 0 or string.strcmp(seg_buf, "bytes") == 0 or string.strcmp(seg_buf, "bool") == 0 or string.strcmp(seg_buf, "float") == 0 or string.strcmp(seg_buf, "double") == 0:
first_wl = 1
# 裸名 typedef 别名保真(N13,与定义侧同源):sizet/uint64/INT/u32 等别名若被判「非 struct 且不在白名单」会被坍缩成 i8*,
# 而定义侧已改为「解析成功即保留」⇒ 跨模块同型收敛被破坏。判据直接用 GenApi.resolve_typedef_or_map(与定义侧同一 API),命中即置位保留;
@@ -2279,8 +2250,7 @@ def _ParseVpiIntoModuleImpl(pool: memhub.MemBuddy*,
# ast/__init__.vpi 的 `parse_expression -> rawptr[Expression]`,而
# Expression 定义在 ast.stmts,真因是子模块 sha1 查找/注入失败)。
# 此处直接给出包名与子模块名(含补前缀后的精确名)便于定位。
if is_pkg_init_rt != 0 and sub_sha1_rt is None \
and sifr_mod is not None and sifr_mod[0] != '\0':
if is_pkg_init_rt != 0 and sub_sha1_rt is None and sifr_mod is not None and sifr_mod[0] != '\0':
GenApi.fatal_error(
sifr,
f"包 stub 的 from-import 子模块 sha1 查找失败:"
@@ -2485,9 +2455,7 @@ def _ParseVpiIntoModuleImpl(pool: memhub.MemBuddy*,
if aa.target is not None and aa.target.kind() == ast.ASTKind.Name:
dbg_tn: ast.Name* = ast.Name*(aa.target)
if dbg_tn.id is not None and dbg_tn.id[0] != '\0': # 存疑
if string.strcmp(dbg_tn.id, "irq_handler_t") == 0 \
or string.strcmp(dbg_tn.id, "gdt") == 0 \
or string.strcmp(dbg_tn.id, "KBD_BUF_SIZE") == 0:
if string.strcmp(dbg_tn.id, "irq_handler_t") == 0 or string.strcmp(dbg_tn.id, "gdt") == 0 or string.strcmp(dbg_tn.id, "KBD_BUF_SIZE") == 0:
dbg_ct: int = GenApi._is_ctypedef_annotation(aa.annotation)
dbg_cd: int = GenApi.is_cdefine_annotation(aa.annotation)
if GenApi._is_ctypedef_annotation(aa.annotation) != 0:
@@ -2496,8 +2464,7 @@ def _ParseVpiIntoModuleImpl(pool: memhub.MemBuddy*,
# vpi 里 CDefine 定义(如 keyboard.vp 的 KBD_BUF_SIZE: t.CDefine = 1024)
# 注册到当前文件 CDefine 表,供同 vpi 后续 t.CArray count 引用解析
# (否则跨模块 count 查找 [CDEF-MISS] fail-fast,VKernel PhaseA 根因)
if aa.target is not None and aa.target.kind() == ast.ASTKind.Name \
and aa.value is not None:
if aa.target is not None and aa.target.kind() == ast.ASTKind.Name and aa.value is not None:
cdef_tgt: ast.Name* = ast.Name*(aa.target)
if cdef_tgt.id is not None:
# 字符串 CDefine(版本号等)跳过:extract_cdefine_int_value
@@ -3136,8 +3103,7 @@ def _inject_global_variable_declare(pool: memhub.MemBuddy*,
# 先制造同名的 external global 声明,随后定义端再发射 global 定义 → llc:
# redefinition of global '@<sha1>.<name>'。与 _inject_function_declare /
# _inject_method_declare 的自注入守卫同因同构(那两处已修,全局此处此前遗漏)。
if trans is not None and trans._declare_only == 0 and trans.ModuleSha1 is not None \
and src_sha1 is not None:
if trans is not None and trans._declare_only == 0 and trans.ModuleSha1 is not None and src_sha1 is not None:
if string.strcmp(src_sha1, trans.ModuleSha1) == 0:
return
# mangled 名:带源模块 SHA1 前缀(对齐定义端 5f7a873 的 @<sha1>.<name>
@@ -3176,8 +3142,7 @@ def _inject_global_variable_declare(pool: memhub.MemBuddy*,
# 对象类(@t.Object/@t.CVTable:对象即指针,HasNew/HasVTable/IsOOP)→ Ptr(struct),与定义端 handle_module_level_var 一致;
# 纯 t.CStruct 值类(如 pci_device)保持值实例——一律转 Ptr 会把实例前 8 字节当指针解引用(#GP),一律保持值则 @t.Object 类模块级变量按指针访问读错 vtable(#PF)。
gv_entry_v: GenTypes.StructEntry* = GenApi.find_struct_by_type(resolved_v)
if gv_entry_v is not None \
and (gv_entry_v.HasNew != 0 or gv_entry_v.HasVTable != 0 or gv_entry_v.IsOOP != 0):
if gv_entry_v is not None and (gv_entry_v.HasNew != 0 or gv_entry_v.HasVTable != 0 or gv_entry_v.IsOOP != 0):
gv_ty_v = mlirlite.Ptr(pool, resolved_v)
else:
gv_ty_v = resolved_v
@@ -4035,8 +4000,7 @@ def _repl_stub_deco_flags(deco_list: list[ast.AST*]*) -> int:
k: int = deco.kind()
if k == ast.ASTKind.Attribute:
at: ast.Attribute* = ast.Attribute*(deco)
if at.attr is not None and at.value is not None \
and at.value.kind() == ast.ASTKind.Name:
if at.attr is not None and at.value is not None and at.value.kind() == ast.ASTKind.Name:
vn: ast.Name* = ast.Name*(at.value)
if vn.id is not None and string.strcmp(vn.id, "t") == 0:
nm = at.attr
@@ -4397,9 +4361,7 @@ def _repl_stub_add_class(pool: memhub.MemBuddy*,
e.Names = pool.alloc(8 * _REPL_STUB_FIELD_MAX)
e.Types = pool.alloc(8 * _REPL_STUB_FIELD_MAX)
e.VtNames = pool.alloc(8 * _REPL_STUB_VT_MAX)
if e.OwnNames is None or e.OwnTypes is None or e.MethodNames is None \
or e.MethodFlags is None or e.Bases is None or e.Names is None \
or e.Types is None or e.VtNames is None:
if e.OwnNames is None or e.OwnTypes is None or e.MethodNames is None or e.MethodFlags is None or e.Bases is None or e.Names is None or e.Types is None or e.VtNames is None:
return 0
string.memset(e.OwnNames, 0, 8 * _REPL_STUB_FIELD_MAX)
string.memset(e.OwnTypes, 0, 8 * _REPL_STUB_FIELD_MAX)