Ejemplo n.º 1
0
        public Cut Write(Instruction instruction)
        {
            CutEvents.OnModify(_body);

            if (_entry)
            {
                Instructions.Insert(0, instruction);

                foreach (var handler in _body.ExceptionHandlers.Where(h => h.HandlerStart == null).ToList())
                {
                    handler.HandlerStart = _refInst;
                }
            }
            else if (_exit || _refInst == Instructions[Instructions.Count - 1])
            {
                Instructions.Add(instruction);

                if (!_exit)
                {
                    foreach (var handler in _body.ExceptionHandlers.Where(h => h.HandlerEnd == null).ToList())
                    {
                        handler.HandlerEnd = _refInst;
                    }
                }
            }
            else
            {
                var index = Instructions.IndexOf(_refInst) + 1;
                Instructions.Insert(index, instruction);
            }

            return(new Cut(_body, instruction));
        }
Ejemplo n.º 2
0
        public Cut Remove()
        {
            CutEvents.OnModify(_body);

            var prevCut = Prev();

            var next = _refInst.Next;
            var prev = _refInst.Previous;

            Redirect(_refInst, next, prev);
            Instructions.Remove(_refInst);

            return(prevCut);
        }
Ejemplo n.º 3
0
        public Cut Replace(Instruction instruction)
        {
            CutEvents.OnModify(_body);

            if (_exit || _entry)
            {
                return(Write(instruction));
            }

            Redirect(_refInst, instruction, instruction);
            Instructions[Instructions.IndexOf(_refInst)] = instruction;

            return(new Cut(_body, instruction));
        }