mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-22 03:40:54 +00:00
braces
This commit is contained in:
parent
21836522ba
commit
65503c1a46
@ -34,7 +34,9 @@ namespace QSBTests
|
|||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
if (!field.Eq(fromField) && !field.Eq(toField) && !field.Eq(objectIdField))
|
if (!field.Eq(fromField) && !field.Eq(toField) && !field.Eq(objectIdField))
|
||||||
|
{
|
||||||
constructor.CheckUses(field, Util.UseType.Store);
|
constructor.CheckUses(field, Util.UseType.Store);
|
||||||
|
}
|
||||||
serialize.CheckUses(field, Util.UseType.Load);
|
serialize.CheckUses(field, Util.UseType.Load);
|
||||||
deserialize.CheckUses(field, Util.UseType.Store);
|
deserialize.CheckUses(field, Util.UseType.Store);
|
||||||
}
|
}
|
||||||
@ -51,7 +53,19 @@ namespace QSBTests
|
|||||||
a.DeclaringType.Name == b.DeclaringType.Name &&
|
a.DeclaringType.Name == b.DeclaringType.Name &&
|
||||||
a.Name == b.Name;
|
a.Name == b.Name;
|
||||||
|
|
||||||
public enum UseType { Store, Load }
|
public static bool IsOp<T>(this Instruction instruction, OpCode opCode, out T operand)
|
||||||
|
{
|
||||||
|
if (instruction.OpCode == opCode)
|
||||||
|
{
|
||||||
|
operand = (T)instruction.Operand;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
operand = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UseType { Store, Load };
|
||||||
|
|
||||||
public static void CheckUses(this MethodDefinition method, FieldReference field, UseType useType)
|
public static void CheckUses(this MethodDefinition method, FieldReference field, UseType useType)
|
||||||
{
|
{
|
||||||
@ -63,19 +77,29 @@ namespace QSBTests
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var stored = method.Body.Instructions.Any(x =>
|
var il = method.Body.Instructions;
|
||||||
x.OpCode == opCode &&
|
var uses = il.Any(x =>
|
||||||
field.Eq((FieldReference)x.Operand)
|
x.IsOp(opCode, out FieldReference f) &&
|
||||||
|
f.Eq(field)
|
||||||
);
|
);
|
||||||
if (stored) return;
|
if (uses)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var baseMethod = method.GetBaseMethod();
|
var baseMethod = method.GetBaseMethod();
|
||||||
if (baseMethod.Eq(method)) break;
|
if (baseMethod.Eq(method))
|
||||||
var callsBase = method.Body.Instructions.Any(x =>
|
{
|
||||||
x.OpCode == OpCodes.Call &&
|
break;
|
||||||
baseMethod.Eq((MethodReference)x.Operand)
|
}
|
||||||
|
var callBase = il.Any(x =>
|
||||||
|
x.IsOp(OpCodes.Call, out MethodReference m) &&
|
||||||
|
m.Eq(baseMethod)
|
||||||
);
|
);
|
||||||
if (!callsBase) break;
|
if (!callBase)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
method = baseMethod;
|
method = baseMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user