Fix ASM strings, ensure one time var on decomp
This commit is contained in:
parent
a64f77f435
commit
5eeed99f97
1 changed files with 23 additions and 4 deletions
|
@ -153,7 +153,7 @@ namespace arookas {
|
||||||
case 0x02: {
|
case 0x02: {
|
||||||
var data = sReader.ReadS32();
|
var data = sReader.ReadS32();
|
||||||
var value = FetchDataValue(data);
|
var value = FetchDataValue(data);
|
||||||
sWriter.Write(" {0} # \"{1}\"", data, value);
|
sWriter.Write(" {0} # \"{1}\"", data, value.Replace("\n", "\\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x03: sWriter.Write(" ${0:X8}", sReader.Read32()); break;
|
case 0x03: sWriter.Write(" ${0:X8}", sReader.Read32()); break;
|
||||||
|
@ -219,7 +219,7 @@ namespace arookas {
|
||||||
for (var i = 0; i < sDataCount; ++i) {
|
for (var i = 0; i < sDataCount; ++i) {
|
||||||
var ofs = sReader.Read32();
|
var ofs = sReader.Read32();
|
||||||
var data = FetchDataValue(ofs);
|
var data = FetchDataValue(ofs);
|
||||||
sWriter.WriteLine(" .string \"{0}\"", data);
|
sWriter.WriteLine(" .string \"{0}\"", data.Replace("\n", "\\n"));
|
||||||
}
|
}
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
}
|
}
|
||||||
|
@ -280,6 +280,7 @@ namespace arookas {
|
||||||
var maxofs = 0u;
|
var maxofs = 0u;
|
||||||
Stack<string> Stack = new Stack<string>();
|
Stack<string> Stack = new Stack<string>();
|
||||||
CodeGraph FuncCodeGraph = new CodeGraph();
|
CodeGraph FuncCodeGraph = new CodeGraph();
|
||||||
|
HashSet<string> DeclaredTable = new HashSet<string>();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
var pos = sReader.Position - sTextOffset;
|
var pos = sReader.Position - sTextOffset;
|
||||||
|
@ -388,8 +389,26 @@ namespace arookas {
|
||||||
string VariableName = "";
|
string VariableName = "";
|
||||||
switch (display)
|
switch (display)
|
||||||
{
|
{
|
||||||
case 0: VariableName = "var " + FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data)); break;
|
case 0:
|
||||||
case 1: VariableName = "var local " + data.ToString(); break;
|
{
|
||||||
|
VariableName = FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data));
|
||||||
|
if (!DeclaredTable.Contains(VariableName))
|
||||||
|
{
|
||||||
|
DeclaredTable.Add(VariableName);
|
||||||
|
VariableName = "var " + VariableName;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
VariableName = data.ToString();
|
||||||
|
if (!DeclaredTable.Contains(VariableName))
|
||||||
|
{
|
||||||
|
DeclaredTable.Add(VariableName);
|
||||||
|
VariableName = "var local " + VariableName;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CodeVertex NewLine = new CodeVertex(VertexType.CodeBlock , -1, VariableName + " = " + Stack.Pop() + ";", pos);
|
CodeVertex NewLine = new CodeVertex(VertexType.CodeBlock , -1, VariableName + " = " + Stack.Pop() + ";", pos);
|
||||||
FuncCodeGraph.AddVertex(NewLine);
|
FuncCodeGraph.AddVertex(NewLine);
|
||||||
|
|
Loading…
Reference in a new issue