From 9bd77eca3d5a0fea7b57af6252d85ab4ce4c506d Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Tue, 6 May 2025 13:48:31 -0400 Subject: Add cast to partial var accesses in pseudo C/Rust Add casts to HLIL_STRUCT_FIELD expressions where the size of the source expression is greater than the size of access --- lang/rust/pseudorust.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lang/rust/pseudorust.cpp') diff --git a/lang/rust/pseudorust.cpp b/lang/rust/pseudorust.cpp index 80858658..380be7c6 100644 --- a/lang/rust/pseudorust.cpp +++ b/lang/rust/pseudorust.cpp @@ -1689,6 +1689,16 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe castedSrcExpr = true; } } + else if ((!settings || settings->IsOptionSet(ShowTypeCasts)) && srcExpr.operation == HLIL_VAR) + { + if (srcExpr.GetType() && srcExpr.GetType()->GetClass() != StructureTypeClass && srcExpr.size > instr.size) + { + GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence); + tokens.Append(KeywordToken, " as "); + AppendSizeToken(instr.size, false, tokens); + castedSrcExpr = true; + } + } if (!castedSrcExpr) GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence); -- cgit v1.3.1