CompileByteCode() public method

public CompileByteCode ( ByteCode b ) : void
b ByteCode
return void
Beispiel #1
0
        public void CompileAndExecuteGetDotNetType()
        {
            Block block;

            block = new Block();
            block.CompileGetDotNetType("System.IO.FileInfo");
            block.CompileByteCode(ByteCode.ReturnPop);

            object obj = block.Execute(null, null);

            Assert.IsNotNull(obj);
            Assert.IsInstanceOfType(obj, typeof(System.Type));
        }
Beispiel #2
0
        public void CompileAndExecuteNewDotNetObject()
        {
            Block block;

            block = new Block();
            block.CompileGetDotNetType("System.IO.FileInfo");
            block.CompileGetConstant("FooBar.txt");
            block.CompileSend("!new:");
            block.CompileByteCode(ByteCode.ReturnPop);

            object obj = block.Execute(null, null);

            Assert.IsNotNull(obj);
            Assert.IsInstanceOfType(obj, typeof(System.IO.FileInfo));
        }
Beispiel #3
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]);
        }
Beispiel #4
0
        public void CompileInsertAndCompileByte()
        {
            Block block = new Block();

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

            Assert.AreEqual(6, block.Bytecodes.Length);
            Assert.AreEqual(1, block.Bytecodes[0]);
            Assert.AreEqual(0, block.Bytecodes[1]);
            Assert.AreEqual(0, block.Bytecodes[2]);
            Assert.AreEqual(0, block.Bytecodes[3]);
            Assert.AreEqual(2, block.Bytecodes[4]);
            Assert.AreEqual(3, block.Bytecodes[5]);
        }
Beispiel #5
0
        public void DecompileValue()
        {
            Block block = new Block();
            block.CompileByteCode(ByteCode.Value);
            BlockDecompiler decompiler = new BlockDecompiler(block);

            var result = decompiler.Decompile();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("Value", result[0]);
        }
Beispiel #6
0
        public void DecompilePrimitive()
        {
            Block block = new Block();
            block.CompileByteCode(ByteCode.Primitive, 10);
            BlockDecompiler decompiler = new BlockDecompiler(block);

            var result = decompiler.Decompile();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("Primitive 10", result[0]);
        }
Beispiel #7
0
        public void DecompileNamedPrimitive()
        {
            Block block = new Block();
            block.CompileByteCode(ByteCode.NamedPrimitive, block.CompileConstant("do"), block.CompileConstant("mod"));
            BlockDecompiler decompiler = new BlockDecompiler(block);

            var result = decompiler.Decompile();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("NamedPrimitive \"do\" \"mod\"", result[0]);
        }