Beispiel #1
0
 private bool HasOffsetToContainer(IStatement container, int stmtIndex)
 {
     if (loopMergingInfo != null && container is IForStatement && stmtIndex >= 0)
     {
         IForStatement        ifs     = (IForStatement)container;
         Set <int>            stmts   = stmtsOfContainer[container];
         IVariableDeclaration loopVar = Recognizer.LoopVariable(ifs);
         foreach (int edge in loopMergingInfo.graph.EdgesInto(stmtIndex))
         {
             int         source     = loopMergingInfo.graph.SourceOf(edge);
             IOffsetInfo offsetInfo = loopMergingInfo.offsetInfos[edge];
             if ((source == stmtIndex || stmts.Contains(source)) && offsetInfo != null && offsetInfo.ContainsKey(loopVar))
             {
                 return(true);
             }
         }
         foreach (int edge in loopMergingInfo.graph.EdgesOutOf(stmtIndex))
         {
             int         target     = loopMergingInfo.graph.TargetOf(edge);
             IOffsetInfo offsetInfo = loopMergingInfo.offsetInfos[edge];
             if ((target == stmtIndex || stmts.Contains(target)) && offsetInfo != null && offsetInfo.ContainsKey(loopVar))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #2
0
        private bool IsProhibited(int edge, IVariableDeclaration loopVar, bool isForwardLoop, bool isForwardEdge)
        {
            ICollection <IVariableDeclaration> prohibited = prohibitedLoopVars[edge];

            if (prohibited != null && prohibited.Contains(loopVar))
            {
                return(true);
            }
            IOffsetInfo offsetInfo = offsetInfos[edge];

            if (offsetInfo != null)
            {
                foreach (var entry in offsetInfo)
                {
                    if (entry.loopVar == loopVar)
                    {
                        int offset = entry.offset;
                        if ((offset > 0) && isForwardLoop && isForwardEdge)
                        {
                            return(true);
                        }
                        if ((offset < 0) && !isForwardLoop && isForwardEdge)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
        public void SetOffsetInfo(IStatement mutated, IStatement affected, IOffsetInfo offsetInfo)
        {
            int source = indexOf[mutated];
            int target = indexOf[affected];

            if (!graph.TryGetEdge(source, target, out int edge))
            {
                edge = graph.AddEdge(source, target);
                prohibitedLoopVars[edge] = null;
            }
            offsetInfos[edge] = offsetInfo;
        }
        private static void AddOffsetIndices(Dictionary <IStatement, IOffsetInfo> offsetIndexOf, IOffsetInfo offsetIndex, IStatement ist)
        {
            IOffsetInfo offsetIndices;

            if (!offsetIndexOf.TryGetValue(ist, out offsetIndices))
            {
                offsetIndexOf[ist] = offsetIndex;
            }
            else
            {
                OffsetInfo newOffsetInfo = new OffsetInfo();
                newOffsetInfo.AddRange(offsetIndices);
                newOffsetInfo.AddRange(offsetIndex);
                offsetIndexOf[ist] = newOffsetInfo;
            }
        }
 public void AddOffsetIndices(IOffsetInfo offsetIndex, IStatement ist)
 {
     AddOffsetIndices(offsetIndexOf, offsetIndex, ist);
 }