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


C# Context.GotoNext方法代码示例

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


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

示例1: Run

        protected override void Run()
        {
            Dictionary<Operand, int> list = new Dictionary<Operand, int>();

            foreach (var block in this.BasicBlocks)
            {
                for (var context = new Context(this.InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
                {
                    context.Marked = false;

                    if (context.Result == null)
                        continue;

                    int index = 0;

                    if (list.TryGetValue(context.Result, out index))
                    {
                        InstructionSet.Data[index].Marked = true;
                        context.Marked = true;
                    }
                    else
                    {
                        list.Add(context.Result, context.Index);
                    }
                }
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:27,代码来源:MultipleDefinitionMarkerStage.cs

示例2: foreach

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        void IMethodCompilerStage.Run()
        {
            // Unable to optimize SSA w/ exceptions or finally handlers present
            if (basicBlocks.HeadBlocks.Count != 1)
                return;

            // initialize worklist
            foreach (BasicBlock block in basicBlocks)
            {
                for (Context ctx = new Context(instructionSet, block); !ctx.EndOfInstruction; ctx.GotoNext())
                {
                    if (ctx.IsEmpty)
                        continue;

                    if (ctx.ResultCount == 0 && ctx.OperandCount == 0)
                        continue;

                    Do(ctx);

                    while (worklist.Count != 0)
                    {
                        int index = worklist.Pop();
                        Context ctx2 = new Context(instructionSet, index);
                        Do(ctx2);
                    }
                }
            }

            UpdateCounter("SSAOptimizations.IRInstructionRemoved", instructionsRemoved);
            worklist = null;
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:34,代码来源:SSAOptimizations.cs

示例3: Run

        protected override void Run()
        {
            // Remove Nops
            foreach (var block in BasicBlocks)
            {
                for (var ctx = new Context(InstructionSet, block); !ctx.IsBlockEndInstruction; ctx.GotoNext())
                {
                    if (ctx.IsEmpty)
                        continue;

                    if (ctx.Instruction == IRInstruction.Nop)
                    {
                        ctx.Remove();
                        continue;
                    }
                }
            }

            // copied from EmptyBlockRemovalStage.cs
            foreach (var block in BasicBlocks)
            {
                // don't process other unusual blocks (header blocks, return block, etc.)
                if (block.NextBlocks.Count == 0 || block.PreviousBlocks.Count == 0)
                    continue;

                // don't remove block if it jumps back to itself
                if (block.PreviousBlocks.Contains(block))
                    continue;

                if (!IsEmptyBlockWithSingleJump(block))
                    continue;

                RemoveEmptyBlockWithSingleJump(block);
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:35,代码来源:IRCleanup.cs

示例4: InsertBlockProtectInstructions

        private void InsertBlockProtectInstructions()
        {
            foreach (var handler in MethodCompiler.Method.ExceptionHandlers)
            {
                var tryBlock = BasicBlocks.GetByLabel(handler.TryStart);

                var tryHandler = BasicBlocks.GetByLabel(handler.HandlerStart);

                var context = new Context(tryBlock);

                while (context.IsEmpty || context.Instruction == IRInstruction.TryStart)
                {
                    context.GotoNext();
                }

                context.AppendInstruction(IRInstruction.TryStart, tryHandler);

                context = new Context(tryHandler);

                if (handler.ExceptionHandlerType == ExceptionHandlerType.Finally)
                {
                    var exceptionObject = AllocateVirtualRegister(exceptionType);
                    var finallyOperand = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);

                    context.AppendInstruction2(IRInstruction.FinallyStart, exceptionObject, finallyOperand);
                }
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:28,代码来源:CILProtectedRegionStage.cs

示例5: Run

        protected override void Run()
        {
            finalVirtualRegisters = new Dictionary<Operand, Operand>();

            foreach (var block in BasicBlocks)
            {
                for (var context = new Context(InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
                {
                    if (context.Instruction == IRInstruction.Phi)
                    {
                        Debug.Assert(context.OperandCount == context.BasicBlock.PreviousBlocks.Count);

                        ProcessPhiInstruction(context);
                    }

                    for (var i = 0; i < context.OperandCount; ++i)
                    {
                        var op = context.GetOperand(i);

                        if (op != null && op.IsSSA)
                        {
                            context.SetOperand(i, GetFinalVirtualRegister(op));
                        }
                    }

                    if (context.Result != null && context.Result.IsSSA)
                    {
                        context.Result = GetFinalVirtualRegister(context.Result);
                    }
                }
            }

            finalVirtualRegisters = null;
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:34,代码来源:LeaveSSAStage.cs

示例6: foreach

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        void IMethodCompilerStage.Run()
        {
            Dictionary<Operand, int> list = new Dictionary<Operand, int>();

            foreach (var block in this.basicBlocks)
            {
                for (var context = new Context(this.instructionSet, block); !context.EndOfInstruction; context.GotoNext())
                {
                    context.Marked = false;

                    if (context.Result == null)
                        continue;

                    int index = 0;

                    if (list.TryGetValue(context.Result, out index))
                    {
                        instructionSet.Data[index].Marked = true;
                        context.Marked = true;
                    }
                    else
                    {
                        list.Add(context.Result, context.Index);
                    }
                }
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:30,代码来源:MultipleDefinitionMarkerStage.cs

示例7: CollectVariablesInExceptions

        /// <summary>
        /// Collects the variables in exceptions.
        /// </summary>
        private void CollectVariablesInExceptions()
        {
            if (basicBlocks.HeadBlocks.Count == 1)
                return;

            foreach (var head in basicBlocks.HeadBlocks)
            {
                if (head == basicBlocks.PrologueBlock)
                    continue;

                foreach (BasicBlock block in basicBlocks.GetConnectedBlocksStartingAtHead(head))
                {
                    for (Context ctx = new Context(instructionSet, block); !ctx.EndOfInstruction; ctx.GotoNext())
                    {
                        if (ctx.IsEmpty)
                            continue;

                        foreach (var operand in ctx.Operands)
                            if (operand.IsLocalVariable)
                                localVariablesInExceptions.AddIfNew(operand);

                        if (ctx.Result != null)
                            if (ctx.Result.IsLocalVariable)
                                localVariablesInExceptions.AddIfNew(ctx.Result);
                    }

                    // quick out
                    if (localVariablesInExceptions.Count == methodCompiler.StackLayout.LocalVariableCount)
                        return;
                }
            }
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:35,代码来源:LocalVariablePromotionStage.cs

示例8: InsertBlockProtectInstructions

        private void InsertBlockProtectInstructions()
        {
            foreach (var handler in MethodCompiler.Method.ExceptionHandlers)
            {
                var tryBlock = BasicBlocks.GetByLabel(handler.TryStart);

                var tryHandler = BasicBlocks.GetByLabel(handler.HandlerStart);

                var context = new Context(InstructionSet, tryBlock);

                while (context.IsEmpty || context.Instruction == IRInstruction.TryStart)
                {
                    context.GotoNext();
                }

                context.AppendInstruction(IRInstruction.TryStart, tryHandler);

                context = new Context(InstructionSet, tryHandler);

                if (handler.HandlerType == ExceptionHandlerType.Exception)
                {
                    var exceptionObject = MethodCompiler.CreateVirtualRegister(handler.Type);

                    context.AppendInstruction(IRInstruction.ExceptionStart, exceptionObject);
                }
                else if (handler.HandlerType == ExceptionHandlerType.Finally)
                {
                    context.AppendInstruction(IRInstruction.FinallyStart);
                }
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:31,代码来源:ProtectedRegionStage.cs

示例9: Run

 protected override void Run()
 {
     for (int index = 0; index < BasicBlocks.Count; index++)
         for (Context ctx = new Context(InstructionSet, BasicBlocks[index]); !ctx.IsBlockEndInstruction; ctx.GotoNext())
             if (!ctx.IsEmpty)
                 ctx.Clone().Visit(this);
 }
开发者ID:tea,项目名称:MOSA-Project,代码行数:7,代码来源:BaseCodeTransformationStage.cs

示例10: foreach

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        void IMethodCompilerStage.Run()
        {
            foreach (var block in this.basicBlocks)
            {
                for (var ctx = new Context(instructionSet, block); !ctx.EndOfInstruction; ctx.GotoNext())
                {
                    if (ctx.IsEmpty)
                        continue;

                    RegisterBitmap inputRegisters = new RegisterBitmap();
                    RegisterBitmap outputRegisters = new RegisterBitmap();

                    GetRegisterUsage(ctx, ref inputRegisters, ref outputRegisters);

                    Debug.WriteLine(String.Format("L_{0:X4}: {1}", ctx.Label, ctx.Instruction.ToString(ctx)));

                    if (outputRegisters.HasValue)
                    {
                        Debug.Write("\t OUTPUT: ");
                        Debug.Write(GetRegisterNames(outputRegisters));
                    }

                    if (inputRegisters.HasValue)
                    {
                        Debug.Write("\t INPUT: ");
                        Debug.Write(GetRegisterNames(inputRegisters));
                    }

                    if (inputRegisters.HasValue | outputRegisters.HasValue)
                    {
                        Debug.WriteLine("");
                    }
                }
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:38,代码来源:OperandUsageAnalyzerStage.cs

示例11: foreach

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        void IMethodCompilerStage.Run()
        {
            foreach (var block in basicBlocks)
            {
                if (block.Label == BasicBlock.EpilogueLabel)
                    continue;

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

                    for (var i = 0; i < context.OperandCount; ++i)
                    {
                        var op = context.GetOperand(i);
                        if (op is SsaOperand)
                            context.SetOperand(i, (op as SsaOperand).Operand);
                    }

                    if (context.Result != null)
                    {
                        if (context.Result is SsaOperand)
                            context.Result = (context.Result as SsaOperand).Operand;
                    }
                }
            }
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:30,代码来源:LeaveSSAStage.cs

示例12: Run

 /// <summary>
 /// Performs stage specific processing on the compiler context.
 /// </summary>
 public virtual void Run()
 {
     for (int index = 0; index < basicBlocks.Count; index++)
         for (Context ctx = new Context(instructionSet, basicBlocks[index]); !ctx.EndOfInstruction; ctx.GotoNext())
             if (!ctx.IsEmpty)
                 ctx.Clone().Visit(this);
 }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:10,代码来源:BaseCodeTransformationStage.cs

示例13: BitArray

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        void IMethodCompilerStage.Run()
        {
            //Trace("METHOD: " + this.methodCompiler.FullName);

            // Initialize arrays
            top = new RegisterBitmap[basicBlocks.Count];
            bottom = new RegisterBitmap[basicBlocks.Count];
            analyzed = new BitArray(basicBlocks.Count);
            traversed = new BitArray(basicBlocks.Count);
            usage = new RegisterBitmap[instructionSet.Size];

            foreach (var block in basicBlocks)
            {
                AnalyzeBlock(block);
            }

            Trace("METHOD: " + this.methodCompiler.Method.FullName);
            Trace(string.Empty);

            var registers = new Dictionary<int, Register>();
            foreach (var register in architecture.RegisterSet)
                registers.Add(register.Index, register);

            StringBuilder line = new StringBuilder();
            for (int l = 0; l < 3; l++)
            {
                line.Append("[");
                for (int r = 15; r >= 0; r--)
                {
                    line.Append(registers[r].ToString()[l]);
                }

                line.Append("]");
            }
            Trace(line.ToString());

            foreach (var block in this.basicBlocks)
            {
                Trace(String.Format("Block #{0} - Label L_{1:X4}", block.Index, block.Label));

                Trace("[" + top[block.Sequence].ToString().Substring(64 - 16, 16) + "] Top");

                for (var ctx = new Context(instructionSet, block); !ctx.EndOfInstruction; ctx.GotoNext())
                {
                    if (ctx.IsEmpty)
                        continue;

                    Trace("[" + usage[ctx.Index].ToString().Substring(64 - 16, 16) + "] " + String.Format("L_{0:X4}: {1}", ctx.Label, ctx.Instruction.ToString(ctx)));
                }

                Trace("[" + bottom[block.Sequence].ToString().Substring(64 - 16, 16) + "] Bottom");
                Trace(string.Empty);
            }

            return;
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:59,代码来源:RegisterUsageAnalyzerStage.cs

示例14: GetFirstContext

 private Context GetFirstContext(BasicBlock block)
 {
     for (Context context = new Context(InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
     {
         if (context.IsBlockStartInstruction)
             continue;
         return context;
     }
     return null;
 }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:10,代码来源:UnboxValueTypeStage.cs

示例15: Run

        protected override void Run()
        {
            for (int index = 0; index < BasicBlocks.Count; index++)
                for (Context ctx = new Context(InstructionSet, BasicBlocks[index]); !ctx.IsBlockEndInstruction; ctx.GotoNext())
                    if (!ctx.IsEmpty)
                        ProcessInstruction(ctx.Clone());

            for (int index = 0; index < BasicBlocks.Count; index++)
                for (Context ctx = new Context(InstructionSet, BasicBlocks[index]); !ctx.IsBlockEndInstruction; ctx.GotoNext())
                    if (!ctx.IsEmpty)
                        ReplaceOperands(ctx.Clone());

            repl.Clear();
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:14,代码来源:ConvertCompoundMoveStage.cs


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