Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
Fix OpCodes with 'Br' and 'Brtrue'.
Browse files Browse the repository at this point in the history
  • Loading branch information
u-less committed Mar 5, 2020
1 parent 7366c54 commit e09a6b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
20 changes: 5 additions & 15 deletions src/Ray.Core/Core/Grains/ObserverGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public ObserverGrain()
if (!sortList.Contains(item))
sortList.Add(item);
}
var declare_1 = ilGen.DeclareLocal(typeof(Task));
var defaultLabel = ilGen.DefineLabel();
var lastLable = ilGen.DefineLabel();
var declare_1 = ilGen.DeclareLocal(typeof(Task));
foreach (var item in sortList)
{
ilGen.Emit(OpCodes.Ldarg_1);
Expand Down Expand Up @@ -110,15 +110,9 @@ public ObserverGrain()
ilGen.Emit(OpCodes.Ldloc_3);
}
}
if (item.DeclareLocal.LocalIndex > 0 && item.DeclareLocal.LocalIndex < 255)
ilGen.Emit(OpCodes.Brtrue_S, item.Lable);
else
ilGen.Emit(OpCodes.Brtrue, item.Lable);
ilGen.Emit(OpCodes.Brtrue, item.Lable);
}
if (declare_1.LocalIndex > 0 && declare_1.LocalIndex <= 255)
ilGen.Emit(OpCodes.Br_S, defaultLabel);
else
ilGen.Emit(OpCodes.Br, defaultLabel);
ilGen.Emit(OpCodes.Br, defaultLabel);
foreach (var item in sortList)
{
ilGen.MarkLabel(item.Lable);
Expand All @@ -145,10 +139,7 @@ public ObserverGrain()
{
ilGen.Emit(OpCodes.Stloc, declare_1);
}
if (declare_1.LocalIndex > 0 && declare_1.LocalIndex <= 255)
ilGen.Emit(OpCodes.Br_S, lastLable);
else
ilGen.Emit(OpCodes.Br, lastLable);
ilGen.Emit(OpCodes.Br, lastLable);
}
ilGen.MarkLabel(defaultLabel);
ilGen.Emit(OpCodes.Ldarg_0);
Expand All @@ -157,13 +148,12 @@ public ObserverGrain()
if (declare_1.LocalIndex > 0 && declare_1.LocalIndex <= 255)
{
ilGen.Emit(OpCodes.Stloc_S, declare_1);
ilGen.Emit(OpCodes.Br_S, lastLable);
}
else
{
ilGen.Emit(OpCodes.Stloc, declare_1);
ilGen.Emit(OpCodes.Br, lastLable);
}
ilGen.Emit(OpCodes.Br, lastLable);
//last
ilGen.MarkLabel(lastLable);
if (declare_1.LocalIndex > 0 && declare_1.LocalIndex <= 255)
Expand Down
13 changes: 2 additions & 11 deletions src/Ray.Core/Snapshot/SnapshotHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public SnapshotHandler()
sortList.Add(item);
}
var defaultLabel = ilGen.DefineLabel();
var maxLocalIndex = 0;
foreach (var item in sortList)
{
ilGen.Emit(OpCodes.Ldarg_2);
Expand Down Expand Up @@ -98,17 +97,9 @@ public SnapshotHandler()
ilGen.Emit(OpCodes.Ldloc_3);
}
}
if (item.DeclareLocal.LocalIndex > 0 && item.DeclareLocal.LocalIndex < 255)
ilGen.Emit(OpCodes.Brtrue_S, item.Lable);
else
ilGen.Emit(OpCodes.Brtrue, item.Lable);
if (item.DeclareLocal.LocalIndex > maxLocalIndex)
maxLocalIndex = item.DeclareLocal.LocalIndex;
ilGen.Emit(OpCodes.Brtrue, item.Lable);
}
if (maxLocalIndex > 0 && maxLocalIndex < 255)
ilGen.Emit(OpCodes.Br_S, defaultLabel);
else
ilGen.Emit(OpCodes.Br, defaultLabel);
ilGen.Emit(OpCodes.Br, defaultLabel);
foreach (var item in sortList)
{
ilGen.MarkLabel(item.Lable);
Expand Down

0 comments on commit e09a6b1

Please sign in to comment.