本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}