Commit 460c8a7c authored by Spencer Alves's avatar Spencer Alves

Some fixes, still not there yet

parent e59f2a7a
......@@ -399,7 +399,7 @@ namespace Altar.Repack
Occurrences = j.Has("occurrences") ? (uint)j["occurrences"] : 0,
FirstOffset = j.Has("firstoffset") ? (uint)j["firstoffset"] : 0xFFFFFFFF,
HasExtra = j.Has("instancetype") || j.Has("unknown"),
InstanceType = j.Has("instancetype") ? (InstanceType)(int)j["instancetype"] : InstanceType.Global,
InstanceType = j.Has("instancetype") ? (InstanceType)(int)j["instancetype"] : InstanceType.StackTopOrGlobal,
unknown2 = j.Has("unknown") ? (uint)j["unknown"] : 0
};
......@@ -532,7 +532,7 @@ namespace Altar.Repack
OpCode = op,
ReturnType = callinst.ReturnType
};
AddReference(functionReferences, new Tuple<string, InstanceType>(callinst.FunctionName, InstanceType.Global), size);
AddReference(functionReferences, new Tuple<string, InstanceType>(callinst.FunctionName, InstanceType.StackTopOrGlobal), size);
break;
case InstructionKind.Break:
var breakinst = (Break)inst;
......@@ -563,6 +563,11 @@ namespace Altar.Repack
OpCode = op,
Type = singleinst.Type
};
if (inst is Dup)
{
var dupinst = (Dup)inst;
bininst.SingleType.DupExtra = dupinst.Extra;
}
break;
case InstructionKind.Goto:
var gotoinst = (Branch)inst;
......
......@@ -1122,6 +1122,7 @@ namespace Altar.Repack
// StackTopOrGlobal isn't allowed in the reference definitions, but
// they still seem to be tracked in one of the other definitions.
IDictionary<Tuple<string, InstanceType>, List<uint>> refsToAdd = new Dictionary<Tuple<string, InstanceType>, List<uint>>();
IList<Tuple<string, InstanceType>> toRemove = new List<Tuple<string, InstanceType>>();
foreach (var kv in references)
{
if (kv.Key.Item2 != InstanceType.StackTopOrGlobal)
......@@ -1140,15 +1141,16 @@ namespace Altar.Repack
{
refsToAdd[key] = kv.Value;
}
toRemove.Add(new Tuple<string, InstanceType>(refdata[i].Name, InstanceType.StackTopOrGlobal));
break;
}
}
}
foreach (var kv in refsToAdd)
references.Add(kv);
for (int i = 0; i < refdata.Length; i++)
foreach (var key in toRemove)
{
references.Remove(new Tuple<string, InstanceType>(refdata[i].Name, InstanceType.StackTopOrGlobal));
references.Remove(key);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment