本文整理汇总了C#中Operand.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Operand.ToString方法的具体用法?C# Operand.ToString怎么用?C# Operand.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operand
的用法示例。
在下文中一共展示了Operand.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Promote
protected void Promote(Operand local)
{
var stacktype = local.Type.GetStackType();
var v = MethodCompiler.CreateVirtualRegister(stacktype);
if (trace.Active) trace.Log("*** Replacing: " + local.ToString() + " with " + v.ToString());
foreach (var node in local.Uses.ToArray())
{
for (int i = 0; i < node.OperandCount; i++)
{
var operand = node.GetOperand(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetOperand(i, v);
if (node.Instruction == IRInstruction.ZeroExtendedMove)
{
node.Instruction = IRInstruction.Move;
node.Size = InstructionSize.None;
}
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
}
}
}
foreach (var node in local.Definitions.ToArray())
{
for (int i = 0; i < node.OperandCount; i++)
{
var operand = node.GetResult(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetResult(i, v);
if (node.Instruction == IRInstruction.ZeroExtendedMove)
{
node.Instruction = IRInstruction.Move;
node.Size = InstructionSize.None;
}
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
}
}
}
}
示例2: GetOperandString
private static string GetOperandString(Operand operand, ListIterator<object> iterator)
{
if (operand == Operand.NEXT)
{
iterator.Advance();
return iterator.Next().ToString();
}
else if (operand == Operand.STRING)
{
iterator.Advance();
return "STRING[" + iterator.Next().ToString() + "]";
}
else if (operand == Operand.NONE)
return "";
return operand.ToString();
}
示例3: ReplaceVirtualRegisterWithConstant
protected void ReplaceVirtualRegisterWithConstant(Operand target, ulong value)
{
if (trace.Active) trace.Log(target.ToString() + " = " + value.ToString() + " Uses: " + target.Uses.Count.ToString());
Debug.Assert(target.Definitions.Count == 1);
if (target.Uses.Count != 0)
{
var constant = Operand.CreateConstant(target.Type, value);
// for each statement T that uses operand, substituted c in statement T
foreach (var node in target.Uses.ToArray())
{
Debug.Assert(node.Instruction != IRInstruction.AddressOf);
for (int i = 0; i < node.OperandCount; i++)
{
var operand = node.GetOperand(i);
if (operand != target)
continue;
if (trace.Active) trace.Log("*** ConditionalConstantPropagation");
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetOperand(i, constant);
conditionalConstantPropagation++;
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
changed = true;
}
}
}
Debug.Assert(target.Uses.Count == 0);
if (target.Definitions.Count == 0)
return;
var defNode = target.Definitions[0];
if (trace.Active) trace.Log("REMOVED:\t" + defNode.ToString());
defNode.SetInstruction(IRInstruction.Nop);
instructionsRemovedCount++;
}
示例4: Promote
protected void Promote(Operand local)
{
var stacktype = local.Type.GetStackType();
var v = MethodCompiler.CreateVirtualRegister(stacktype);
if (trace.Active) trace.Log("*** Replacing: " + local.ToString() + " with " + v.ToString());
foreach (int index in local.Uses.ToArray())
{
Context ctx = new Context(InstructionSet, index);
for (int i = 0; i < ctx.OperandCount; i++)
{
Operand operand = ctx.GetOperand(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + ctx.ToString());
ctx.SetOperand(i, v);
if (trace.Active) trace.Log("AFTER: \t" + ctx.ToString());
}
}
}
foreach (int index in local.Definitions.ToArray())
{
Context ctx = new Context(InstructionSet, index);
for (int i = 0; i < ctx.OperandCount; i++)
{
Operand operand = ctx.GetResult(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + ctx.ToString());
ctx.SetResult(i, v);
if (trace.Active) trace.Log("AFTER: \t" + ctx.ToString());
}
}
}
}
示例5: ReplaceVirtualRegister
private void ReplaceVirtualRegister(Operand local, Operand replacement, bool updateMove)
{
if (trace.Active) trace.Log("Replacing: " + local.ToString() + " with " + replacement.ToString());
foreach (var node in local.Uses.ToArray())
{
AddOperandUsageToWorkList(node);
for (int i = 0; i < node.OperandCount; i++)
{
var operand = node.GetOperand(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetOperand(i, replacement);
if (updateMove)
{
if (node.Instruction == IRInstruction.ZeroExtendedMove)
{
node.Instruction = IRInstruction.Move;
node.Size = InstructionSize.None;
}
}
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
}
}
}
foreach (var node in local.Definitions.ToArray())
{
AddOperandUsageToWorkList(node);
for (int i = 0; i < node.ResultCount; i++)
{
var operand = node.GetResult(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetResult(i, replacement);
if (updateMove)
{
if (node.Instruction == IRInstruction.ZeroExtendedMove)
{
node.Instruction = IRInstruction.Move;
node.Size = InstructionSize.None;
}
}
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
}
}
}
}
示例6: ReplaceVirtualRegister
private void ReplaceVirtualRegister(Operand local, Operand replacement)
{
if (trace.Active) trace.Log("Replacing: " + local.ToString() + " with " + replacement.ToString());
foreach (var node in local.Uses.ToArray())
{
AddOperandUsageToWorkList(node);
for (int i = 0; i < node.OperandCount; i++)
{
var operand = node.GetOperand(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetOperand(i, replacement);
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
}
}
}
foreach (var node in local.Definitions.ToArray())
{
AddOperandUsageToWorkList(node);
for (int i = 0; i < node.ResultCount; i++)
{
var operand = node.GetResult(i);
if (local == operand)
{
if (trace.Active) trace.Log("BEFORE:\t" + node.ToString());
node.SetResult(i, replacement);
if (trace.Active) trace.Log("AFTER: \t" + node.ToString());
}
}
}
}
示例7: TraceOperand
private static String TraceOperand(ExecutionContext Context, Operand Operand, out int NewIP, int IP)
{
NewIP = IP;
if (Operand == EtcScriptLib.VirtualMachine.Operand.NEXT)
{
NewIP = IP + 1;
return Context.CurrentInstruction.Code[NewIP] == null ? "null" : Context.CurrentInstruction.Code[NewIP].ToString();
}
else if (Operand == EtcScriptLib.VirtualMachine.Operand.STRING)
{
NewIP = IP + 1;
return "STRING[" + Context.CurrentInstruction.Code[NewIP].ToString() + "]";
}
else
return Operand.ToString();
}