public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { Visit(expression.Expression); Label loadTrue = _ilEmitContext.ILGenerator.DefineLabel(); Label finishLabel = _ilEmitContext.ILGenerator.DefineLabel(); if (expression.Negated) { _ilEmitContext.ILGenerator.Emit(OpCodes.Brtrue, loadTrue); } else { _ilEmitContext.ILGenerator.Emit(OpCodes.Brfalse, loadTrue); } _ilEmitContext.ILGenerator.Emit(OpCodes.Ldc_I4_0); _ilEmitContext.ILGenerator.Emit(OpCodes.Br, finishLabel); _ilEmitContext.ILGenerator.MarkLabel(loadTrue); _ilEmitContext.ILGenerator.Emit(OpCodes.Ldc_I4_1); _ilEmitContext.ILGenerator.MarkLabel(finishLabel); _ilEmitContext.ILGenerator.Emit(OpCodes.Box, typeof(bool)); return(expression); }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { Visit(expression.Expression); if (_lastExpressionsYieldsNullOrFalse && !expression.Negated) _lastExpressionsYieldsNullOrFalse = false; return expression; }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { Visit(expression.Expression); if (_lastExpressionsYieldsNullOrFalse && !expression.Negated) { _lastExpressionsYieldsNullOrFalse = false; } return(expression); }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { _xmlWriter.WriteStartElement("isNullExpression"); _xmlWriter.WriteAttributeString("negated", XmlConvert.ToString(expression.Negated)); WriteTypeAttribute(expression.ExpressionType); WriteAstNode("expression", expression.Expression); _xmlWriter.WriteEndElement(); return(expression); }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { Visit(expression.Expression); _writer.Write(" IS "); if (expression.Negated) { _writer.Write("NOT "); } _writer.Write("NULL"); return(expression); }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { base.VisitIsNullExpression(expression); ConstantExpression constantExpression = expression.Expression as ConstantExpression; if (constantExpression != null) { if (expression.Negated) { return(LiteralExpression.FromBoolean(constantExpression.GetValue() != null)); } else { return(LiteralExpression.FromBoolean(constantExpression.GetValue() == null)); } } return(expression); }
private static bool VisitIsNullExpression(IsNullExpression node1, IsNullExpression node2) { return node2 != null && node1.Negated == node2.Negated && Visit(node1.Expression, node2.Expression); }
private static bool VisitIsNullExpression(IsNullExpression node1, IsNullExpression node2) { return(node2 != null && node1.Negated == node2.Negated && Visit(node1.Expression, node2.Expression)); }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { Visit(expression.Expression); _writer.Write(" IS "); if (expression.Negated) _writer.Write("NOT "); _writer.Write("NULL"); return expression; }
public void PushIsNull() { ExpressionNode operand = _expressionStack.Pop(); IsNullExpression isNullExpression = new IsNullExpression(false, operand); _expressionStack.Push(isNullExpression); }
public virtual ExpressionNode VisitIsNullExpression(IsNullExpression expression) { expression.Expression = VisitExpression(expression.Expression); return(expression); }
public virtual ExpressionNode VisitIsNullExpression(IsNullExpression expression) { expression.Expression = VisitExpression(expression.Expression); return expression; }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { Visit(expression.Expression); Label loadTrue = _ilEmitContext.ILGenerator.DefineLabel(); Label finishLabel = _ilEmitContext.ILGenerator.DefineLabel(); if (expression.Negated) _ilEmitContext.ILGenerator.Emit(OpCodes.Brtrue, loadTrue); else _ilEmitContext.ILGenerator.Emit(OpCodes.Brfalse, loadTrue); _ilEmitContext.ILGenerator.Emit(OpCodes.Ldc_I4_0); _ilEmitContext.ILGenerator.Emit(OpCodes.Br, finishLabel); _ilEmitContext.ILGenerator.MarkLabel(loadTrue); _ilEmitContext.ILGenerator.Emit(OpCodes.Ldc_I4_1); _ilEmitContext.ILGenerator.MarkLabel(finishLabel); _ilEmitContext.ILGenerator.Emit(OpCodes.Box, typeof(bool)); return expression; }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { base.VisitIsNullExpression(expression); ConstantExpression constantExpression = expression.Expression as ConstantExpression; if (constantExpression != null) { if (expression.Negated) return LiteralExpression.FromBoolean(constantExpression.GetValue() != null); else return LiteralExpression.FromBoolean(constantExpression.GetValue() == null); } return expression; }
public override ExpressionNode VisitUnaryExpression(UnaryExpression expression) { // First visit arguments base.VisitUnaryExpression(expression); if (expression.Op == UnaryOperator.LogicalNot) { // Replace "NOT NOT expr" by "expr" UnaryExpression unOp = expression.Operand as UnaryExpression; if (unOp != null) { if (unOp.Op == UnaryOperator.LogicalNot) { return(VisitExpression(unOp.Operand)); } } // Replace "NOT expr IS NULL" and "NOT expr IS NOT NULL" by // "expr IS NOT NULL" and "expr IS NULL" resp. IsNullExpression isNull = expression.Operand as IsNullExpression; if (isNull != null) { isNull.Negated = !isNull.Negated; return(VisitExpression(isNull)); } // Apply negation on EXISTS ExistsSubselect existsSubselect = expression.Operand as ExistsSubselect; if (existsSubselect != null) { existsSubselect.Negated = !existsSubselect.Negated; return(existsSubselect); } // Apply negation on ALL/ANY subquery AllAnySubselect allAnySubselect = expression.Operand as AllAnySubselect; if (allAnySubselect != null) { allAnySubselect.Op = AstUtil.NegateBinaryOp(allAnySubselect.Op); allAnySubselect.Type = (allAnySubselect.Type == AllAnySubselect.AllAnyType.All) ? AllAnySubselect.AllAnyType.Any : AllAnySubselect.AllAnyType.All; return(allAnySubselect); } // Apply De Morgan's law BinaryExpression binOp = expression.Operand as BinaryExpression; if (binOp != null) { BinaryOperator negatedOp = AstUtil.NegateBinaryOp(binOp.Op); if (negatedOp != null) { ExpressionNode newLeft; ExpressionNode newRight; if (binOp.Op == BinaryOperator.LogicalAnd || binOp.Op == BinaryOperator.LogicalOr) { newLeft = new UnaryExpression(expression.Op, binOp.Left); newRight = new UnaryExpression(expression.Op, binOp.Right); } else { newLeft = binOp.Left; newRight = binOp.Right; } binOp.Op = negatedOp; binOp.Left = newLeft; binOp.Right = newRight; return(VisitExpression(binOp)); } } } return(expression); }
public override ExpressionNode VisitIsNullExpression(IsNullExpression expression) { _xmlWriter.WriteStartElement("isNullExpression"); _xmlWriter.WriteAttributeString("negated", XmlConvert.ToString(expression.Negated)); WriteTypeAttribute(expression.ExpressionType); WriteAstNode("expression", expression.Expression); _xmlWriter.WriteEndElement(); return expression; }