public static SemanticContext And(SemanticContext a, SemanticContext b) { //System.Console.Out.WriteLine( "AND: " + a + "&&" + b ); if (a == EmptySemanticContext || a == null) { return(b); } if (b == EmptySemanticContext || b == null) { return(a); } if (a.Equals(b)) { return(a); // if same, just return left one } //System.Console.Out.WriteLine( "## have to AND" ); return(new AND(a, b)); }
public override bool Equals(object o) { if (o == null) { return(false); } if (object.ReferenceEquals(this, o)) { return(true); // equals if same object } PredicateLabel pl = o as PredicateLabel; if (pl == null) { return(false); } return(_semanticContext.Equals(pl.SemanticContext)); }
public static SemanticContext Or(SemanticContext a, SemanticContext b) { //System.Console.Out.WriteLine( "OR: " + a + "||" + b ); if (a == EmptySemanticContext || a == null) { return(b); } if (b == EmptySemanticContext || b == null) { return(a); } if (a is TruePredicate) { return(a); } if (b is TruePredicate) { return(b); } if (a is NOT && b is Predicate) { NOT n = (NOT)a; // check for !p||p if (n.ctx.Equals(b)) { return(new TruePredicate()); } } else if (b is NOT && a is Predicate) { NOT n = (NOT)b; // check for p||!p if (n.ctx.Equals(a)) { return(new TruePredicate()); } } else if (a.Equals(b)) { return(a); } //System.Console.Out.WriteLine( "## have to OR" ); return(new OR(a, b)); }
public static SemanticContext Or(SemanticContext a, SemanticContext b) { //System.Console.Out.WriteLine( "OR: " + a + "||" + b ); if ( a == EmptySemanticContext || a == null ) { return b; } if ( b == EmptySemanticContext || b == null ) { return a; } if ( a is TruePredicate ) { return a; } if ( b is TruePredicate ) { return b; } if ( a is NOT && b is Predicate ) { NOT n = (NOT)a; // check for !p||p if ( n.ctx.Equals( b ) ) { return new TruePredicate(); } } else if ( b is NOT && a is Predicate ) { NOT n = (NOT)b; // check for p||!p if ( n.ctx.Equals( a ) ) { return new TruePredicate(); } } else if ( a.Equals( b ) ) { return a; } //System.Console.Out.WriteLine( "## have to OR" ); return new OR( a, b ); }
public static SemanticContext And(SemanticContext a, SemanticContext b) { //System.Console.Out.WriteLine( "AND: " + a + "&&" + b ); if ( a == EmptySemanticContext || a == null ) { return b; } if ( b == EmptySemanticContext || b == null ) { return a; } if ( a.Equals( b ) ) { return a; // if same, just return left one } //System.Console.Out.WriteLine( "## have to AND" ); return new AND( a, b ); }