AjTalk.Language.Method.CompileGet C# (CSharp) Метод

CompileGet() публичный Метод

public CompileGet ( string name ) : void
name string
Результат void
        public override void CompileGet(string name)
        {
            if (this.TryCompileGet(name))
            {
                return;
            }

            this.CompileByteCode(ByteCode.GetGlobalVariable, this.CompileGlobal(name));
        }

Usage Example

Пример #1
0
        public void Compile()
        {
            Machine machine = new Machine();
            IClass cls = machine.CreateClass("TestClass");
            cls.DefineInstanceVariable("x");
            cls.DefineClassVariable("count");

            Block block;

            block = new Method(cls, "x:");
            block.CompileArgument("newX");
            block.CompileGet("newX");
            block.CompileGet("count");
            block.CompileSet("x");

            Assert.AreEqual(1, block.Arity);
            Assert.AreEqual(0, block.NoLocals);
            Assert.IsNotNull(block.ByteCodes);
            Assert.IsTrue(block.ByteCodes.Length > 0);

            BlockDecompiler decompiler = new BlockDecompiler(block);
            var result = decompiler.Decompile();

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count);

            Assert.AreEqual("GetArgument newX", result[0]);
            Assert.AreEqual("GetClassVariable count", result[1]);
            Assert.AreEqual("SetInstanceVariable x", result[2]);
        }
All Usage Examples Of AjTalk.Language.Method::CompileGet