尝试进行 Qt 测试,增加了 AI 人机调试工具 _console,以及 TransPyV 进行修正

This commit is contained in:
2026-07-21 14:41:22 +08:00
parent a277ded8d4
commit 135aa05485
311 changed files with 7084 additions and 2131 deletions

View File

@@ -149,16 +149,8 @@ class AnnAssignHandle(BaseHandle):
if isinstance(TargetType, ir.IntType) and isinstance(Value.type, ir.IntType):
if TargetType.width < Value.type.width:
Value = Gen.builder.trunc(Value, TargetType, name="trunc")
elif TargetType.width > Value.type.width:
if Value.type.width == 1:
# i1 是布尔值,无符号语义,必须 zext
Value = Gen.builder.zext(Value, TargetType, name="zext")
else:
is_unsigned: bool = id(Value) in Gen._unsigned_results
if is_unsigned:
Value = Gen.builder.zext(Value, TargetType, name="zext")
else:
Value = Gen.builder.sext(Value, TargetType, name="sext")
else:
Value = Gen.builder.zext(Value, TargetType, name="zext")
elif isinstance(TargetType, ir.PointerType) and isinstance(Value.type, ir.PointerType):
Value = Gen.builder.bitcast(Value, TargetType, name="ptr_bitcast")
elif isinstance(TargetType, ir.PointerType) and isinstance(Value.type, ir.IntType):
@@ -317,7 +309,6 @@ class AnnAssignHandle(BaseHandle):
TypeInfo = CTypeInfo()
TypeInfo.BaseType = t.CInt()
IsPtr: bool = TypeInfo.IsPtr
if TypeInfo.IsDefine:
if Node.value and isinstance(Node.value, ast.Constant):
if not hasattr(Gen, '_define_constants'):
@@ -556,22 +547,14 @@ class AnnAssignHandle(BaseHandle):
VarPtr: ir.Value = Gen.variables[VarName]
if isinstance(VarPtr.type, ir.PointerType):
TargetType: ir.Type = VarPtr.type.pointee
if InitValue.type != TargetType:
if isinstance(InitValue.type, ir.IntType) and isinstance(TargetType, ir.IntType):
if TargetType.width > InitValue.type.width:
if InitValue.type.width == 1:
# i1 是布尔值,无符号语义,必须 zext
InitValue = Gen.builder.zext(InitValue, TargetType, name=f"zext_{VarName}")
else:
is_unsigned: bool = (Node.value is not None and Gen._check_node_unsigned(Node.value)) or id(InitValue) in Gen._unsigned_results
if is_unsigned:
InitValue = Gen.builder.zext(InitValue, TargetType, name=f"zext_{VarName}")
else:
InitValue = Gen.builder.sext(InitValue, TargetType, name=f"sext_{VarName}")
elif TargetType.width < InitValue.type.width:
InitValue = Gen.builder.trunc(InitValue, TargetType, name=f"trunc_{VarName}")
elif isinstance(InitValue.type, ir.PointerType) and isinstance(TargetType, ir.PointerType):
InitValue = Gen.builder.bitcast(InitValue, TargetType, name=f"cast_{VarName}")
if InitValue.type != TargetType:
if isinstance(InitValue.type, ir.IntType) and isinstance(TargetType, ir.IntType):
if TargetType.width > InitValue.type.width:
InitValue = Gen.builder.zext(InitValue, TargetType, name=f"zext_{VarName}")
elif TargetType.width < InitValue.type.width:
InitValue = Gen.builder.trunc(InitValue, TargetType, name=f"trunc_{VarName}")
elif isinstance(InitValue.type, ir.PointerType) and isinstance(TargetType, ir.PointerType):
InitValue = Gen.builder.bitcast(InitValue, TargetType, name=f"cast_{VarName}")
Gen._store(InitValue, VarPtr)
except Exception as _e:
if _config_mode == "strict":
@@ -648,15 +631,7 @@ class AnnAssignHandle(BaseHandle):
if InitValue.type != VarType:
if isinstance(InitValue.type, ir.IntType) and isinstance(VarType, ir.IntType):
if VarType.width > InitValue.type.width:
if InitValue.type.width == 1:
# i1 是布尔值,无符号语义,必须 zext
InitValue = Gen.builder.zext(InitValue, VarType, name=f"zext_{VarName}")
else:
is_unsigned: bool = (Node.value is not None and Gen._check_node_unsigned(Node.value)) or id(InitValue) in Gen._unsigned_results
if is_unsigned:
InitValue = Gen.builder.zext(InitValue, VarType, name=f"zext_{VarName}")
else:
InitValue = Gen.builder.sext(InitValue, VarType, name=f"sext_{VarName}")
InitValue = Gen.builder.zext(InitValue, VarType, name=f"zext_{VarName}")
elif VarType.width < InitValue.type.width:
InitValue = Gen.builder.trunc(InitValue, VarType, name=f"trunc_{VarName}")
elif isinstance(InitValue.type, ir.PointerType) and isinstance(VarType, ir.PointerType):