public static ContOp?reverse(this ContOp match) { switch (match) { case ContOp.IN: return(ContOp.HAS); case ContOp.HAS: return(ContOp.IN); case ContOp.NOT_IN: return(ContOp.NOT_HAS); case ContOp.NOT_HAS: return(ContOp.NOT_IN); default: return(null); } }
private MatchOp getMatchOp(Context context, IType fieldType, IType valueType, ContOp oper, bool reverse) { if (reverse) { ContOp?reversed = oper.reverse(); if (!reversed.HasValue) { throw new SyntaxError("Cannot reverse " + this.oper); } return(getMatchOp(context, valueType, fieldType, reversed.Value, false)); } if ((fieldType == TextType.Instance || valueType == CharacterType.Instance) && (valueType == TextType.Instance || valueType == CharacterType.Instance)) { switch (oper) { case ContOp.HAS: case ContOp.NOT_HAS: return(MatchOp.CONTAINS); } } if (valueType is ContainerType) { switch (oper) { case ContOp.IN: case ContOp.NOT_IN: return(MatchOp.IN); } } if (fieldType is ContainerType) { switch (oper) { case ContOp.HAS: case ContOp.NOT_HAS: return(MatchOp.HAS); } } throw new SyntaxError("Unsupported operator: " + oper.ToString()); }
public ContainsExpression(IExpression left, ContOp oper, IExpression right) { this.left = left; this.oper = oper; this.right = right; }