當前位置: 首頁>>代碼示例>>C#>>正文


C# Machine.Execute方法代碼示例

本文整理匯總了C#中System.Machine.Execute方法的典型用法代碼示例。如果您正苦於以下問題:C# Machine.Execute方法的具體用法?C# Machine.Execute怎麽用?C# Machine.Execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Machine的用法示例。


在下文中一共展示了Machine.Execute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PushByteTwice

        public void PushByteTwice()
        {
            Machine machine = new Machine();

            machine.Execute(new byte[] { (byte)Bytecodes.Push1, 0x01, (byte)Bytecodes.Push1, 0x02 });

            Assert.AreEqual(machine.Stack.Pop(), Integer256.Two);
            Assert.AreEqual(machine.Stack.Pop(), Integer256.One);
            Assert.AreEqual(0, machine.Stack.Size);
        }
開發者ID:ajlopez,項目名稱:EthSharpVm,代碼行數:10,代碼來源:MachineTests.cs

示例2: PushThreeBytesTwice

        public void PushThreeBytesTwice()
        {
            Machine machine = new Machine();

            machine.Execute(new byte[] { (byte)Bytecodes.Push3, 0x01, 0x02, 0x03, (byte)Bytecodes.Push3, 0x04, 0x05, 0x06 });

            Assert.AreEqual(machine.Stack.Pop(), new Integer256((256 * 256 * 4) + (256 * 5) + 6));
            Assert.AreEqual(machine.Stack.Pop(), new Integer256((256 * 256 * 1) + (256 * 2) + 3));
            Assert.AreEqual(0, machine.Stack.Size);
        }
開發者ID:ajlopez,項目名稱:EthSharpVm,代碼行數:10,代碼來源:MachineTests.cs

示例3: PushDupPop

        private static void PushDupPop(uint times)
        {
            IList<Byte> bytes = new List<byte>();

            for (int k = 0; k < times; k++)
            {
                bytes.Add((byte)Bytecodes.Push1);
                bytes.Add((byte)k);
            }

            bytes.Add((byte)(Bytecodes.Dup1 + (int)times - 1));

            Machine machine = new Machine();

            machine.Execute(bytes.ToArray());

            Integer256 value = new Integer256(times);

            Assert.AreEqual(Integer256.Zero, machine.Stack.Pop());

            for (int k = 0; k < times; k++)
            {
                value = value.Subtract(Integer256.One);
                Assert.AreEqual(value, machine.Stack.Pop());
            }

            Assert.AreEqual(0, machine.Stack.Size);
        }
開發者ID:ajlopez,項目名稱:EthSharpVm,代碼行數:28,代碼來源:MachineTests.cs

示例4: PushTwoBytesTwice

        public void PushTwoBytesTwice()
        {
            Machine machine = new Machine();

            machine.Execute(new byte[] { (byte)Bytecodes.Push2, 0x01, 0x02, (byte)Bytecodes.Push2, 0x03, 0x04 });

            Assert.AreEqual(machine.Stack.Pop(), new Integer256((256 * 3) + 4));
            Assert.AreEqual(machine.Stack.Pop(), new Integer256(256 + 2));
        }
開發者ID:ajlopez,項目名稱:EthSharpVm,代碼行數:9,代碼來源:MachineTests.cs

示例5: PushPop

        private static void PushPop(byte[] bytes)
        {
            IList<Byte> bs = new List<byte>();

            bs.Add((byte)(Bytecodes.Push1 + bytes.Length - 1));

            foreach (byte b in bytes)
                bs.Add(b);

            Machine machine = new Machine();

            machine.Execute(bs.ToArray());

            Assert.AreEqual(1, machine.Stack.Size);
            Assert.AreEqual(Integer256.FromBytes(bytes), machine.Stack.Pop());
        }
開發者ID:ajlopez,項目名稱:EthSharpVm,代碼行數:16,代碼來源:MachineTests.cs


注:本文中的System.Machine.Execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。