mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Include return void statement when required; Temporarily use gotos
This commit is contained in:
@@ -118,27 +118,14 @@ partial class Decompiler
|
|||||||
blockStack.Peek().Statements.Add(ExpressionStatement(propertySetExpression));
|
blockStack.Peek().Statements.Add(ExpressionStatement(propertySetExpression));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode.PropertyDictionaryAdd:
|
case OpCode.VerifyTypeCast:
|
||||||
// TODO
|
var objToCast = stack.Pop();
|
||||||
var targetDictProperty = _context.GetImportedProperty(instruction.Operands.ElementAt(0));
|
var typeToCastTo = _context.GetImportedType(instruction.Operands.First());
|
||||||
|
|
||||||
var keyReference = instruction.Operands.ElementAt(1);
|
stack.Push(CastExpression(
|
||||||
var key = _context.GetConstant(keyReference).Value.ToString();
|
IrisExpression.ToSyntax(typeToCastTo, _context),
|
||||||
|
IrisExpression.ToSyntax(objToCast, _context)
|
||||||
var dictValue = stack.Pop();
|
));
|
||||||
|
|
||||||
var targetInstance = (XElement)stack.Peek();
|
|
||||||
|
|
||||||
PropertyDictionaryAddOnXElement(targetInstance, targetDictProperty, IrisObject.Create(dictValue, null, _context), key);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OpCode.PropertyListAdd:
|
|
||||||
// TODO
|
|
||||||
var targetListProperty = _context.GetImportedProperty(instruction.Operands.First());
|
|
||||||
var valueToAdd = stack.Pop();
|
|
||||||
var targetInstance2 = (XElement)ToXmlFriendlyObject(stack.Peek());
|
|
||||||
|
|
||||||
PropertyListAddOnXElement(targetInstance2, targetListProperty, IrisObject.Create(valueToAdd, null, _context));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode.JumpIfFalse:
|
case OpCode.JumpIfFalse:
|
||||||
@@ -149,7 +136,6 @@ partial class Decompiler
|
|||||||
// TODO: What about for loops?
|
// TODO: What about for loops?
|
||||||
if (instruction.Offset > jumpToOffset)
|
if (instruction.Offset > jumpToOffset)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPeek = opCode is OpCode.JumpIfFalsePeek or OpCode.JumpIfTruePeek or OpCode.JumpIfNullPeek;
|
var isPeek = opCode is OpCode.JumpIfFalsePeek or OpCode.JumpIfTruePeek or OpCode.JumpIfNullPeek;
|
||||||
@@ -169,19 +155,21 @@ partial class Decompiler
|
|||||||
_ => throw new NotImplementedException()
|
_ => throw new NotImplementedException()
|
||||||
};
|
};
|
||||||
|
|
||||||
var ifBlock = new CodeBlockInfo(instruction.Offset, jumpToOffset, SyntaxKind.IfStatement, jumpCondition);
|
//var ifBlock = new CodeBlockInfo(instruction.Offset, jumpToOffset, SyntaxKind.IfStatement, jumpCondition);
|
||||||
blockStack.Push(ifBlock);
|
//blockStack.Push(ifBlock);
|
||||||
|
|
||||||
|
var ifBlock = IfStatement(jumpCondition,
|
||||||
|
GotoStatement(SyntaxKind.GotoStatement, IdentifierName($"UIB_{jumpToOffset:X4}")))
|
||||||
|
.WithLeadingTrivia(Comment($"/* UIB_{instruction.Offset:X4} */"));
|
||||||
|
blockStack.Peek().Statements.Add(ifBlock);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode.Jump:
|
case OpCode.Jump:
|
||||||
var jumpOffset = (uint)instruction.Operands.First().Value;
|
var jumpOffset = (uint)instruction.Operands.First().Value;
|
||||||
var statementsJumpedTo = DecompileMethod(jumpOffset, export);
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
blockStack.Peek().Statements.Add(
|
blockStack.Peek().Statements.Add(GotoStatement(SyntaxKind.GotoStatement, IdentifierName($"UIB_{jumpOffset:X4}")));
|
||||||
Block(List([..statementsJumpedTo]))
|
|
||||||
.WithTrailingTrivia(EndOfLine(Environment.NewLine), Comment($"// TODO: {instruction}"))
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode.ReturnValue:
|
case OpCode.ReturnValue:
|
||||||
@@ -189,7 +177,18 @@ partial class Decompiler
|
|||||||
blockStack.Peek().Statements.Add(returnStatement);
|
blockStack.Peek().Statements.Add(returnStatement);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case not OpCode.ReturnVoid:
|
case OpCode.ReturnVoid:
|
||||||
|
// Include return statement when we're not in the main block (which would return anyway)
|
||||||
|
// or when we're not at the end of the function
|
||||||
|
if (blockStack.Count > 1 || i + 1 < methodBody.Length)
|
||||||
|
blockStack.Peek().Statements.Add(ReturnStatement());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OpCode.ClearSymbol:
|
||||||
|
// Ignore these instructions
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
if (!TryDecompileExpression(instruction, stack, blockStack))
|
if (!TryDecompileExpression(instruction, stack, blockStack))
|
||||||
{
|
{
|
||||||
var unsupportedComment = Comment($"// Unsupported instruction: {instruction}");
|
var unsupportedComment = Comment($"// Unsupported instruction: {instruction}");
|
||||||
|
|||||||
+18
-28
@@ -826,37 +826,27 @@
|
|||||||
<Script>string GetDefaultFrameBackground()
|
<Script>string GetDefaultFrameBackground()
|
||||||
{
|
{
|
||||||
source = null;
|
source = null;
|
||||||
|
/* UIB_001B */
|
||||||
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is not zuneUI:QuickplayPage)
|
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is not zuneUI:QuickplayPage)
|
||||||
{
|
goto UIB_0058;
|
||||||
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage)
|
/* UIB_0029 */
|
||||||
{
|
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage)
|
||||||
}
|
goto UIB_0038;
|
||||||
|
/* UIB_0038 */
|
||||||
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage && string.IsNullOrEmpty(zuneUI:Shell.SessionStartupPath))
|
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage && string.IsNullOrEmpty(zuneUI:Shell.SessionStartupPath))
|
||||||
{
|
goto UIB_0054;
|
||||||
}
|
/* UIB_0058 */
|
||||||
}
|
|
||||||
|
|
||||||
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is not zuneUI:QuickplayPage && zuneUI:ZuneShell.DefaultInstance.CurrentPage is not zuneUI:StartupPage || !(string.IsNullOrEmpty(zuneUI:Shell.SessionStartupPath)) || configuration:ClientConfiguration.Shell.StartupPage != zuneUI:Shell.MainFrame.Quickplay.DefaultUIPath)
|
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is not zuneUI:QuickplayPage && zuneUI:ZuneShell.DefaultInstance.CurrentPage is not zuneUI:StartupPage || !(string.IsNullOrEmpty(zuneUI:Shell.SessionStartupPath)) || configuration:ClientConfiguration.Shell.StartupPage != zuneUI:Shell.MainFrame.Quickplay.DefaultUIPath)
|
||||||
{
|
goto UIB_0083;
|
||||||
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage)
|
/* UIB_0066 */
|
||||||
{
|
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage)
|
||||||
}
|
goto UIB_007F;
|
||||||
}
|
/* UIB_0083 */
|
||||||
|
|
||||||
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:QuickplayPage || zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage && string.IsNullOrEmpty(zuneUI:Shell.SessionStartupPath) && configuration:ClientConfiguration.Shell.StartupPage == zuneUI:Shell.MainFrame.Quickplay.DefaultUIPath || zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage && zuneUI:Shell.SessionStartupPath == zuneUI:Shell.MainFrame.Quickplay.DefaultUIPath)
|
if (zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:QuickplayPage || zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage && string.IsNullOrEmpty(zuneUI:Shell.SessionStartupPath) && configuration:ClientConfiguration.Shell.StartupPage == zuneUI:Shell.MainFrame.Quickplay.DefaultUIPath || zuneUI:ZuneShell.DefaultInstance.CurrentPage is zuneUI:StartupPage && zuneUI:Shell.SessionStartupPath == zuneUI:Shell.MainFrame.Quickplay.DefaultUIPath)
|
||||||
{
|
goto UIB_0097;
|
||||||
source = QuickplayFrameBackground.Value;
|
source = QuickplayFrameBackground.Value;
|
||||||
{
|
goto UIB_00AA;
|
||||||
// Unsupported instruction: CSYM 63
|
source = (zuneUI:NamedStringOption)FrameBackgrounds.get_Item(DefaultBackgroundIndex).Value;
|
||||||
;
|
|
||||||
return source;
|
|
||||||
} // TODO: JMP 170
|
|
||||||
}// Unsupported instruction: VTC 960
|
|
||||||
;
|
|
||||||
source = FrameBackgrounds.get_Item(DefaultBackgroundIndex).Value;
|
|
||||||
// Unsupported instruction: CSYM 63
|
|
||||||
;
|
|
||||||
return source;
|
return source;
|
||||||
}</Script>
|
}</Script>
|
||||||
</Scripts>
|
</Scripts>
|
||||||
|
|||||||
Reference in New Issue
Block a user