public override int GetHashCode() { int hashCode = -590270970; hashCode = hashCode * -1521134295 + Id.GetHashCode(); hashCode = hashCode * -1521134295 + LabBookId.GetHashCode(); hashCode = hashCode * -1521134295 + Created.GetHashCode(); hashCode = hashCode * -1521134295 + Updated.GetHashCode(); hashCode = hashCode * -1521134295 + pH.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Type); hashCode = hashCode * -1521134295 + Brook1.GetHashCode(); hashCode = hashCode * -1521134295 + Brook5.GetHashCode(); hashCode = hashCode * -1521134295 + Brook10.GetHashCode(); hashCode = hashCode * -1521134295 + Brook20.GetHashCode(); hashCode = hashCode * -1521134295 + Brook30.GetHashCode(); hashCode = hashCode * -1521134295 + Brook40.GetHashCode(); hashCode = hashCode * -1521134295 + Brook50.GetHashCode(); hashCode = hashCode * -1521134295 + Brook60.GetHashCode(); hashCode = hashCode * -1521134295 + Brook70.GetHashCode(); hashCode = hashCode * -1521134295 + Brook80.GetHashCode(); hashCode = hashCode * -1521134295 + Brook90.GetHashCode(); hashCode = hashCode * -1521134295 + Brook100.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(BrookComment); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(BrookDisc); hashCode = hashCode * -1521134295 + BrookXvisc.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(BrookXrpm); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(BrookXdisc); hashCode = hashCode * -1521134295 + Krebs.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(KrebsComment); hashCode = hashCode * -1521134295 + ICI.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ICIdisc); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ICIcomment); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Temperature); return(hashCode); }
internal static bool OfHasNormalArgs(LNode n, bool nameDefinition, Pedantics p) { if (!CallsMinWPAIH(n, S.Of, 1, p)) { return(false); } ICI childFlags = ICI.InOf; if (nameDefinition) { childFlags = (childFlags | ICI.NameDefinition | ICI.DisallowDotted | ICI.DisallowOf); } for (int i = 1; i < n.ArgCount; i++) { if (!IsComplexIdentifier(n.Args[i], childFlags, p)) { return(false); } } return(true); }
/// <summary>Returns true if `n` is a potential type name.</summary> /// <param name="n"></param> /// <param name="f"></param> /// <param name="p"></param> /// <returns></returns> public static bool IsComplexIdentifier(LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax) { // // To be printable, a complex identifier in EC# must not contain // attributes ((p & Pedantics.DropNonDeclAttrs) != 0 to override) and must be // 1. A simple symbol // 2. A substitution expression // 3. An 'of' expression a<b,...>, where 'a' is (1) or (2), and each arg 'b' // is a complex identifier (if printing in C# style), and there is at // least one type parameter. If b is @'tuple, then later arguments can be // #var expressions (see code for details). // 4. A dotted expression (a.b), where 'a' is a complex identifier and 'b' // is (1), (2) or (3); structures like @`'.`(a, b, c) and @`'.`(a, b.c) // do not count as complex identifiers. Note that a.b<c> is // structured @`'.`(a, @'of(b, c)), not #of(@`'.`(a, b), c). A dotted // expression that starts with a dot, such as .a.b, is structured // (.a).b rather than .(a.b), as unary . has precedence as high as $. // 5. A scope-resolution expression (a::b), where 'a' is (1) or (2) and // 'b' does not contain another scope-resolution operator. // // Type names have the same structure, with the following patterns for // arrays, pointers, nullables, and tuples: // // Foo* <=> @'of(@*, Foo) // Foo[] <=> @'of(@`[]`, Foo) // Foo[,] <=> @'of(#`[,]`, Foo) // Foo? <=> @'of(@?, Foo) // (A, B) <=> @'of(@'tuple, A, B) // (A a, B b)<=> @'of(@'tuple, #var(A, a), #var(B, b)) // // Note that we can't just use @'of(Nullable, Foo) for Foo? because it // doesn't work if System is not imported. It's reasonable to allow '? // instead of global::System.Nullable, since we have special symbols // for types like #int32 anyway. // // (a.b<c>.d<e>.f is structured a.(b<c>).(d<e>).f or @`'.`(@`'.`(@`'.`(a, @'of(b, c)), @'of(d, e)), f). if ((f & ICI.AllowAttrs) == 0 && ((f & ICI.AllowParensAround) != 0 ? HasPAttrs(n, p) : HasPAttrsOrParens(n, p))) { // Attribute(s) are illegal, except 'in', 'out' and 'where' when // TypeParamDefinition inside <...> return((f & (ICI.NameDefinition | ICI.InOf)) == (ICI.NameDefinition | ICI.InOf) && IsPrintableTypeParam(n)); } if (n.IsId) { return(true); } if (CallsWPAIH(n, S.Substitute, 1, p)) { return(true); } if (CallsWPAIH(n, S.CsRawText, 1, p) && n[0].IsLiteral) { return(true); } var args = n.Args; if (CallsMinWPAIH(n, S.Of, 2, p)) { var baseName = args[0]; if (!IsSimpleIdentifier(baseName, p)) { return(false); } if ((f & ICI.AllowAnyExprInOf) != 0) { return(true); } ICI childFlags = ICI.InOf; if ((f & ICI.NameDefinition) != 0) { childFlags = (childFlags | ICI.NameDefinition | ICI.DisallowDotted); } for (int i = 1; i < n.ArgCount; i++) { var childArg = n.Args[i]; if (!IsComplexIdentifier(childArg, childFlags, p)) { if (baseName.IsIdNamed(S.Tuple) && (childFlags & ICI.NameDefinition) == 0) { // If part of a tuple type isn't a valid complex Id, // it must be an unassigned variable declaration if (childArg.Calls(S.Var, 2) && IsComplexIdentifier(childArg.Args[0], childFlags, p) && IsSimpleIdentifier(childArg.Args[1], p)) { continue; } } return(false); } } return(true); } if (CallsWPAIH(n, S.Dot, 2, p) && (f & ICI.DisallowDotted) == 0) { // right-hand argument must be simple or be an "of<expression>" if (!IsComplexIdentifier(args.Last, ICI.DisallowDotted | ICI.DisallowColonColon, p)) { return(false); } return(IsComplexIdentifier(args[0], ICI.Default, p)); } if (CallsWPAIH(n, S.ColonColon, 2, p) && (f & ICI.DisallowColonColon) == 0) { // left-hand argument must be simple if (!IsSimpleIdentifier(args[0], p)) { return(false); } return(IsComplexIdentifier(args.Last, ICI.DisallowColonColon, p)); } return(false); }
public static bool IsComplexIdentifier(LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax) { // Returns true if 'n' is printable as a complex identifier. // // To be printable, a complex identifier in EC# must not contain // attributes ((p & Pedantics.DropNonDeclAttrs) != 0 to override) and must be // 1. A simple symbol // 2. A substitution expression // 3. A dotted expr (a.b), where 'a' is a complex identifier and 'b' // is (1) or (2); structures like #.(a, b, c) and #.(a, b<c>) do // not count as complex identifiers. Note that a.b<c> is // structured #of(#.(a, b), c), not #.(a, #of(b, c)). A dotted // expression that starts with a dot, such as .a.b, is structured // (.a).b rather than .(a.b); unary . has high precedence. // 4. An #of expr a<b,...>, where // - 'a' is a complex identifier and not itself an #of expr // - each arg 'b' is a complex identifier (if printing in C# style) // // Type names have the same structure, with the following patterns for // arrays, pointers, nullables and typeof<>: // // Foo* <=> #of(@*, Foo) // Foo[] <=> #of(@`[]`, Foo) // Foo[,] <=> #of(#`[,]`, Foo) // Foo? <=> #of(@?, Foo) // typeof<X> <=> #of(#typeof, X) // // Note that we can't just use #of(Nullable, Foo) for Foo? because it // doesn't work if System is not imported. It's reasonable to allow #? // as a synonym for global::System.Nullable, since we have special // symbols for types like #int32 anyway. // // (a.b<c>.d<e>.f is structured ((((a.b)<c>).d)<e>).f or #.(#of(#.(#of(#.(a,b), c), d), e), f) if ((f & ICI.AllowAttrs) == 0 && ((f & ICI.AllowParensAround) != 0 ? HasPAttrs(n, p) : HasPAttrsOrParens(n, p))) { // Attribute(s) are illegal, except 'in', 'out' and 'where' when // TypeParamDefinition inside <...> return((f & (ICI.NameDefinition | ICI.InOf)) == (ICI.NameDefinition | ICI.InOf) && IsPrintableTypeParam(n)); } if (n.IsId) { return(true); } if (CallsWPAIH(n, S.Substitute, 1, p)) { return(true); } if (CallsMinWPAIH(n, S.Of, 1, p) && (f & ICI.DisallowOf) == 0) { var baseName = n.Args[0]; if (!IsComplexIdentifier(baseName, (f & (ICI.DisallowDotted)) | ICI.DisallowOf, p)) { return(false); } if ((f & ICI.AllowAnyExprInOf) != 0) { return(true); } return(OfHasNormalArgs(n, (f & ICI.NameDefinition) != 0, p)); } if (CallsWPAIH(n, S.Dot, p) && (f & ICI.DisallowDotted) == 0 && Range.IsInRange(n.ArgCount, 1, 2)) { var args = n.Args; LNode lhs = args[0], rhs = args.Last; // right-hand argument must be simple var rhsFlags = (f & ICI.ExprMode) | ICI.DisallowOf | ICI.DisallowDotted; if ((f & ICI.ExprMode) != 0) { rhsFlags |= ICI.AllowParensAround; } if (!IsComplexIdentifier(args.Last, rhsFlags, p)) { return(false); } if ((f & ICI.ExprMode) != 0 && lhs.IsParenthesizedExpr() || (lhs.IsCall && !lhs.Calls(S.Dot) && !lhs.Calls(S.Of))) { return(true); } return(IsComplexIdentifier(args[0], (f & ICI.ExprMode), p)); } return(false); }
public static bool IsComplexIdentifier(LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax) { // Returns true if 'n' is printable as a complex identifier. // // To be printable, a complex identifier in EC# must not contain // attributes ((p & Pedantics.DropNonDeclAttrs) != 0 to override) and must be // 1. A simple symbol // 2. A substitution expression // 3. An #of expr a<b,...>, where 'a' is (1) or (2) and each arg 'b' is a // complex identifier (if printing in C# style) // 3. A dotted expr (a.b), where 'a' is a complex identifier and 'b' // is (1), (2) or (3); structures like @`'.`(a, b, c) and @`'.`(a, b.c) // do not count as complex identifiers. Note that a.b<c> is // structured @`'.`(a, #of(b, c)), not #of(@`'.`(a, b), c). A dotted // expression that starts with a dot, such as .a.b, is structured // (.a).b rather than .(a.b), as unary . has precedence as high as $. // // Type names have the same structure, with the following patterns for // arrays, pointers, nullables and typeof<>: // // Foo* <=> #of(@*, Foo) // Foo[] <=> #of(@`[]`, Foo) // Foo[,] <=> #of(#`[,]`, Foo) // Foo? <=> #of(@?, Foo) // // Note that we can't just use #of(Nullable, Foo) for Foo? because it // doesn't work if System is not imported. It's reasonable to allow '? // instead of global::System.Nullable, since we have special symbols // for types like #int32 anyway. // // (a.b<c>.d<e>.f is structured a.(b<c>).(d<e>).f or @`'.`(@`'.`(@`'.`(a, #of(b, c)), #of(d, e)), f). if ((f & ICI.AllowAttrs) == 0 && ((f & ICI.AllowParensAround) != 0 ? HasPAttrs(n, p) : HasPAttrsOrParens(n, p))) { // Attribute(s) are illegal, except 'in', 'out' and 'where' when // TypeParamDefinition inside <...> return (f & (ICI.NameDefinition | ICI.InOf)) == (ICI.NameDefinition | ICI.InOf) && IsPrintableTypeParam(n); } if (n.IsId) return true; if (CallsWPAIH(n, S.Substitute, 1, p)) return true; var args = n.Args; if (CallsMinWPAIH(n, S.Of, 1, p)) { var baseName = args[0]; if (!IsSimpleIdentifier(baseName, p)) return false; if ((f & ICI.AllowAnyExprInOf) != 0) return true; ICI childFlags = ICI.InOf; if ((f & ICI.NameDefinition) != 0) childFlags = (childFlags | ICI.NameDefinition | ICI.DisallowDotted); for (int i = 1; i < n.ArgCount; i++) if (!IsComplexIdentifier(n.Args[i], childFlags, p)) return false; return true; } if (CallsWPAIH(n, S.Dot, p) && n.ArgCount == 2 && (f & ICI.DisallowDotted) == 0) { LNode lhs = args[0], rhs = args.Last; // right-hand argument must be simple var rhsFlags = ICI.DisallowDotted; if (!IsComplexIdentifier(args.Last, rhsFlags, p)) return false; return IsComplexIdentifier(args[0], ICI.Default, p); } return false; }
public static bool IsComplexIdentifier(LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax) { // Returns true if 'n' is printable as a complex identifier. // // To be printable, a complex identifier in EC# must not contain // attributes ((p & Pedantics.DropNonDeclAttrs) != 0 to override) and must be // 1. A simple symbol // 2. A substitution expression // 3. An #of expr a<b,...>, where 'a' is (1) or (2) and each arg 'b' is a // complex identifier (if printing in C# style) // 3. A dotted expr (a.b), where 'a' is a complex identifier and 'b' // is (1), (2) or (3); structures like @`'.`(a, b, c) and @`'.`(a, b.c) // do not count as complex identifiers. Note that a.b<c> is // structured @`'.`(a, #of(b, c)), not #of(@`'.`(a, b), c). A dotted // expression that starts with a dot, such as .a.b, is structured // (.a).b rather than .(a.b), as unary . has precedence as high as $. // // Type names have the same structure, with the following patterns for // arrays, pointers, nullables and typeof<>: // // Foo* <=> #of(@*, Foo) // Foo[] <=> #of(@`[]`, Foo) // Foo[,] <=> #of(#`[,]`, Foo) // Foo? <=> #of(@?, Foo) // // Note that we can't just use #of(Nullable, Foo) for Foo? because it // doesn't work if System is not imported. It's reasonable to allow '? // instead of global::System.Nullable, since we have special symbols // for types like #int32 anyway. // // (a.b<c>.d<e>.f is structured a.(b<c>).(d<e>).f or @`'.`(@`'.`(@`'.`(a, #of(b, c)), #of(d, e)), f). if ((f & ICI.AllowAttrs) == 0 && ((f & ICI.AllowParensAround) != 0 ? HasPAttrs(n, p) : HasPAttrsOrParens(n, p))) { // Attribute(s) are illegal, except 'in', 'out' and 'where' when // TypeParamDefinition inside <...> return((f & (ICI.NameDefinition | ICI.InOf)) == (ICI.NameDefinition | ICI.InOf) && IsPrintableTypeParam(n)); } if (n.IsId) { return(true); } if (CallsWPAIH(n, S.Substitute, 1, p)) { return(true); } var args = n.Args; if (CallsMinWPAIH(n, S.Of, 1, p)) { var baseName = args[0]; if (!IsSimpleIdentifier(baseName, p)) { return(false); } if ((f & ICI.AllowAnyExprInOf) != 0) { return(true); } ICI childFlags = ICI.InOf; if ((f & ICI.NameDefinition) != 0) { childFlags = (childFlags | ICI.NameDefinition | ICI.DisallowDotted); } for (int i = 1; i < n.ArgCount; i++) { if (!IsComplexIdentifier(n.Args[i], childFlags, p)) { return(false); } } return(true); } if (CallsWPAIH(n, S.Dot, p) && n.ArgCount == 2 && (f & ICI.DisallowDotted) == 0) { LNode lhs = args[0], rhs = args.Last; // right-hand argument must be simple var rhsFlags = ICI.DisallowDotted; if (!IsComplexIdentifier(args.Last, rhsFlags, p)) { return(false); } return(IsComplexIdentifier(args[0], ICI.Default, p)); } return(false); }
public static bool IsComplexIdentifier(LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax) { // Returns true if 'n' is printable as a complex identifier. // // To be printable, a complex identifier in EC# must not contain // attributes ((p & Pedantics.DropNonDeclAttrs) != 0 to override) and must be // 1. A simple symbol // 2. A substitution expression // 3. A dotted expr (a.b), where 'a' is a complex identifier and 'b' // is (1) or (2); structures like #.(a, b, c) and #.(a, b<c>) do // not count as complex identifiers. Note that a.b<c> is // structured #of(#.(a, b), c), not #.(a, #of(b, c)). A dotted // expression that starts with a dot, such as .a.b, is structured // (.a).b rather than .(a.b); unary . has high precedence. // 4. An #of expr a<b,...>, where // - 'a' is a complex identifier and not itself an #of expr // - each arg 'b' is a complex identifier (if printing in C# style) // // Type names have the same structure, with the following patterns for // arrays, pointers, nullables and typeof<>: // // Foo* <=> #of(@*, Foo) // Foo[] <=> #of(@`[]`, Foo) // Foo[,] <=> #of(#`[,]`, Foo) // Foo? <=> #of(@?, Foo) // typeof<X> <=> #of(#typeof, X) // // Note that we can't just use #of(Nullable, Foo) for Foo? because it // doesn't work if System is not imported. It's reasonable to allow #? // as a synonym for global::System.Nullable, since we have special // symbols for types like #int32 anyway. // // (a.b<c>.d<e>.f is structured ((((a.b)<c>).d)<e>).f or #.(#of(#.(#of(#.(a,b), c), d), e), f) if ((f & ICI.AllowAttrs) == 0 && ((f & ICI.AllowParensAround) != 0 ? HasPAttrs(n, p) : HasPAttrsOrParens(n, p))) { // Attribute(s) are illegal, except 'in', 'out' and 'where' when // TypeParamDefinition inside <...> return (f & (ICI.NameDefinition | ICI.InOf)) == (ICI.NameDefinition | ICI.InOf) && IsPrintableTypeParam(n); } if (n.IsId) return true; if (CallsWPAIH(n, S.Substitute, 1, p)) return true; if (CallsMinWPAIH(n, S.Of, 1, p) && (f & ICI.DisallowOf) == 0) { var baseName = n.Args[0]; if (!IsComplexIdentifier(baseName, (f & (ICI.DisallowDotted)) | ICI.DisallowOf, p)) return false; if ((f & ICI.AllowAnyExprInOf) != 0) return true; return OfHasNormalArgs(n, (f & ICI.NameDefinition) != 0, p); } if (CallsWPAIH(n, S.Dot, p) && (f & ICI.DisallowDotted) == 0 && Range.IsInRange(n.ArgCount, 1, 2)) { var args = n.Args; LNode lhs = args[0], rhs = args.Last; // right-hand argument must be simple var rhsFlags = (f & ICI.ExprMode) | ICI.DisallowOf | ICI.DisallowDotted; if ((f & ICI.ExprMode) != 0) rhsFlags |= ICI.AllowParensAround; if (!IsComplexIdentifier(args.Last, rhsFlags, p)) return false; if ((f & ICI.ExprMode) != 0 && lhs.IsParenthesizedExpr() || (lhs.IsCall && !lhs.Calls(S.Dot) && !lhs.Calls(S.Of))) return true; return IsComplexIdentifier(args[0], (f & ICI.ExprMode), p); } return false; }