/// <summary>
        /// 按照链式方式依次把调用继续下去
        /// </summary>
        /// <param name="request"></param>
        public virtual void Handle(IRequest request)
        {
            // 如果发现当前操作设置了断点,则抛出事件
            if (HasBreakPoint)
            {
                OnBreak(new CallHandlerEventArgs(this, request));
            }

            if (request == null)
            {
                return;
            }
            if (request.EnumType.GetHashCode() == EnumType.GetHashCode())
            {
                Process(request);
            }
            else
            {
                if (Successors.Any())
                {
                    foreach (var s in Successors)
                    {
                        s.Handle(request);
                    }
                }
            }
        }
Exemple #2
0
 public Arrow FindNext()
 {
     return(Successors
            .MaxBy(x => x.Weight + Graph.DWeight * Visited
                   + x.To.Successors.Select(y => y.Weight + Graph.DWeight * y.To.Visited).Max())
            .First());
 }
Exemple #3
0
        public void Split(Block rightBlock)
        {
            int splitIndex = BinarySearch(OpCodes, rightBlock.Address);

            if (OpCodes[splitIndex].Address < rightBlock.Address)
            {
                splitIndex++;
            }

            int splitCount = OpCodes.Count - splitIndex;

            if (splitCount <= 0)
            {
                throw new ArgumentException("Can't split at right block address.");
            }

            rightBlock.EndAddress = EndAddress;
            rightBlock.Successors.AddRange(Successors);
            rightBlock.Predecessors.Add(this);

            EndAddress = rightBlock.Address;

            Successors.Clear();
            Successors.Add(rightBlock);

            // Move ops.
            rightBlock.OpCodes.AddRange(OpCodes.GetRange(splitIndex, splitCount));

            OpCodes.RemoveRange(splitIndex, splitCount);

            // Update push consumers that points to this block.
            foreach (SyncTarget syncTarget in SyncTargets.Values)
            {
                PushOpInfo pushOpInfo = syncTarget.PushOpInfo;

                Operand local = pushOpInfo.Consumers[this];
                pushOpInfo.Consumers.Remove(this);
                pushOpInfo.Consumers.Add(rightBlock, local);
            }

            foreach ((ulong key, SyncTarget value) in SyncTargets)
            {
                rightBlock.SyncTargets.Add(key, value);
            }

            SyncTargets.Clear();

            // Move push ops.
            for (int i = 0; i < PushOpCodes.Count; i++)
            {
                if (PushOpCodes[i].Op.Address >= rightBlock.Address)
                {
                    int count = PushOpCodes.Count - i;
                    rightBlock.PushOpCodes.AddRange(PushOpCodes.Skip(i));
                    PushOpCodes.RemoveRange(i, count);
                    break;
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// 添加后续节点
 /// </summary>
 /// <param name="success"></param>
 public void AddSuccessor(CoRHandlerBase <Request> success)
 {
     if (this.Successors == null)
     {
         Successors = new List <CoRHandlerBase <Request> >();
     }
     Successors.Add(success);
 }
Exemple #5
0
 void SetSuccessors()
 {
     Collider[] _successors = Physics.OverlapSphere(Position, successorRange, cellLayer);
     Successors = _successors.Select(s => s.GetComponent <CE_Cell>()).ToList();
     Successors.Distinct();
     Successors.Remove(this);
     CE_Board.Instance.Add(this);
 }
Exemple #6
0
                private string Print(int indentlevel)
                {
                    var space = "".PadLeft(indentlevel, ' ');

                    return(string.Join($"\n{space}", new[] { Label }.Concat(
                                           Successors.Select(x => x.Print(indentlevel + 4))
                                           )));
                }
Exemple #7
0
    public static Successors getInstance()
    {
        if (instance == null)
        {
            instance = new Successors();
        }

        return(instance);
    }
        public void AddSuccessor(int successorNumber)
        {
            if (Successors.Contains(successorNumber))
            {
                throw new ArgumentException("Violation of: successorNumber is not in this.Successors");
            }

            Successors.Add(successorNumber);
        }
Exemple #9
0
        /// <summary>
        /// Erzeugt eine textuelle Repräsentation des Vorgangs. Angelehnt an die Syntax des Prozessplans.
        /// </summary>
        /// <returns>Textuelle Repräsentation des Vorgangs.</returns>
        internal string GetInfo()
        {
            string predecessors = String.Join(",", Predecessors.Select(n => n.ID));
            string ancestors    = String.Join(",", Successors.Select(n => n.ID));

            predecessors = String.IsNullOrWhiteSpace(predecessors) ? "-" : predecessors;
            ancestors    = String.IsNullOrWhiteSpace(ancestors) ? "-" : ancestors;

            return($"{ID} | {Description} | {Duration} | {predecessors} | {ancestors}");
        }
Exemple #10
0
        /// <summary>
        /// Rückwärtsterminierung. Berechnet den spätesten Anfangs- und Endzeitpunkt, den
        /// Gesamtpuffer und den Freien Puffer des Vorgangs.
        /// </summary>
        internal void BackwardPassCalculation()
        {
            LatestFinishingPoint = IsFinal
                ? EarliestFinishingPoint
                : Successors.Select(successor => successor.LatestStartingPoint).Min();
            LatestStartingPoint = LatestFinishingPoint - Duration;

            TotalFloat = LatestFinishingPoint - EarliestFinishingPoint;
            FreeFloat  = IsFinal
                ? 0
                : Successors.Select(successor => successor.EarliestStartingPoint).Min() - EarliestFinishingPoint;
        }
Exemple #11
0
        /// <summary>
        /// Unbinds all predecessors and successors from this node.
        /// </summary>
        internal void UnBindAll()
        {
            while (Predecessors.Count > 0)
            {
                FlowNode <T> pre = Predecessors.First();
                pre.Successors.Remove(this);
                Predecessors.Remove(pre);
            }

            while (Successors.Count > 0)
            {
                FlowNode <T> succ = Successors.First();
                succ.Predecessors.Remove(this);
                Successors.Remove(succ);
            }
            //System.Diagnostics.Debug.Assert(DebugConsistencyCheck(pred, succ));
        }
Exemple #12
0
 protected override void InternalInitBufferObjects()
 {
     if (Successors.Any(suc => suc.MaxBufferSize > 0))
     {
         AvoidBroadcastBlock = true;
         OwnBroadcastBlock   = new ActionBlock <TInput>(Broadcast, new ExecutionDataflowBlockOptions()
         {
             BoundedCapacity = MaxBufferSize
         });
     }
     else
     {
         BroadcastBlock = new BroadcastBlock <TInput>(Clone, new DataflowBlockOptions()
         {
             BoundedCapacity = MaxBufferSize
         });
     }
 }
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }
            if (other == this)
            {
                return(true);
            }
            if (!(other is CSECourse))
            {
                return(false);
            }

            CSECourse otherCourse = other as CSECourse;

            return(Number == otherCourse.Number &&
                   Name == otherCourse.Name &&
                   Syllabus == otherCourse.Syllabus &&
                   Prereqs.Equals(otherCourse.Prereqs) &&
                   Successors.Equals(otherCourse.Successors));
        }
Exemple #14
0
 public bool Accept(RuntimeModelVisitor visitor)
 {
     return(visitor.Visit(this, next => Successors.All(activation => activation.Accept(next))));
 }
Exemple #15
0
 public bool Accept(RuntimeVisitor visitor)
 {
     return(visitor.Visit(this, next => _rightActivation.Accept(next) &&
                          Successors.All(activation => activation.Accept(next))));
 }
Exemple #16
0
        private void ImportFallThrough(BasicBlock next)
        {
            // Setup successor of current block as next
            _currentBasicBlock !.Successors.Add(next);

            // Setup predecessor of next block as current block
            next.Predecessors.Add(_currentBasicBlock);

            // Evaluation stack in each basic block holds the imported high level tree representation of the IL

            EvaluationStack <StackEntry>?entryStack = next.EntryStack;

            if (entryStack != null)
            {
                // Check the entry stack and the current stack are equivalent,
                // i.e. have same length and elements are identical

                if (entryStack.Length != _stack.Length)
                {
                    throw new InvalidProgramException();
                }

                for (int i = 0; i < entryStack.Length; i++)
                {
                    if (entryStack[i].Kind != _stack[i].Kind)
                    {
                        throw new InvalidProgramException();
                    }

                    if (entryStack[i].Kind == StackValueKind.ValueType)
                    {
                        if (entryStack[i].Kind != _stack[i].Kind)
                        {
                            throw new InvalidProgramException();
                        }
                    }
                }
            }

            if (_stack.Length > 0)
            {
                // If the block is not empty on exit from the basic block, additional
                // processing is needed to make sure the block successors can use the
                // values on the predecessor’s stack.
                //
                // Any branch/jump statement is removed.
                // Next the remaining values on the stack are removed and converted
                // into assignments to new temps
                // The next basic blocks entry stack is setup to contain the temps
                // The branch/jump statement is put back if there was one

                var setupEntryStack = entryStack == null;
                if (entryStack == null)
                {
                    entryStack = new EvaluationStack <StackEntry>(_stack.Length);
                }

                // Remove the branch/jump statement at the end of the block if present
                var lastStmt = ImportExtractLastStmt();

                // Spill stuff on stack in new temps and setup new stack to contain the temps
                for (int i = 0; i < _stack.Length; i++)
                {
                    int?tempNumber = null;
                    if (!setupEntryStack)
                    {
                        tempNumber = (entryStack[i].As <LocalVariableEntry>()).LocalNumber;
                    }
                    var temp = ImportSpillStackEntry(_stack[i], tempNumber);
                    if (setupEntryStack)
                    {
                        entryStack.Push(temp);
                    }
                }

                // Add the branch/jump statement back if there was one
                if (lastStmt != null)
                {
                    ImportAppendTree(lastStmt);
                }

                // Set the entry stack for the next basic block to the one we've built
                // e.g. with the new temps on it
                next.EntryStack = entryStack;
            }

            MarkBasicBlock(next);
        }
 public override void SetValue(TResult value)
 {
     Successors.SetDummy();
     LensPut.SetValue(Target.Value, value);
 }
Exemple #18
0
 public void Dispose()
 {
     Successors.UnsetAll();
 }
Exemple #19
0
 protected virtual void Dispose(bool disposing)
 {
     Successors.UnsetAll();
 }
Exemple #20
0
 /// <summary>
 /// Adds a sucessor to the list of successors
 /// </summary>
 /// <param name="Node">Node.</param>
 public void AddSucessor(RRTNode Node)
 {
     Successors.Add(Node);
 }