Weaver: SyncVarAccessReplacer: syntax & comments to make it more obvious

This commit is contained in:
mischa 2023-06-24 11:39:26 +08:00
parent 89f7d38005
commit 19065acb19

View File

@ -75,24 +75,36 @@ static void ProcessMethod(SyncVarAccessLists syncVarAccessLists, MethodDefinitio
static int ProcessInstruction(SyncVarAccessLists syncVarAccessLists, MethodDefinition md, Instruction instr, int iCount) static int ProcessInstruction(SyncVarAccessLists syncVarAccessLists, MethodDefinition md, Instruction instr, int iCount)
{ {
// stfld (sets value of a field)? // stfld (sets value of a field)?
if (instr.OpCode == OpCodes.Stfld && instr.Operand is FieldDefinition opFieldst) if (instr.OpCode == OpCodes.Stfld)
{ {
ProcessSetInstruction(syncVarAccessLists, md, instr, opFieldst); // operand is a FieldDefinition in the same assembly?
if (instr.Operand is FieldDefinition opFieldst)
{
ProcessSetInstruction(syncVarAccessLists, md, instr, opFieldst);
}
} }
// ldfld (load value of a field)? // ldfld (load value of a field)?
if (instr.OpCode == OpCodes.Ldfld && instr.Operand is FieldDefinition opFieldld) if (instr.OpCode == OpCodes.Ldfld)
{ {
// this instruction gets the value of a field. cache the field reference. // operand is a FieldDefinition in the same assembly?
ProcessGetInstruction(syncVarAccessLists, md, instr, opFieldld); if (instr.Operand is FieldDefinition opFieldld)
{
// this instruction gets the value of a field. cache the field reference.
ProcessGetInstruction(syncVarAccessLists, md, instr, opFieldld);
}
} }
// ldflda (load field address aka reference) // ldflda (load field address aka reference)
if (instr.OpCode == OpCodes.Ldflda && instr.Operand is FieldDefinition opFieldlda) if (instr.OpCode == OpCodes.Ldflda)
{ {
// watch out for initobj instruction // operand is a FieldDefinition in the same assembly?
// see https://github.com/vis2k/Mirror/issues/696 if (instr.Operand is FieldDefinition opFieldlda)
return ProcessLoadAddressInstruction(syncVarAccessLists, md, instr, opFieldlda, iCount); {
// watch out for initobj instruction
// see https://github.com/vis2k/Mirror/issues/696
return ProcessLoadAddressInstruction(syncVarAccessLists, md, instr, opFieldlda, iCount);
}
} }
// we processed one instruction (instr) // we processed one instruction (instr)