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

CompileJumpByteCode() public method

public CompileJumpByteCode ( ByteCode b, short jump ) : void
b ByteCode
jump short
return void
        public void CompileJumpByteCode(ByteCode b, short jump)
        {
            this.CompileByte((byte)b);
            this.CompileByte((byte)(jump >> 8));
            this.CompileByte((byte)(jump & 0xff));
        }

Usage Example

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

            block.CompileJumpByteCode(ByteCode.Jump, 10);
            block.CompileJumpByteCode(ByteCode.JumpIfFalse, 256);
            block.CompileJumpByteCode(ByteCode.JumpIfTrue, 1024);

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