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


C# Context.Remove方法代码示例

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


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

示例1: 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

示例2: Run

        // TODO:
        // 1. If first branch is to the next basic block,
        //       then swap branch condition, replace branch target with jump target, and remove jump instruction.
        //           part of code: ConditionCode = GetOppositeConditionCode(ConditionCode);
        // 2. If the basic block contains only a single jump instruction, rewrite all jumps to avoid it.
        protected override void Run()
        {
            var trace = CreateTrace();

            for (int f = 0; f < BasicBlocks.Count - 1; f++)
            {
                var from = BasicBlocks[f];
                var next = BasicBlocks[f + 1];

                Context context = new Context(InstructionSet, from, from.EndIndex);
                context.GotoPrevious();

                while (context.IsEmpty)
                {
                    context.GotoPrevious();
                }

                if (context.Instruction.FlowControl != FlowControl.UnconditionalBranch)
                    continue;

                Debug.Assert(context.Instruction.FlowControl == FlowControl.UnconditionalBranch);
                //Debug.Assert(context.BranchTargets.Length == 1);

                var target = context.BranchTargets[0];

                if (next.Label != target)
                    continue;

                context.Remove();
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:36,代码来源:JumpPeepholeOptimizationStage.cs

示例3: MyTestInitialize

        public void MyTestInitialize()
        {
            m_Case = new BestServerCase();
            m_Context = new Context();
            TrueFalseMatrix matrix = new TrueFalseMatrix(4, 4, 0.0, 200, 50, true);

            m_cellList = new List<IACell>();
            for (int i = 0; i < 3; i++)
            {
                IACell cell = new UMTSCell();
                m_cellList.Add(cell);
            }
            double[] x = new double[3] { 50, 100, 150 };
            double[] y = new double[3] { 50, 100, 50 };
            MockCellList.CreateCellList(m_cellList, x, y);

            m_pg = new UMTSPredictionGroup();
            m_pg.Region = MockRegion.CreateRegion();
            m_pg.Region.Name = "region1";
            m_pg.Name = "UMTSPredictionGroup1";
            UnionCsService service = new UnionCsService();
            Service umtsService = new UMTSService();
            service.CSServiceDic.Add(NetWorkType.UMTS, umtsService);
            m_pg.CsService = service;
            m_pg.TrafficTerminal = new Terminal();
            m_pg.TrafficTerminal.NetTerminalList.Add(new NetworkTerminal());

            m_index = 0;
            LinkLossAssist.Init();

            m_Context.Add(ContextKeys.Group, m_pg);
            m_Context.Add(ContextKeys.TFMatrix, matrix);
            m_Context.Add(ContextKeys.ApplicationContext, ProjectSingleton.CurrentProject.AppContext);
            m_Case.InitialCase(m_Context);

            for (int i = 0; i < 3; i++)
            {
                m_Context.Add(ContextKeys.CurrentCalcCell, m_cellList[i]);
                m_Case.Run(m_index, m_Context);
                m_Context.Remove(ContextKeys.CurrentCalcCell);
            }
        }
开发者ID:xiaoyj,项目名称:Space,代码行数:42,代码来源:BestServerCaseFixture.cs

示例4: ProcessPhiInstruction

        /// <summary>
        /// Processes the phi instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ProcessPhiInstruction(Context context)
        {
            var sourceBlocks = context.Other as List<BasicBlock>;

            for (var index = 0; index < context.BasicBlock.PreviousBlocks.Count; index++)
            {
                var operand = context.GetOperand(index);
                var predecessor = sourceBlocks[index];

                InsertCopyStatement(predecessor, context.Result, operand);
            }

            context.Remove();
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:18,代码来源:LeaveSSAStage.cs

示例5:

 /// <summary>
 /// Visitation function for Dup instruction.
 /// </summary>
 /// <param name="context">The context.</param>
 void CIL.ICILVisitor.Dup(Context context)
 {
     // We don't need the dup anymore.
     context.Remove();
 }
开发者ID:tea,项目名称:MOSA-Project,代码行数:9,代码来源:CILTransformationStage.cs

示例6: ProcessInvokeInstruction

        /// <summary>
        /// Visitation function for Call instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void CIL.ICILVisitor.Call(Context context)
        {
            if (CanSkipDueToRecursiveSystemObjectCtorCall(context))
            {
                context.Remove();
                return;
            }

            if (ProcessExternalCall(context))
                return;

            ProcessInvokeInstruction(context, context.MosaMethod, context.Result, new List<Operand>(context.Operands));
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:17,代码来源:CILTransformationStage.cs

示例7: MakeCall

        /// <summary>
        /// Expands method call instruction represented by the context to perform the method call.
        /// </summary>
        /// <param name="typeLayout">The type layouts.</param>
        /// <param name="context">The context.</param>
        public override void MakeCall(BaseMethodCompiler compiler, MosaTypeLayout typeLayout, Context context)
        {
            /*
             * Calling convention is right-to-left, pushed on the stack. Return value in EAX for integral
             * types 4 bytes or less, XMM0 for floating point and EAX:EDX for 64-bit. If this is a method
             * of a type, the this argument is moved to ECX right before the call.
             * If return value is value type, a stack local is allocated as a hidden parameter in caller
             * stack, the callee will then store the return value in the allocated space
             * The return value is the first parameter (even before this)
             * The callee will place the address of the return value into EAX and the caller will then
             * either retrieve the return value using compound move or will let one of the callers higher
             * in the caller chain handle the retrieval of the return value using compound move.
             */

            Operand target = context.Operand1;
            Operand result = context.Result;
            MosaMethod method = context.MosaMethod;

            Debug.Assert(method != null, context.ToString());

            Operand scratch = Operand.CreateCPURegister(typeLayout.TypeSystem.BuiltIn.Pointer, scratchRegister);

            List<Operand> operands = BuildOperands(context);

            int stackSize = CalculateStackSizeForParameters(typeLayout, architecture, operands, method);

            context.Remove();

            int returnSize = 0;
            if (typeLayout.IsCompoundType(method.Signature.ReturnType))
            {
                returnSize = typeLayout.GetTypeSize(method.Signature.ReturnType);
            }

            if (stackSize != 0 || returnSize != 0)
            {
                ReserveStackSizeForCall(typeLayout.TypeSystem, context, returnSize + stackSize, scratch);
                PushOperands(compiler, typeLayout, context, method, operands, returnSize + stackSize, scratch);
            }

            // the mov/call two-instructions combo is to help facilitate the register allocator
            architecture.InsertMoveInstruction(context, scratch, target);
            architecture.InsertCallInstruction(context, scratch);

            CleanupReturnValue(compiler, typeLayout, context, result);
            FreeStackAfterCall(typeLayout.TypeSystem, context, returnSize + stackSize);
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:52,代码来源:BaseCallingConvention32Bit.cs

示例8: ProcessInvokeInstruction

        /// <summary>
        /// Visitation function for Call instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void CIL.ICILVisitor.Call(Context context)
        {
            if (this.CanSkipDueToRecursiveSystemObjectCtorCall(context))
            {
                context.Remove();
                return;
            }

            if (ProcessExternalCall(context))
                return;

            // Create a symbol operand for the invocation target
            RuntimeMethod invokeTarget = context.InvokeTarget;
            Operand symbolOperand = Operand.CreateSymbolFromMethod(invokeTarget);

            ProcessInvokeInstruction(context, symbolOperand, context.Result, new List<Operand>(context.Operands));
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:21,代码来源:CILTransformationStage.cs

示例9: ProcessPhiInstruction

        /// <summary>
        /// Processes the phi instruction.
        /// </summary>
        /// <param name="block">The block.</param>
        /// <param name="context">The context.</param>
        private void ProcessPhiInstruction(BasicBlock block, Context context)
        {
            for (var index = 0; index < block.PreviousBlocks.Count; index++)
            {
                var predecessor = block.PreviousBlocks[index];
                var operand = context.GetOperand(index);

                InsertCopyStatement(predecessor, context.Result, operand);
            }
            context.Remove();
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:16,代码来源:LeaveSSAStage.cs

示例10: Ldloc

 /// <summary>
 /// Visitation function for Ldloc instruction.
 /// </summary>
 /// <param name="context">The context.</param>
 public void Ldloc(Context context)
 {
     if (context.Ignore)
     {
         context.Remove();
     }
     else
     {
         ProcessLoadInstruction(context);
     }
 }
开发者ID:grover,项目名称:MOSA-Project,代码行数:15,代码来源:CILTransformationStage.cs

示例11: CreateTermDefinition

        private void CreateTermDefinition(string term, Context context, JObject localContext, IDictionary<string, bool> defined)
        {
            if (defined.ContainsKey(term))
            {
                if (!defined[term])
                {
                    throw new InvalidOperationException("Cyclic IRI mapping detected.");
                }

                return;
            }

            if (IsKeyWord(term))
            {
                throw new InvalidOperationException("Keyword redefinition detected.");
            }

            defined[term] = false;
            context.Remove(term);
            JToken value = ((localContext != null) && (localContext.Property(term) != null) ? localContext[term].DeepClone() : null);
            if ((value == null) || ((value is JValue) && (((JValue)value).Value == null)) || ((value is JObject) && (((JObject)value).Property(Id) != null) && (((JObject)value).Property(Id).ValueEquals(null))))
            {
                context[term] = null;
                return;
            }
            else if ((value is JValue) && (((JValue)value).Type == JTokenType.String))
            {
                JObject newObject = new JObject();
                newObject[Id] = value;
                value = newObject;
            }
            else if (!(value is JObject))
            {
                throw new InvalidOperationException("Invalid term definition.");
            }

            TermDefinition definition = new TermDefinition() { Original = value };
            if (((JObject)value).Property(Type) != null)
            {
                if (!((JObject)value).Property(Type).ValueIs<string>())
                {
                    throw new InvalidOperationException("Invalid type mapping.");
                }

                string result = ((JObject)value).Property(Type).ValueAs<string>();
                result = ExpandIri(result, context, localContext, false, true, defined);
                if ((result != Id) && (result != Vocab) && (!Regex.IsMatch(result, "[a-zA-Z0-9_]+:.+")))
                {
                    throw new InvalidOperationException("Invalid type mapping.");
                }

                definition.Type = result;
            }

            if (((JObject)value).Property(Reverse) != null)
            {
                JProperty reverse = ((JObject)value).Property(Reverse);
                if (((JObject)value).Property(Id) != null)
                {
                    throw new InvalidOperationException("Invalid reverse property.");
                }

                if (!reverse.ValueIs<string>())
                {
                    throw new InvalidOperationException("Invalid IRI mapping.");
                }

                definition.Iri = ExpandIri(reverse.ValueAs<string>(), context, localContext, false, true, defined);

                if (((JObject)value).Property(Container) != null)
                {
                    definition.Container = (string)((JObject)value)[Container];
                }

                definition.IsReverse = true;
                context[term] = definition;
                defined[term] = true;
                return;
            }

            definition.IsReverse = false;
            if ((value is JObject) && (((JObject)value).Property(Id) != null) && (!((JObject)value).Property(Id).ValueEquals(term)))
            {
                if ((!(((JObject)value).Property(Id).Value is JValue)) || (((JValue)((JObject)value).Property(Id).Value).Type != JTokenType.String))
                {
                    throw new InvalidOperationException("Invalid IRI mapping.");
                }

                string iri = ExpandIri((string)((JValue)((JObject)value).Property(Id).Value).Value, context, localContext, false, true, defined).ToString();
                if ((!IsKeyWord((string)iri)) && (!Regex.IsMatch(iri, "[a-zA-Z0-9_]+:.+")))
                {
                    throw new InvalidOperationException("Invalid IRI mapping.");
                }

                if ((string)iri == Context)
                {
                    throw new InvalidOperationException("Invalid keyword alias.");
                }

                definition.Iri = iri;
//.........这里部分代码省略.........
开发者ID:rafalrosochacki,项目名称:RomanticWeb,代码行数:101,代码来源:JsonLdProcessor.expand.cs


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