refactor(viperc): 清理标记下标推导中的内联类型转换
This commit is contained in:
1 parent
82a735c367
commit
850f61dc22
2 files changed
+8
-4
No files matched your search
@@ -362,7 +362,8 @@ novirtual class AssignGenMixin:
|
|||||||
nm = n2.id
|
nm = n2.id
|
||||||
elif k == ast.ASTKind.Subscript:
|
elif k == ast.ASTKind.Subscript:
|
||||||
# Descriptor wrapper (CConst[T] etc.): the width comes from the wrapped type.
|
# 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
|
if nm is None: return 0
|
||||||
return self._int_bits_of_type_name(pool, nm, 0)
|
return self._int_bits_of_type_name(pool, nm, 0)
|
||||||
|
|
||||||
@@ -433,7 +434,8 @@ novirtual class AssignGenMixin:
|
|||||||
n2: ast.Name* = ast.Name*(annot)
|
n2: ast.Name* = ast.Name*(annot)
|
||||||
nm = n2.id
|
nm = n2.id
|
||||||
elif k == ast.ASTKind.Subscript:
|
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
|
if nm is None: return 0
|
||||||
return self._float_kind_of_type_name(pool, nm, 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
|
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.
|
# Generic type param: a scalar-typed param uses its own size, a pointer/aggregate uses 8 bytes.
|
||||||
if inner_pe.kind() == ast.ASTKind.Name:
|
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:
|
if gp_nm is not None:
|
||||||
gp_resolved: str = self.Gen.TypeGenBase.resolve_generic_type_name(gp_nm)
|
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:
|
if gp_resolved is not None and string.strcmp(gp_resolved, gp_nm) != 0:
|
||||||
|
|||||||
@@ -1448,7 +1448,8 @@ novirtual class TypeGenResolve(TypeGenBase.TypeGenBase):
|
|||||||
if node.kind() != ast.ASTKind.Subscript: return 0
|
if node.kind() != ast.ASTKind.Subscript: return 0
|
||||||
sub_r: ast.Subscript* = ast.Subscript*(node)
|
sub_r: ast.Subscript* = ast.Subscript*(node)
|
||||||
if sub_r.value is None or sub_r.value.kind() != ast.ASTKind.Name: return 0
|
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 nm is None: return 0
|
||||||
if string.strcmp(nm, "CRef") == 0: return 1
|
if string.strcmp(nm, "CRef") == 0: return 1
|
||||||
if string.strcmp(nm, "CTempRef") == 0: return 2
|
if string.strcmp(nm, "CTempRef") == 0: return 2
|
||||||
|
|||||||
Reference in new issue
Block a user