Пример #1
0
 public ControlFlowLabelMap(ILBlock method, ErrorContext error)
 {
     method.FixParents();
     this.error = error;
     foreach (ILBasicBlock bb in method.GetSelfAndChildrenRecursive <ILBasicBlock>())
     {
         ILLabel entry = bb.Body[0] as ILLabel;
         //     ILExpression br = bb.Body.ElementAtOrDefault(bb.Body.Count - 2) as ILExpression;
         //     ILExpression b = bb.Body.ElementAtOrDefault(bb.Body.Count - 1) as ILExpression;
         //     if (br != null && (br.Code == GMCode.Bt || br.Code == GMCode.Bt)) labelToBranch[br.Operand as ILLabel].Add(entry);
         //   if (b != null && b.Code == GMCode.B) labelToBranch[b.Operand as ILLabel].Add(entry);
         // skip 1 cause we have the label entry
         labelToBasicBlock[entry] = bb;
         for (int i = 1; i < bb.Body.Count; i++)
         {
             ILNode       n = bb.Body[i];
             ILExpression e = n as ILExpression;
             if (e == null)
             {
                 continue;
             }
             foreach (var target in e.GetBranchTargets())
             {
                 labelGlobalRefCount[target] = labelGlobalRefCount.GetOrDefault(target) + 1;
                 HashSet <ILLabel> labels;
                 if (!labelToBranch.TryGetValue(target, out labels))
                 {
                     labelToBranch.Add(target, labels = new HashSet <ILLabel>());
                 }
                 labels.Add(entry);
             }
         }
     }
 }