コード例 #1
0
        private void LinkSection(ILNode node, BlockSection section)
        {
            bool useProxy1   = _random.NextBool();
            var  nextSibling = GetNextSiblingIgnoreNop(node);
            var  proxy       = useProxy1 ? section.Proxy1 : section.Proxy2;

            if (object.ReferenceEquals(nextSibling, proxy.Node))
            {
                proxy = useProxy1 ? section.Proxy2 : section.Proxy1;
            }

            // ldc.i4.X / ldslfd X
            int value = _random.Next(proxy.MinValue, proxy.MaxValue);

            if (_doNotUseFieldNumber)
            {
                node = node.AddNext(Instruction.GetLdc(value));
            }
            else
            {
                node = node.AddNext(OpCodes.Ldsfld, GetIntFieldRef(value));
            }

            // br [proxy]
            var targetLabel = new ILLabel();

            proxy.Node.AddPrevious(targetLabel);
            node = node.AddNext(OpCodes.Br, targetLabel);
        }