当前位置: 首页>>代码示例>>C#>>正文


C# Instruction.ToString方法代码示例

本文整理汇总了C#中Instruction.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Instruction.ToString方法的具体用法?C# Instruction.ToString怎么用?C# Instruction.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Instruction的用法示例。


在下文中一共展示了Instruction.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public void Execute(Machine machine, Stack<object> stack, Scope scope, Instruction instr)
        {
            int length;
            string name;

            switch (instr)
            {
                default:
                    throw new VMException("Something just went horribly wrong. Variable instructlet is not supposed to receive {0}", instr.ToString());

                case Instruction.SetVar:
                    length = (int)machine.TakeByte();
                    name = machine.TakeBytes(length).AsString();

                    machine.ExecuteNextInstructlet();
                    scope.SetVariable(name, stack.Pop());
                    break;

                case Instruction.GetVar:
                    length = (int)machine.TakeByte();
                    name = machine.TakeBytes((int)length).AsString();

                    stack.Push(scope.GetVariable(name));
                    break;
            }
        }
开发者ID:Spanfile,项目名称:Englang,代码行数:26,代码来源:VariableInstructlet.cs

示例2: GenerateDisassembly

        private List<DisassemblyLine> GenerateDisassembly(short address, short length)
        {
            var res = new List<DisassemblyLine>();
            var instruction = new Instruction(vm);
            var originalIP = vm.IP;
            var previousIP = vm.IP;
            var failed = false;

            vm.IP = address;

            for (var i = 0; i < length; i++)
            {
                if (!failed)
                {
                    try
                    {
                        instruction.Decode();
                        res.Add(new DisassemblyLine(previousIP, instruction.ToString()));
                    }
                    catch
                    {
                        vm.IP = previousIP;
                        failed = true;
                    }
                }

                if (failed && (vm.IP > 0 || vm.IP < 32000))
                {
                    res.Add(new DisassemblyLine(previousIP, vm.Memory[vm.IP++].ToString("X")));
                }

                previousIP = vm.IP;
            }

            vm.IP = originalIP;
            return res;
        }
开发者ID:Rohansi,项目名称:VM,代码行数:37,代码来源:Debugger.cs

示例3: ToString_InstructionOfT_ReturnsCodeAndArgumentAsString

        public void ToString_InstructionOfT_ReturnsCodeAndArgumentAsString()
        {
            var instruction = new Instruction<int>(OpCodes.Ldarg, 1, null);

            Assert.AreEqual("ldarg 1", instruction.ToString());
        }
开发者ID:vitamink,项目名称:LightInject,代码行数:6,代码来源:EmitterTests.cs

示例4: ToString_Instruction_ReturnsCodeAsString

 public void ToString_Instruction_ReturnsCodeAsString()
 {
     var instruction = new Instruction(OpCodes.Stloc, null);
     
     Assert.AreEqual("stloc", instruction.ToString());
 }
开发者ID:vitamink,项目名称:LightInject,代码行数:6,代码来源:EmitterTests.cs

示例5: IsPlacedOnTable

 /// <summary>
 /// Checks if the Robot is placed on table
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="action"></param>
 /// <returns>bool</returns>
 public static bool IsPlacedOnTable(int? x, int? y, Instruction action)
 {
     if (!x.HasValue || !y.HasValue)
     {
         string instructionaction = action.ToString();
         if (action == Instruction.Left || action == Instruction.Right)
         _error = String.Format("Robot can not rotate {0}!! Robot is not placed on the table.", instructionaction);
         if (action == Instruction.Report)
             _error = "Can not generate the report!! Robot is not placed on the table.";
         if (action == Instruction.Move)
             _error = "Robot can not move!! Robot is not placed on the table.";
         return false;
     }
     return true;
 }
开发者ID:navingautam,项目名称:RobotSimulator,代码行数:22,代码来源:RobotStatus.cs

示例6: IsOnTable

 /// <summary>
 /// Checks if the Robot position is inside the table
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="action"></param>
 /// <returns>bool</returns>
 public static bool IsOnTable(int x, int y, Instruction action)
 {
     if (x < 0 || y < 0 || x > TABLESIZE || y > TABLESIZE)
     {
         _error = String.Format("Can not {0} the Robot out of the table boundary.", action.ToString());
         return false;
     }
     return true;
 }
开发者ID:navingautam,项目名称:RobotSimulator,代码行数:16,代码来源:RobotStatus.cs

示例7: TraceInstruction

 void TraceInstruction(Instruction instruction)
 {
     Console.WriteLine ("*****");
     Console.WriteLine (instruction.ToString ());
     StringBuilder sb = new StringBuilder ();
     this.PrintLineFor (sb, this.programCounter, instruction.StartPos, instruction.EndPos);
     Console.WriteLine (sb.ToString ());
     Console.WriteLine ("Stack before:");
     for (var i = 0; i < this.stack.Count; i++) {
         Console.WriteLine (DumpShovelValue (this.api, this.stack.Storage [i]));
     }
 }
开发者ID:mbrezu,项目名称:Shovel,代码行数:12,代码来源:Vm.cs

示例8: ToString_InstructionOfT_ReturnsCodeAndArgumentAsString

        public void ToString_InstructionOfT_ReturnsCodeAndArgumentAsString()
        {
            var instruction = new Instruction<int>(OpCodes.Ldarg, 1, null);

            Assert.Equal("ldarg 1", instruction.ToString(), StringComparer.InvariantCultureIgnoreCase);
        }
开发者ID:vitamink,项目名称:LightInject,代码行数:6,代码来源:EmitterTests.cs

示例9: ToString_Instruction_ReturnsCodeAsString

 public void ToString_Instruction_ReturnsCodeAsString()
 {
     var instruction = new Instruction(OpCodes.Stloc, null);
     
     Assert.Equal("stloc", instruction.ToString(),StringComparer.InvariantCultureIgnoreCase);
 }
开发者ID:vitamink,项目名称:LightInject,代码行数:6,代码来源:EmitterTests.cs

示例10: GetMnemonic

 public static string GetMnemonic(Instruction instr)
 {
     // carefully done, this should actually work right
     string str = instr.ToString();
     return str.Replace('_', '.').ToLowerInvariant();
 }
开发者ID:DexterHaslem,项目名称:doyleil,代码行数:6,代码来源:Instructions.cs


注:本文中的Instruction.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。