Ejemplo n.º 1
0
        public override void VisitCFGExitBlock(ExitBlock x)
        {
            VisitCFGBlock(x);

            // TODO: EdgeToCallers:
            EnqueueSubscribers(x);
        }
Ejemplo n.º 2
0
        protected void PingSubscribers(ExitBlock exit)
        {
            if (exit != null)
            {
                bool wasNotAnalysed = false;
                if (_state.Routine?.IsReturnAnalysed == false)
                {
                    wasNotAnalysed = true;
                    _state.Routine.IsReturnAnalysed = true;
                }

                // Ping the subscribers either if the return type has changed or
                // it is the first time the analysis reached the routine exit
                var rtype = _state.GetReturnType();
                if (rtype != exit._lastReturnTypeMask || wasNotAnalysed)
                {
                    exit._lastReturnTypeMask = rtype;
                    var subscribers = exit.Subscribers;
                    if (subscribers.Count != 0)
                    {
                        lock (subscribers)
                        {
                            foreach (var subscriber in subscribers)
                            {
                                _worklist.PingReturnUpdate(exit, subscriber);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private IEnumerator TeleportToExit(ExitBlock reachedExit, PlayerStateController player)
        {
            PlayerManager.Instance.TeleportPlayer(player, reachedExit.transform, false);

            yield return(TeleportExitCoroutine);

            this.OnSectionFinished?.Invoke(new SectionTransitionData(reachedExit.TargetSectionID));
            this.DisableSection();
        }
Ejemplo n.º 4
0
 protected void EnqueueSubscribers(ExitBlock exit)
 {
     if (exit != null)
     {
         var rtype = _state.GetReturnType();
         if (rtype != exit._lastReturnTypeMask)
         {
             exit._lastReturnTypeMask = rtype;
             exit.Subscribers.ForEach(_worklist.Enqueue);
         }
     }
 }
Ejemplo n.º 5
0
        public override void VisitCFGExitBlock(ExitBlock x)
        {
            VisitCFGBlock(x);

            // TODO: EdgeToCallers:
            var rtype = _state.GetReturnType();

            if (rtype != x._lastReturnTypeMask)
            {
                x._lastReturnTypeMask = rtype;
                x.Subscribers.ForEach(_worklist.Enqueue);
            }
        }
Ejemplo n.º 6
0
        public void PingReturnUpdate(ExitBlock updatedExit, T callingBlock)
        {
            var caller = callingBlock.FlowState?.Routine;

            if (caller == null || _callGraph.GetCalleeEdges(caller).All(edge => edge.Callee.IsReturnAnalysed))
            {
                Enqueue(callingBlock);
            }
            else
            {
                _dirtyCallBlocks.TryAdd(callingBlock, null);
            }
        }
Ejemplo n.º 7
0
        private Exit GenerateExitFromBlock(ExitBlock eb)
        {
            Exit output = new Exit
                          (
                eb.PosX,
                eb.PosY,
                eb.ExitDirection == Direction.North,
                eb.ExitDirection == Direction.South,
                eb.ExitDirection == Direction.East,
                eb.ExitDirection == Direction.West,
                eb.ExitToID,
                0,
                0
                          );

            return(output);
        }
Ejemplo n.º 8
0
        public bool CreateExitBlock(CreateBlockViewModel model)
        {
            var entity = new ExitBlock
            {
                MapID         = model.MapModel.MapID,
                OwnerID       = _userID,
                Name          = model.CreateBlockModel.Name,
                Description   = model.CreateBlockModel.Description,
                TypeOfBlock   = GetBlockTypeFromString("Exit"),
                PosX          = model.CreateBlockModel.PosX,
                PosY          = model.CreateBlockModel.PosY,
                ExitDirection = GetExitDirectionFromString(model.CreateBlockModel.ExitDirection),
                ExitToID      = model.CreateBlockModel.ExitToID
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Blocks.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 9
0
        public void PingReturnUpdate(ExitBlock updatedExit, T callingBlock)
        {
            var caller = callingBlock.FlowState?.Routine;

            // If the update of the analysis is in progress and the caller is not yet analysed (its FlowState is null due to invalidation) or
            // is not within the currently analysed routines, don't enqueue it
            if (callingBlock.FlowState == null ||
                (caller != null && _currentRoutinesLastReturnTypes != null && !_currentRoutinesLastReturnTypes.ContainsKey(caller)))
            {
                return;
            }

            if (caller == null || _callGraph.GetCalleeEdges(caller).All(edge => edge.Callee.IsReturnAnalysed))
            {
                Enqueue(callingBlock);
            }
            else
            {
                _dirtyCallBlocks.TryAdd(callingBlock, null);
            }
        }
Ejemplo n.º 10
0
 private void InvokeSectionFinished(ExitBlock reachedExit, PlayerStateController player)
 {
     StartCoroutine(TeleportToExit(reachedExit, player));
 }
Ejemplo n.º 11
0
 public void Awake()
 {
     GetComponent <SpriteRenderer>().enabled = false;
     block = GetComponentInChildren <ExitBlock>();
 }
Ejemplo n.º 12
0
 // Create the special blocks attached to the method entry / exit.
 private void CreateEntryAndExitBlocks(Method method, StatementList blocks) {
   entry_point       = new EntryBlock(new MethodHeader(method));
   exit_point        = new ExitBlock();
   normal_exit_point = new NormalExitBlock();
   excp_exit_point   = new ExcpExitBlock(method);
 }