Esempio n. 1
0
        /// <summary>
        /// Appends a method store to the current one
        /// </summary>
        /// <param name="sem"></param>
        public void AppendMethodStore(SEMethodStore sem, int offset)
        {
            foreach (var defelem in sem.DefinedFieldSet.Values)
            {
                SEFieldStore sef;
                if (!this.defFieldSet.TryGetValue(defelem.FullName, out sef))
                {
                    sef = new SEFieldStore(defelem.FullName);
                    sef.OptionalField = defelem.OptionalField;
                    this.defFieldSet[defelem.FullName] = sef;
                }

                sef.AllOffsets.Add(offset);
            }

            foreach (var useelem in sem.UsedFieldSet.Values)
            {
                SEFieldStore sef;
                if (!this.useFieldSet.TryGetValue(useelem.FullName, out sef))
                {
                    sef = new SEFieldStore(useelem.FullName);
                    sef.OptionalField = useelem.OptionalField;
                    this.useFieldSet[useelem.FullName] = sef;
                }

                sef.AllOffsets.Add(offset);
            }
        }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            SEFieldStore other = obj as SEFieldStore;

            if (other == null)
            {
                return(false);
            }

            return(this.fullname == other.fullname);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a field to defined list
        /// </summary>
        /// <param name="field"></param>
        public void AddToDefinedList(Field field, int offset)
        {
            SEFieldStore sef;
            if(!this.defFieldSet.TryGetValue(field.FullName, out sef))
            {
                sef = new SEFieldStore(field.FullName);
                sef.OptionalField = field;
                this.defFieldSet[field.FullName] = sef;
            }

            sef.AllOffsets.Add(offset);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a field to defined list
        /// </summary>
        /// <param name="field"></param>
        public void AddToDefinedList(Field field, int offset)
        {
            SEFieldStore sef;

            if (!this.defFieldSet.TryGetValue(field.FullName, out sef))
            {
                sef = new SEFieldStore(field.FullName);
                sef.OptionalField = field;
                this.defFieldSet[field.FullName] = sef;
            }

            sef.AllOffsets.Add(offset);
        }
Esempio n. 5
0
        /// <summary>
        /// Reads from the database
        /// </summary>
        /// <returns></returns>
        public static SideEffectStore ReadFromDatabase()
        {
            try
            {
                var filename = Path.Combine(DUCoverConstants.DUCoverStoreLocation, DUCoverConstants.SideEffectStoreDebugFile);
                SideEffectStore ses = new SideEffectStore();
                if (!File.Exists(filename))
                    return ses;

                using (StreamReader sr = new StreamReader(filename))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        line.Trim();
                        string methodname = line;
                        SEMethodStore sem = new SEMethodStore(methodname);
                        ses.MethodStore[methodname] = sem;

                        //Reading defined
                        line = sr.ReadLine().Trim();
                        string[] parts = line.Split(' ');

                        int numDefined = Convert.ToInt32(parts[1]);
                        for (int count = 0; count < numDefined; count++)
                        {
                            line = sr.ReadLine().Trim();
                            string[] lineparts = line.Split(' ');

                            SEFieldStore sef = new SEFieldStore(lineparts[0]);
                            sem.DefinedFieldSet[lineparts[0]] = sef;
                            for (int tcount = 1; tcount < lineparts.Length; tcount++)
                            {
                                sef.AllOffsets.Add(Convert.ToInt32(lineparts[tcount]));
                            }
                        }

                        //Reading used
                        line = sr.ReadLine().Trim();
                        parts = line.Split(' ');

                        int numUsed = Convert.ToInt32(parts[1]);
                        for (int count = 0; count < numUsed; count++)
                        {
                            line = sr.ReadLine().Trim();
                            string[] lineparts = line.Split(' ');

                            SEFieldStore sef = new SEFieldStore(lineparts[0]);
                            sem.UsedFieldSet[lineparts[0]] = sef;
                            for (int tcount = 1; tcount < lineparts.Length; tcount++)
                            {
                                sef.AllOffsets.Add(Convert.ToInt32(lineparts[tcount]));
                            }
                        }
                    }
                }

                Console.WriteLine("Number of entries read: " + ses.MethodStore.Count);
                return ses;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to deserialize");
                logger.ErrorException("Error occurred while reading from file " + ex.StackTrace, ex);
            }

            return new SideEffectStore();
        }
Esempio n. 6
0
        /// <summary>
        /// Appends a method store to the current one
        /// </summary>
        /// <param name="sem"></param>
        public void AppendMethodStore(SEMethodStore sem, int offset)
        {
            foreach (var defelem in sem.DefinedFieldSet.Values)
            {
                SEFieldStore sef;
                if (!this.defFieldSet.TryGetValue(defelem.FullName, out sef))
                {
                    sef = new SEFieldStore(defelem.FullName);
                    sef.OptionalField = defelem.OptionalField;
                    this.defFieldSet[defelem.FullName] = sef;
                }

                sef.AllOffsets.Add(offset);
            }

            foreach (var useelem in sem.UsedFieldSet.Values)
            {
                SEFieldStore sef;
                if (!this.useFieldSet.TryGetValue(useelem.FullName, out sef))
                {
                    sef = new SEFieldStore(useelem.FullName);
                    sef.OptionalField = useelem.OptionalField;
                    this.useFieldSet[useelem.FullName] = sef;
                }

                sef.AllOffsets.Add(offset);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Reads from the database
        /// </summary>
        /// <returns></returns>
        public static SideEffectStore ReadFromDatabase()
        {
            try
            {
                var             filename = Path.Combine(DUCoverConstants.DUCoverStoreLocation, DUCoverConstants.SideEffectStoreDebugFile);
                SideEffectStore ses      = new SideEffectStore();
                if (!File.Exists(filename))
                {
                    return(ses);
                }

                using (StreamReader sr = new StreamReader(filename))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        line.Trim();
                        string        methodname = line;
                        SEMethodStore sem        = new SEMethodStore(methodname);
                        ses.MethodStore[methodname] = sem;

                        //Reading defined
                        line = sr.ReadLine().Trim();
                        string[] parts = line.Split(' ');

                        int numDefined = Convert.ToInt32(parts[1]);
                        for (int count = 0; count < numDefined; count++)
                        {
                            line = sr.ReadLine().Trim();
                            string[] lineparts = line.Split(' ');

                            SEFieldStore sef = new SEFieldStore(lineparts[0]);
                            sem.DefinedFieldSet[lineparts[0]] = sef;
                            for (int tcount = 1; tcount < lineparts.Length; tcount++)
                            {
                                sef.AllOffsets.Add(Convert.ToInt32(lineparts[tcount]));
                            }
                        }

                        //Reading used
                        line  = sr.ReadLine().Trim();
                        parts = line.Split(' ');

                        int numUsed = Convert.ToInt32(parts[1]);
                        for (int count = 0; count < numUsed; count++)
                        {
                            line = sr.ReadLine().Trim();
                            string[] lineparts = line.Split(' ');

                            SEFieldStore sef = new SEFieldStore(lineparts[0]);
                            sem.UsedFieldSet[lineparts[0]] = sef;
                            for (int tcount = 1; tcount < lineparts.Length; tcount++)
                            {
                                sef.AllOffsets.Add(Convert.ToInt32(lineparts[tcount]));
                            }
                        }
                    }
                }

                Console.WriteLine("Number of entries read: " + ses.MethodStore.Count);
                return(ses);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to deserialize");
                logger.ErrorException("Error occurred while reading from file " + ex.StackTrace, ex);
            }

            return(new SideEffectStore());
        }