mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Minor fixes to JMP statements
This commit is contained in:
@@ -130,10 +130,10 @@ public static class ControlFlowAnalyzer
|
|||||||
sb.AppendLine($" >];");
|
sb.AppendLine($" >];");
|
||||||
|
|
||||||
if (block.NextOffset is not uint.MaxValue)
|
if (block.NextOffset is not uint.MaxValue)
|
||||||
sb.AppendLine($" {nodeId} -> {block.NextOffset};");
|
sb.AppendLine($" {nodeId}:s -> {block.NextOffset}:n;");
|
||||||
|
|
||||||
if (block.BranchTargetOffset is not uint.MaxValue)
|
if (block.BranchTargetOffset is not uint.MaxValue)
|
||||||
sb.AppendLine($" {nodeId} -> {block.BranchTargetOffset} [color=red];");
|
sb.AppendLine($" {nodeId}:s -> {block.BranchTargetOffset}:n [color=red];");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine("}");
|
sb.AppendLine("}");
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ partial class Decompiler
|
|||||||
|
|
||||||
var controlBlocks = ControlFlowAnalyzer.CreateGraph(methodBody);
|
var controlBlocks = ControlFlowAnalyzer.CreateGraph(methodBody);
|
||||||
var dotGraph = ControlFlowAnalyzer.SerializeToGraphviz(controlBlocks);
|
var dotGraph = ControlFlowAnalyzer.SerializeToGraphviz(controlBlocks);
|
||||||
//Console.WriteLine(dotGraph);
|
Console.WriteLine(dotGraph);
|
||||||
|
|
||||||
Stack<CodeBlockInfo> blockStack = [];
|
Stack<CodeBlockInfo> blockStack = [];
|
||||||
blockStack.Push(new(0, methodBody[^1].Offset, SyntaxKind.Block, null));
|
blockStack.Push(new(0, methodBody[^1].Offset, SyntaxKind.Block, null));
|
||||||
@@ -101,7 +101,7 @@ partial class Decompiler
|
|||||||
|
|
||||||
var symbolRef = export.SymbolReferenceTable[writeSymbolIndex];
|
var symbolRef = export.SymbolReferenceTable[writeSymbolIndex];
|
||||||
var symbolIdentifierExpr = IrisExpression.ToSyntax(symbolRef);
|
var symbolIdentifierExpr = IrisExpression.ToSyntax(symbolRef);
|
||||||
var newSymbolValueExpr = IrisExpression.ToSyntax(newSymbolValue, _context);
|
var newSymbolValueExpr = SimplifyExpression(IrisExpression.ToSyntax(newSymbolValue, _context), true);
|
||||||
|
|
||||||
StatementSyntax symbolWriteExpr;
|
StatementSyntax symbolWriteExpr;
|
||||||
|
|
||||||
@@ -175,14 +175,15 @@ partial class Decompiler
|
|||||||
var isPeek = opCode is OpCode.JumpIfFalsePeek or OpCode.JumpIfTruePeek or OpCode.JumpIfNullPeek;
|
var isPeek = opCode is OpCode.JumpIfFalsePeek or OpCode.JumpIfTruePeek or OpCode.JumpIfNullPeek;
|
||||||
var rawJumpCondition = IrisExpression.ToSyntax(isPeek ? stack.Peek() : stack.Pop(), _context);
|
var rawJumpCondition = IrisExpression.ToSyntax(isPeek ? stack.Peek() : stack.Pop(), _context);
|
||||||
|
|
||||||
|
// TODO: Invert jump condition when decompiling to blocks instead of gotos
|
||||||
var jumpCondition = opCode switch
|
var jumpCondition = opCode switch
|
||||||
{
|
{
|
||||||
OpCode.JumpIfFalse or
|
OpCode.JumpIfFalse or
|
||||||
OpCode.JumpIfFalsePeek => rawJumpCondition,
|
OpCode.JumpIfFalsePeek => LogicalNotOf(rawJumpCondition),
|
||||||
|
|
||||||
OpCode.JumpIfTruePeek => LogicalNotOf(rawJumpCondition),
|
OpCode.JumpIfTruePeek => rawJumpCondition,
|
||||||
|
|
||||||
OpCode.JumpIfNullPeek => BinaryExpression(SyntaxKind.ExclamationEqualsToken,
|
OpCode.JumpIfNullPeek => BinaryExpression(SyntaxKind.EqualsEqualsToken,
|
||||||
rawJumpCondition,
|
rawJumpCondition,
|
||||||
LiteralExpression(SyntaxKind.NullLiteralExpression)),
|
LiteralExpression(SyntaxKind.NullLiteralExpression)),
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ internal record IrisObject(object Object, TypeSchema Type)
|
|||||||
if (property is not null)
|
if (property is not null)
|
||||||
return property.PropertyType;
|
return property.PropertyType;
|
||||||
}
|
}
|
||||||
|
else if (expr is CastExpressionSyntax castExpr)
|
||||||
|
{
|
||||||
|
var castTargetName = QualifiedTypeName.Parse(castExpr.Type.ToString());
|
||||||
|
return ctx.GetImportedType(castTargetName);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user