Mosa.Compiler.Framework.InstructionNode.Insert C# (CSharp) Method

Insert() public method

public Insert ( InstructionNode node ) : void
node InstructionNode
return void
        public void Insert(InstructionNode node)
        {
            //Block.DebugCheck();

            node.Block = Block;
            var firstnode = node;

            while (firstnode.Previous != null)
            {
                firstnode.Block = Block;
                firstnode = firstnode.Previous;
            }

            var lastnode = firstnode;

            while (lastnode.Next != null)
            {
                lastnode.Block = Block;
                lastnode = lastnode.Next;
            }

            Debug.Assert(!firstnode.IsBlockStartInstruction);
            Debug.Assert(!firstnode.IsBlockEndInstruction);
            Debug.Assert(!lastnode.IsBlockStartInstruction);
            Debug.Assert(!lastnode.IsBlockEndInstruction);

            lastnode.Next = Next;
            Next.Previous = lastnode;
            Next = firstnode;
            firstnode.Previous = this;

            Debug.Assert(this != Next);
            Debug.Assert(this != Previous);

            //Block.DebugCheck();
        }