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


C# Operand.ToString方法代码示例

本文整理汇总了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());
                    }
                }
            }
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:52,代码来源:PromoteLocalVariablesStage.cs

示例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();
 }
开发者ID:Blecki,项目名称:EtcScript,代码行数:16,代码来源:Debug.cs

示例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++;
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:44,代码来源:SparseConditionalConstantPropagationStage.cs

示例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());
                    }
                }
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:42,代码来源:PromoteLocalVariablesStage.cs

示例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());
                    }
                }
            }
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:58,代码来源:IROptimizationStage.cs

示例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());
                    }
                }
            }
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:38,代码来源:IROptimizationStage.cs

示例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();
 }
开发者ID:Blecki,项目名称:EtcScript,代码行数:16,代码来源:VirtualMachine.cs


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