PERWAPI.CILInstructions.InsertInstructions C# (CSharp) Method

InsertInstructions() private method

private InsertInstructions ( int ix, CILInstruction newInsts, int numNew ) : void
ix int
newInsts CILInstruction
numNew int
return void
        private void InsertInstructions(int ix, CILInstruction[] newInsts, int numNew)
        {
            CILInstruction[] newBuff = buffer, oldBuff = buffer;
            int newSize = tide + numNew - numReplace;
            if (buffer.Length < newSize) {
                newBuff = new CILInstruction[newSize];
                for (int i=0; i < ix; i++) {
                    newBuff[i] = oldBuff[i];
                }
            }
            // shuffle up
            int offset = numNew-numReplace;
            int end = ix + numReplace;
            for (int i=tide-1; i >= end; i--) {
                newBuff[i+offset] = oldBuff[i];
            }
            // insert new instructions
            for (int i=0; i < numNew; i++) {
                newBuff[ix+i] = newInsts[i];
            }
            buffer = newBuff;
            tide += numNew - numReplace;
            UpdateIndexesFrom(ix);
        }