From 850f61dc224c82447b1f00c40fad34f9466d95ca Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 18 Oct 2026 13:40:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(viperc):=20=E6=B8=85=E7=90=86=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E4=B8=8B=E6=A0=87=E6=8E=A8=E5=AF=BC=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=86=85=E8=81=94=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Gen/AssignGenMixin.vp | 9 ++++++--- App/lib/core/Gen/Type/TypeGenResolve.vp | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/App/lib/core/Gen/AssignGenMixin.vp b/App/lib/core/Gen/AssignGenMixin.vp index 454687d..8ad98b9 100644 --- a/App/lib/core/Gen/AssignGenMixin.vp +++ b/App/lib/core/Gen/AssignGenMixin.vp @@ -362,7 +362,8 @@ novirtual class AssignGenMixin: nm = n2.id elif k == ast.ASTKind.Subscript: # Descriptor wrapper (CConst[T] etc.): the width comes from the wrapped type. - return self._annot_int_bits(pool, (ast.Subscript*(annot)).slice) + sub_ib: ast.Subscript* = ast.Subscript*(annot) + return self._annot_int_bits(pool, sub_ib.slice) if nm is None: return 0 return self._int_bits_of_type_name(pool, nm, 0) @@ -433,7 +434,8 @@ novirtual class AssignGenMixin: n2: ast.Name* = ast.Name*(annot) nm = n2.id elif k == ast.ASTKind.Subscript: - return self._annot_float_kind(pool, (ast.Subscript*(annot)).slice) + sub_fk: ast.Subscript* = ast.Subscript*(annot) + return self._annot_float_kind(pool, sub_fk.slice) if nm is None: return 0 return self._float_kind_of_type_name(pool, nm, 0) @@ -964,7 +966,8 @@ novirtual class AssignGenMixin: if self._annotation_contains_name(inner_pe, "bytes") != 0: return 1 # Generic type param: a scalar-typed param uses its own size, a pointer/aggregate uses 8 bytes. if inner_pe.kind() == ast.ASTKind.Name: - gp_nm: str = (ast.Name*(inner_pe)).id + inner_nm_pe: ast.Name* = ast.Name*(inner_pe) + gp_nm: str = inner_nm_pe.id if gp_nm is not None: gp_resolved: str = self.Gen.TypeGenBase.resolve_generic_type_name(gp_nm) if gp_resolved is not None and string.strcmp(gp_resolved, gp_nm) != 0: diff --git a/App/lib/core/Gen/Type/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp index 6e6038d..c9a6e15 100644 --- a/App/lib/core/Gen/Type/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -1448,7 +1448,8 @@ novirtual class TypeGenResolve(TypeGenBase.TypeGenBase): if node.kind() != ast.ASTKind.Subscript: return 0 sub_r: ast.Subscript* = ast.Subscript*(node) if sub_r.value is None or sub_r.value.kind() != ast.ASTKind.Name: return 0 - nm: str = (ast.Name*(sub_r.value)).id + nm_node_r: ast.Name* = ast.Name*(sub_r.value) + nm: str = nm_node_r.id if nm is None: return 0 if string.strcmp(nm, "CRef") == 0: return 1 if string.strcmp(nm, "CTempRef") == 0: return 2