AjTalk.Language.Block.CompileInsert C# (CSharp) Method

CompileInsert() public method

public CompileInsert ( int position, int count ) : void
position int
count int
return void
        public void CompileInsert(int position, int count)
        {
            byte[] aux = new byte[this.bytecodes.Length + count];
            Array.Copy(this.bytecodes, aux, position);
            Array.Copy(this.bytecodes, position, aux, position + count, this.bytecodes.Length - position);
            this.bytecodes = aux;
            this.nextbytecode += (short)count;
        }

Usage Example

Example #1
0
        public void CompileJumpAt()
        {
            Block block = new Block();

            block.CompileByteCode((ByteCode)1);
            block.CompileByteCode((ByteCode)2);
            block.CompileByteCode((ByteCode)3);

            block.CompileInsert(1, 3);
            block.CompileJumpByteCodeAt(ByteCode.Jump, 10, 1);

            Assert.AreEqual(6, block.Bytecodes.Length);
            Assert.AreEqual(1, block.Bytecodes[0]);
            Assert.AreEqual((byte)ByteCode.Jump, block.Bytecodes[1]);
            Assert.AreEqual(0, block.Bytecodes[2]);
            Assert.AreEqual(10, block.Bytecodes[3]);
            Assert.AreEqual(2, block.Bytecodes[4]);
            Assert.AreEqual(3, block.Bytecodes[5]);
        }
All Usage Examples Of AjTalk.Language.Block::CompileInsert