本文整理汇总了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;
}
}
示例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;
}
示例3: ToString_InstructionOfT_ReturnsCodeAndArgumentAsString
public void ToString_InstructionOfT_ReturnsCodeAndArgumentAsString()
{
var instruction = new Instruction<int>(OpCodes.Ldarg, 1, null);
Assert.AreEqual("ldarg 1", instruction.ToString());
}
示例4: ToString_Instruction_ReturnsCodeAsString
public void ToString_Instruction_ReturnsCodeAsString()
{
var instruction = new Instruction(OpCodes.Stloc, null);
Assert.AreEqual("stloc", instruction.ToString());
}
示例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;
}
示例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;
}
示例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]));
}
}
示例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);
}
示例9: ToString_Instruction_ReturnsCodeAsString
public void ToString_Instruction_ReturnsCodeAsString()
{
var instruction = new Instruction(OpCodes.Stloc, null);
Assert.Equal("stloc", instruction.ToString(),StringComparer.InvariantCultureIgnoreCase);
}
示例10: GetMnemonic
public static string GetMnemonic(Instruction instr)
{
// carefully done, this should actually work right
string str = instr.ToString();
return str.Replace('_', '.').ToLowerInvariant();
}