/// <summary>
        /// Copies the current AssignmentPath and return the copy
        /// </summary>
        /// <returns></returns>
        public AssignmentPath Copy()
        {
            AssignmentPath newPath = new AssignmentPath();

            foreach (var vs in VariableStmts)
            {
                newPath.AddNewPair(vs);
            }
            return(newPath);
        }
Esempio n. 2
0
        public void AddNewRelations(VariableDeclaration assignedVar, HashSet <VariableDeclaration> assigningVars, Statement stmt)
        {
            //InitValidStates
            if (!VarDictionary.ContainsKey(assignedVar))
            {
                AssignmentPath aPath = new AssignmentPath();
                aPath.AddNewPair(assignedVar, assignedVar.ParentStatement);
                List <AssignmentPath> listPath = new List <AssignmentPath>();
                listPath.Add(aPath);
                VarDictionary[assignedVar] = listPath;
            }
            foreach (var assigningVar in assigningVars)
            {
                if (!VarDictionary.ContainsKey(assigningVar))
                {
                    AssignmentPath aPath = new AssignmentPath();
                    aPath.AddNewPair(assigningVar, assigningVar.ParentStatement);
                    List <AssignmentPath> listPath = new List <AssignmentPath>();
                    listPath.Add(aPath);
                    VarDictionary[assigningVar] = listPath;
                }
            }
            List <AssignmentPath> newListPath = new List <AssignmentPath>();

            //Then update
            foreach (var assigningVar in assigningVars)
            {
                var ListPath = VarDictionary[assigningVar];
                foreach (var path in ListPath)
                {
                    var newPath = path.Copy();
                    //newPath.AddNewPair(assigningVar, stmt);
                    newPath.AddNewPair(assignedVar, stmt);
                    newListPath.Add(newPath);
                }
            }
            VarDictionary[assignedVar] = newListPath;
        }