예제 #1
0
        public static CIList ciInsert(CIList list, int index, CIList listToInsert)
        {
            if (index >= 0 && index <= list.Count)
            {
                List <Label> labels = null;

                if (index != list.Count && (list[index].labels?.Count ?? 0) > 0)                 // copy labels from instruction where we insert
                {
                    labels = new List <Label>(list[index].labels);
                    list[index].labels.Clear();
                }

                list.InsertRange(index, listToInsert);

                if (labels != null)
                {
                    list[index].labels.AddRange(labels);                     // add copied labels to a new instruction at 'index'
                }
            }
            else
            {
                Debug.assert(false, $"ciInsert: CodeInstruction index is invalid ({index})");
            }

            return(list);
        }
예제 #2
0
        public static CIList ciRemove(CIList list, int index, int countToRemove)
        {
            if (index >= 0 && index + countToRemove <= list.Count)
            {
                list.RemoveRange(index, countToRemove);
            }
            else
            {
                Debug.assert(false, "ciRemove: CodeInstruction index is invalid");
            }

            return(list);
        }
예제 #3
0
 public static CIList ciReplace(CIList list, CIPredicate predicate, params object[] cinsForReplace) =>
 ciReplace(list, list.FindIndex(predicate), cinsForReplace);
예제 #4
0
        public static CIList ciRemove(CIList list, CIPredicate predicate, int indexDelta, int countToRemove)
        {
            int index = list.FindIndex(predicate);

            return(ciRemove(list, (index == -1? -1: index + indexDelta), countToRemove));
        }
예제 #5
0
 public static CIList constToCfgVar <T, C>(CIList list, T val, string cfgVarName, ILGenerator ilg) where C : Component =>
 ciReplace(list, ci => ci.isLDC(val), _codeForCfgVar <T, C>(val, cfgVarName, ilg));
예제 #6
0
 public static CIList constToCfgVar <T>(CIList list, T val, string cfgVarName) =>
 ciReplace(list, ci => ci.isLDC(val), _codeForCfgVar(cfgVarName));