Ejemplo n.º 1
0
        private void match_tables()
        {
            /* FIXME: we should do something a bit more sophisticated:
             * start by matching table names, then ensure data types and such haven’t changed
             * ... then try another matching strategy?
             */

            var table_counts = new Dictionary <string, int>();

            //FIXME: Pretty sure I want duplicates here, use Concat() instead of Union()?
            foreach (var table in Orig.Union(Dest))
            {
                var name = table.Name;
                if (!table_counts.ContainsKey(name))
                {
                    table_counts.Add(name, 1);
                }
                else
                {
                    table_counts[name]++;
                }
            }

            foreach (var kp in table_counts)
            {
                var name  = kp.Key;
                var count = kp.Value;
                switch (count)
                {
                case 1:
                    string orig_name = null;
                    string dest_name = null;
                    if (Orig.ContainsKey(name))
                    {
                        orig_name = name;
                    }
                    else
                    {
                        dest_name = name;
                    }
                    UnmatchedTables.Add(new TableTuple(this, orig_name, dest_name));
                    break;

                case 2:
                    MatchedTables.Add(new TableTuple(this, name, name));
                    break;

                default:
                    throw new Exception($"{name} has {count} occurences");
                }
            }
        }
Ejemplo n.º 2
0
        public static void Log(String sMsg, Prio ePriorite, Orig eOrigine, bool bMsgBox)
        {
            DateTime dt    = DateTime.Now;
            String   sLine = dt.Year.ToString() + "/" + dt.Month.ToString().PadLeft(2, '0') + "/" + dt.Day.ToString().PadLeft(2, '0')
                             + "\t" + dt.Hour.ToString().PadLeft(2, '0') + ":" + dt.Minute.ToString().PadLeft(2, '0') + ":" + dt.Second.ToString().PadLeft(2, '0')
                             + "\t" + eOrigine.ToString()
                             + "\t" + ePriorite.ToString()
                             + "\t" + sMsg;

            if (m_sLogFileDefined)
            {
                m_sw.WriteLine(sLine);
                m_sw.Flush();
            }
            // TODO : vérifier que le destructeur de StreamWriter ferme le fichier
        }
 /// <summary>
 /// Tests whether this edge has the given orig and dest vertices.
 /// </summary>
 /// <param name="p0">the origin vertex to test</param>
 /// <param name="p1">the destination vertex to test</param>
 /// <returns><c>true</c> if the vertices are equal to the ones of this edge</returns>
 public bool Equals(Coordinate p0, Coordinate p1)
 {
     return(Orig.Equals2D(p0) && Sym.Orig.Equals(p1));
 }
