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


C# Context.SetResult方法代码示例

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


在下文中一共展示了Context.SetResult方法的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 (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

示例2: ProcessInvokeInstruction

        /// <summary>
        /// Processes a method call instruction.
        /// </summary>
        /// <param name="context">The transformation context.</param>
        /// <param name="method">The method.</param>
        /// <param name="resultOperand">The result operand.</param>
        /// <param name="operands">The operands.</param>
        private void ProcessInvokeInstruction(Context context, MosaMethod method, Operand symbolOperand, Operand resultOperand, List<Operand> operands)
        {
            Debug.Assert(method != null);

            context.SetInstruction(IRInstruction.Call, (byte)(operands.Count + 1), (byte)(resultOperand == null ? 0 : 1));
            context.MosaMethod = method;

            if (resultOperand != null)
            {
                context.SetResult(resultOperand);
            }

            int index = 0;
            context.SetOperand(index++, symbolOperand);
            foreach (Operand op in operands)
            {
                context.SetOperand(index++, op);
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:26,代码来源:CILTransformationStage.cs

示例3: RenameVariables

        /// <summary>
        /// Renames the variables.
        /// </summary>
        /// <param name="block">The block.</param>
        /// <param name="dominanceCalculation">The dominance calculation.</param>
        /// <param name="variables">The variables.</param>
        private void RenameVariables(BasicBlock block, IDominanceProvider dominanceCalculation, Dictionary<Operand, Stack<int>> variables)
        {
            for (var context = new Context(instructionSet, block); !context.EndOfInstruction; context.GotoNext())
            {
                if (!(context.Instruction is Phi))
                {
                    for (var i = 0; i < context.OperandCount; ++i)
                    {
                        var op = context.GetOperand(i);

                        if (!(op is StackOperand))
                            continue;

                        if (!variables.ContainsKey(op))
                            throw new Exception(op.ToString() + " is not in dictionary [block = " + block + "]");

                        var index = variables[op].Peek();
                        context.SetOperand(i, CreateSsaOperand(context.GetOperand(i), index));
                    }
                }

                if (PhiPlacementStage.IsAssignmentToStackVariable(context))
                {
                    var op = context.Result;
                    var index = variables[op].Count;
                    context.SetResult(CreateSsaOperand(op, index));
                    variables[op].Push(index);
                }
            }

            foreach (var s in block.NextBlocks)
            {
                var j = WhichPredecessor(s, block);

                for (var context = new Context(instructionSet, s); !context.EndOfInstruction; context.GotoNext())
                {
                    if (!(context.Instruction is Phi))
                        continue;

                    var op = context.GetOperand(j);

                    if (variables[op].Count > 0)
                    {
                        var index = variables[op].Peek();
                        context.SetOperand(j, CreateSsaOperand(context.GetOperand(j), index));
                    }
                }
            }

            foreach (var s in dominanceCalculation.GetChildren(block))
            {
                RenameVariables(s, dominanceCalculation, variables);
            }
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:60,代码来源:EnterSSAStage.cs

示例4: AssignPhysicalRegistersToInstructions

        private void AssignPhysicalRegistersToInstructions(Context context, Operand old, Operand replacement)
        {
            for (int i = 0; i < context.OperandCount; i++)
            {
                var operand = context.GetOperand(i);

                if (operand.IsVirtualRegister)
                {
                    if (operand == old)
                    {
                        context.SetOperand(i, replacement);
                        continue;
                    }
                }
                else if (operand.IsMemoryAddress && operand.OffsetBase != null)
                {
                    if (operand.OffsetBase == old)
                    {
                        // FIXME: Creates a lot of duplicate single operands
                        context.SetOperand(i, Operand.CreateMemoryAddress(operand.Type, replacement, operand.Displacement));
                    }
                }
            }

            for (int i = 0; i < context.ResultCount; i++)
            {
                var operand = context.GetResult(i);

                if (operand.IsVirtualRegister)
                {
                    if (operand == old)
                    {
                        context.SetResult(i, replacement);
                        continue;
                    }
                }
                else if (operand.IsMemoryAddress && operand.OffsetBase != null)
                {
                    if (operand.OffsetBase == old)
                    {
                        // FIXME: Creates a lot of duplicate single operands
                        context.SetResult(i, Operand.CreateMemoryAddress(operand.Type, replacement, operand.Displacement));
                    }
                }
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:46,代码来源:GreedyRegisterAllocator.cs

示例5: RenameVariables

        /// <summary>
        /// Renames the variables.
        /// </summary>
        /// <param name="block">The block.</param>
        /// <param name="dominance">The dominance provider.</param>
        private void RenameVariables(BasicBlock block, IDominanceAnalysis dominance)
        {
            for (var context = new Context(InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
            {
                if (context.Instruction != IRInstruction.Phi)
                {
                    for (var i = 0; i < context.OperandCount; ++i)
                    {
                        var op = context.GetOperand(i);

                        if (op == null || !op.IsVirtualRegister)
                            continue;

                        Debug.Assert(variables.ContainsKey(op), op.ToString() + " is not in dictionary [block = " + block + "]");

                        var version = variables[op].Peek();
                        context.SetOperand(i, GetSSAOperand(op, version));
                    }
                }

                if (!context.IsEmpty && context.Result != null && context.Result.IsVirtualRegister)
                {
                    var op = context.Result;
                    var index = counts[op];
                    context.SetResult(GetSSAOperand(op, index));
                    variables[op].Push(index);
                    counts[op] = index + 1;
                }
            }

            foreach (var s in block.NextBlocks)
            {
                var index = WhichPredecessor(s, block); // okay since the block list order does not change between this stage and PhiPlacementStage

                for (var context = new Context(InstructionSet, s); !context.IsBlockEndInstruction; context.GotoNext())
                {
                    if (context.Instruction != IRInstruction.Phi)
                        continue;

                    Debug.Assert(context.OperandCount == context.BasicBlock.PreviousBlocks.Count);

                    var op = context.GetOperand(index);

                    if (variables[op].Count > 0)
                    {
                        var version = variables[op].Peek();
                        context.SetOperand(index, GetSSAOperand(context.GetOperand(index), version));
                    }
                }
            }

            foreach (var s in dominance.GetChildren(block))
            {
                RenameVariables(s, dominance);
            }

            for (var context = new Context(InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
            {
                if (!context.IsEmpty && context.Result != null && context.Result.IsVirtualRegister)
                {
                    var op = context.Result.SSAParent;
                    var index = variables[op].Pop();
                }
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:70,代码来源:EnterSSAStage.cs

示例6: ProcessInvokeInstruction

        /// <summary>
        /// Processes a method call instruction.
        /// </summary>
        /// <param name="context">The transformation context.</param>
        /// <param name="destinationOperand">The operand, which holds the call destination.</param>
        /// <param name="resultOperand"></param>
        /// <param name="operands"></param>
        private void ProcessInvokeInstruction(Context context, Operand destinationOperand, Operand resultOperand, List<Operand> operands)
        {
            context.SetInstruction(IRInstruction.Call, (byte)(operands.Count + 1), (byte)(resultOperand == null ? 0 : 1));

            if (resultOperand != null)
                context.SetResult(resultOperand);

            int operandIndex = 0;
            context.SetOperand(operandIndex++, destinationOperand);
            foreach (Operand op in operands)
            {
                context.SetOperand(operandIndex++, op);
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:21,代码来源:CILTransformationStage.cs

示例7: RenameVariables

        /// <summary>
        /// Renames the variables.
        /// </summary>
        /// <param name="block">The block.</param>
        private void RenameVariables(BasicBlock block)
        {
            for (var context = new Context(instructionSet, block); !context.EndOfInstruction; context.GotoNext())
            {
                if (!(context.Instruction is Phi))
                {
                    for (var i = 0; i < context.OperandCount; ++i)
                    {
                        var op = context.GetOperand(i);

                        if (op == null || !op.IsStackLocal)
                            continue;

                        Debug.Assert(variables.ContainsKey(op), op.ToString() + " is not in dictionary [block = " + block + "]");

                        var index = variables[op].Peek();
                        context.SetOperand(i, GetSSAOperand(op, index, 0));
                    }
                }

                if (!context.IsEmpty && context.Result != null && context.Result.IsStackLocal)
                {
                    var op = context.Result;
                    var index = counts[op];
                    context.SetResult(GetSSAOperand(op, index, op.Definitions.Count));
                    variables[op].Push(index);
                    counts[op] = index + 1;
                }
            }

            foreach (var s in block.NextBlocks)
            {
                var j = WhichPredecessor(s, block); // ???

                for (var context = new Context(instructionSet, s); !context.EndOfInstruction; context.GotoNext())
                {
                    if (!(context.Instruction is Phi))
                        continue;

                    var op = context.GetOperand(j);

                    if (variables[op].Count > 0)
                    {
                        var index = variables[op].Peek();
                        context.SetOperand(j, GetSSAOperand(context.GetOperand(j), index, 0));
                    }
                }
            }

            foreach (var s in dominanceCalculation.GetChildren(block))
            {
                RenameVariables(s);
            }

            for (var context = new Context(instructionSet, block); !context.EndOfInstruction; context.GotoNext())
            {
                if (!context.IsEmpty && context.Result != null && context.Result.IsStackLocal)
                {
                    var op = context.Result.SsaOperand;
                    var index = variables[op].Pop();
                }
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:67,代码来源:EnterSSAStage.cs


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