Ejemplo n.º 4
0
        protected override AstNode?Before(AstNode node, bool inList)
        {
            if (node is AstBinary astBinary)
            {
                DescendBinaryOrVar();

                if (astBinary.Right == Remove)
                {
                    return(astBinary.Left); // TODO tree transformer which remove alone symbol refs
                }

                return(astBinary);
            }

            if (node is AstVar astVar)
            {
                DescendBinaryOrVar();

                var defsToRemove = astVar.Definitions.Where(astVarDef => astVarDef.Value == Remove).ToList();

                foreach (var astVarDef in defsToRemove)
                {
                    astVar.Definitions.RemoveItem(astVarDef);
                }

                if (astVar.Definitions.Count == 0)
                {
                    return(inList ? Remove : new AstEmptyStatement());
                }

                return(astVar);
            }

            if (node is AstScope)
            {
                var       parent    = Parent();
                SymbolDef?symbolDef = null;
                if (parent is AstBinary)
                {
                    if (parent is AstAssign astAssign && astAssign.Left is AstSymbolRef symbolRef)
                    {
                        symbolDef = symbolRef.Thedef;
                        if (symbolDef !.Global && symbolDef !.Orig.Where(x => x is AstSymbolDeclaration).ToList().Count == 0)
                        {
                            return(node);
                        }
                    }
                    else
                    {
                        return(node);
                    }
                }

                if (parent is AstVarDef astVarDef)
                {
                    if (astVarDef.Name is AstSymbol symbol)
                    {
                        symbolDef = symbol.Thedef;
                    }
                    else
                    {
                        return(node);
                    }
                }

                if (node is AstLambda astLambda && (inList || _isInBinaryOrVar))
                {
                    if (symbolDef == null && astLambda.Name == null)
                    {
                        return(node);
                    }

                    if (symbolDef == null)
                    {
                        symbolDef = astLambda.Name !.Thedef !;
                    }

                    var canBeRemoved       = true;
                    var shouldPreserveName = false;
                    var definitionScope    = symbolDef.Scope;
                    foreach (var reference in symbolDef.References)
                    {
                        // Referenced in same scope as defined and used differently than writing
                        if (reference.Scope == definitionScope)
                        {
                            if (reference.Usage != SymbolUsage.Write)
                            {
                                canBeRemoved = false;
                                break;
                            }

                            shouldPreserveName = true;
                        }

                        // Used in scope which is not defined by this function
                        if (reference.Scope != definitionScope && !astLambda.IsParentScopeFor(reference.Scope))
                        {
                            canBeRemoved = false;
                            break;
                        }
                    }

                    if (canBeRemoved)
                    {
                        ShouldIterateAgain = true;
                        if (shouldPreserveName && !_isInBinaryOrVar)
                        {
                            var varDefs = new StructList <AstVarDef>();
                            varDefs.Add(new AstVarDef(new AstSymbolVar(symbolDef.Name)));
                            return(new AstVar(ref varDefs));
                        }
                        return(Remove);
                    }
                }

                Descend();
                return(node);
            }
Ejemplo n.º 5
0
 public static void Log(String sMsg, Prio ePriorite, Orig eOrigine)
 {
     Log(sMsg, ePriorite, eOrigine, false);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Iss != null)
         {
             hashCode = hashCode * 59 + Iss.GetHashCode();
         }
         if (Sub != null)
         {
             hashCode = hashCode * 59 + Sub.GetHashCode();
         }
         if (Aud != null)
         {
             hashCode = hashCode * 59 + Aud.GetHashCode();
         }
         if (Exp != null)
         {
             hashCode = hashCode * 59 + Exp.GetHashCode();
         }
         if (Nbf != null)
         {
             hashCode = hashCode * 59 + Nbf.GetHashCode();
         }
         if (Iat != null)
         {
             hashCode = hashCode * 59 + Iat.GetHashCode();
         }
         if (Jti != null)
         {
             hashCode = hashCode * 59 + Jti.GetHashCode();
         }
         if (Uuid != null)
         {
             hashCode = hashCode * 59 + Uuid.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (GivenName != null)
         {
             hashCode = hashCode * 59 + GivenName.GetHashCode();
         }
         if (Nickname != null)
         {
             hashCode = hashCode * 59 + Nickname.GetHashCode();
         }
         if (Email != null)
         {
             hashCode = hashCode * 59 + Email.GetHashCode();
         }
         if (EmailVerified != null)
         {
             hashCode = hashCode * 59 + EmailVerified.GetHashCode();
         }
         if (Zoneinfo != null)
         {
             hashCode = hashCode * 59 + Zoneinfo.GetHashCode();
         }
         if (Locale != null)
         {
             hashCode = hashCode * 59 + Locale.GetHashCode();
         }
         if (Cnf != null)
         {
             hashCode = hashCode * 59 + Cnf.GetHashCode();
         }
         if (Orig != null)
         {
             hashCode = hashCode * 59 + Orig.GetHashCode();
         }
         if (Dest != null)
         {
             hashCode = hashCode * 59 + Dest.GetHashCode();
         }
         if (Mky != null)
         {
             hashCode = hashCode * 59 + Mky.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns true if JWToken instances are equal
        /// </summary>
        /// <param name="other">Instance of JWToken to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(JWToken other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Iss == other.Iss ||
                     Iss != null &&
                     Iss.Equals(other.Iss)
                     ) &&
                 (
                     Sub == other.Sub ||
                     Sub != null &&
                     Sub.Equals(other.Sub)
                 ) &&
                 (
                     Aud == other.Aud ||
                     Aud != null &&
                     Aud.Equals(other.Aud)
                 ) &&
                 (
                     Exp == other.Exp ||
                     Exp != null &&
                     Exp.Equals(other.Exp)
                 ) &&
                 (
                     Nbf == other.Nbf ||
                     Nbf != null &&
                     Nbf.Equals(other.Nbf)
                 ) &&
                 (
                     Iat == other.Iat ||
                     Iat != null &&
                     Iat.Equals(other.Iat)
                 ) &&
                 (
                     Jti == other.Jti ||
                     Jti != null &&
                     Jti.Equals(other.Jti)
                 ) &&
                 (
                     Uuid == other.Uuid ||
                     Uuid != null &&
                     Uuid.Equals(other.Uuid)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     GivenName == other.GivenName ||
                     GivenName != null &&
                     GivenName.Equals(other.GivenName)
                 ) &&
                 (
                     Nickname == other.Nickname ||
                     Nickname != null &&
                     Nickname.Equals(other.Nickname)
                 ) &&
                 (
                     Email == other.Email ||
                     Email != null &&
                     Email.Equals(other.Email)
                 ) &&
                 (
                     EmailVerified == other.EmailVerified ||
                     EmailVerified != null &&
                     EmailVerified.Equals(other.EmailVerified)
                 ) &&
                 (
                     Zoneinfo == other.Zoneinfo ||
                     Zoneinfo != null &&
                     Zoneinfo.Equals(other.Zoneinfo)
                 ) &&
                 (
                     Locale == other.Locale ||
                     Locale != null &&
                     Locale.Equals(other.Locale)
                 ) &&
                 (
                     Cnf == other.Cnf ||
                     Cnf != null &&
                     Cnf.Equals(other.Cnf)
                 ) &&
                 (
                     Orig == other.Orig ||
                     Orig != null &&
                     Orig.Equals(other.Orig)
                 ) &&
                 (
                     Dest == other.Dest ||
                     Dest != null &&
                     Dest.Equals(other.Dest)
                 ) &&
                 (
                     Mky == other.Mky ||
                     Mky != null &&
                     Mky.Equals(other.Mky)
                 ));
        }