public virtual UnaryExpression Update(UnaryExpression u, Expression operand, UnaryExpressionType unaryExpressionType) { if (u.Expression != operand || u.Type != unaryExpressionType) { return new UnaryExpression(unaryExpressionType, operand); } return u; }
/// <summary> /// Initializes a new instance of the UnaryExpression class. /// </summary> /// <param name="proxy">Proxy object for the expression.</param> /// <param name="type">The type of operation being performed.</param> /// <param name="value">The value the operator is being applied to.</param> internal UnaryExpression(CodeUnitProxy proxy, UnaryExpressionType type, Expression value) : base(proxy, (int)type) { Param.AssertNotNull(proxy, "proxy"); Param.Ignore(type); Param.AssertNotNull(value, "value"); CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(UnaryExpressionType), this.UnaryExpressionType), "The type is invalid."); this.value.Value = value; }
/// <summary> /// Initializes a new instance of the UnaryExpression class. /// </summary> /// <param name="proxy">Proxy object for the expression.</param> /// <param name="type">The type of operation being performed.</param> /// <param name="value">The value the operator is being applied to.</param> internal UnaryExpression(CodeUnitProxy proxy, UnaryExpressionType type, Expression value) : base(proxy, (int)type) { Param.AssertNotNull(proxy, "proxy"); Param.Ignore(type); Param.AssertNotNull(value, "value"); CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(UnaryExpressionType), this.UnaryExpressionType), "The type is invalid."); this.value.Value = value; }
internal static gsUnaryType ToUnaryType(this UnaryExpressionType unaryExpressionType) { switch (unaryExpressionType) { case UnaryExpressionType.Positive: return(gsUnaryType.Positive); case UnaryExpressionType.Negative: return(gsUnaryType.Negative); default: throw new NotImplementedException($"UnaryExpressionType {unaryExpressionType} not supported"); } }
public static string UnaryExpressionType(UnaryExpressionType type) { switch (type) { case Microsoft.SqlServer.TransactSql.ScriptDom.UnaryExpressionType.Positive: return("+"); case Microsoft.SqlServer.TransactSql.ScriptDom.UnaryExpressionType.Negative: return("-"); case Microsoft.SqlServer.TransactSql.ScriptDom.UnaryExpressionType.BitwiseNot: return("~"); default: throw new GraphViewException("Invalid unary expression type."); } }
public static string UnaryExpressionType(UnaryExpressionType type) { switch (type) { case GraphView.UnaryExpressionType.Positive: return("+"); case GraphView.UnaryExpressionType.Negative: return("-"); case GraphView.UnaryExpressionType.BitwiseNot: return("~"); default: throw new GraphViewException("Invalid unary expression type."); } }
private static Type AnalysisType(UnaryExpressionType expressionType, AstExpression body) { switch (expressionType) { case UnaryExpressionType.UnaryPlus: case UnaryExpressionType.Increment: case UnaryExpressionType.Decrement: if (IsArithmetic(body.RuntimeType)) { return(body.RuntimeType); } break; case UnaryExpressionType.Negate: if (IsArithmetic(body.RuntimeType) && !IsUnsignedInt(body.RuntimeType)) { return(body.RuntimeType); } break; case UnaryExpressionType.Not: if (IsIntegerOrBool(body.RuntimeType)) { return(body.RuntimeType); } break; case UnaryExpressionType.IsFalse: if (body.RuntimeType == typeof(bool)) { return(body.RuntimeType); } break; case UnaryExpressionType.IncrementAssign: case UnaryExpressionType.DecrementAssign: if (!body.CanWrite) { throw new AstException("表达式不可写!"); } goto case UnaryExpressionType.Increment; } throw new InvalidOperationException($"“{body.RuntimeType}”不支持“{expressionType}”一元操作!"); }
/// <summary> /// Get unary operator string by unary expression type /// </summary> /// <param name="type">The unary expression type</param> /// <returns>The unary operator string</returns> protected static string GetUnaryOperatorString(UnaryExpressionType type) { switch (type) { case UnaryExpressionType.Not: return("!"); case UnaryExpressionType.BitNot: return("~"); case UnaryExpressionType.Negative: return("-"); case UnaryExpressionType.Positive: return("+"); case UnaryExpressionType.Dereference: return("*"); default: throw new ExpressionEvaluatorException("unknown unary operator"); } }
public UnaryExpression(UnaryExpressionType type, LogicalExpression expression) { Type = type; Expression = expression; }
public static string UnaryExpressionType(UnaryExpressionType type) { switch (type) { case Microsoft.SqlServer.TransactSql.ScriptDom.UnaryExpressionType.Positive: return "+"; case Microsoft.SqlServer.TransactSql.ScriptDom.UnaryExpressionType.Negative: return "-"; case Microsoft.SqlServer.TransactSql.ScriptDom.UnaryExpressionType.BitwiseNot: return "~"; default: throw new GraphViewException("Invalid unary expression type."); } }
public UnaryExpression(UnaryExpressionType type, LogicalExpression expression) { Type = type; Expression = expression; }
/// <summary> /// 一元运算。 /// </summary> /// <param name="expressionType">一元运算类型。</param> /// <param name="body">表达式。</param> public UnaryAst(AstExpression body, UnaryExpressionType expressionType) : base(AnalysisType(expressionType, body)) { this.expressionType = expressionType; this.body = body; }
private UnaryAst(UnaryAst unaryAst) : base(unaryAst.RuntimeType) { expressionType = unaryAst.expressionType - 1; body = unaryAst.body; }
/// <summary> /// Constructor /// </summary> /// <param name="type">Expression type</param> /// <param name="expression">The expression</param> public UnaryExpression(UnaryExpressionType type, IExpression expression) { this.type = type; this.expression = expression; }
internal UnaryExpression(UnaryExpressionType type, IExpression expression) { _expressionType = type; _expression = expression; }
public static object Evaluate(UnaryExpressionType op, object value) => op switch {
/// <summary> /// Get unary operator string by unary expression type /// </summary> /// <param name="type">The unary expression type</param> /// <returns>The unary operator string</returns> protected static string GetUnaryOperatorString(UnaryExpressionType type) { switch (type) { case UnaryExpressionType.Not: return "!"; case UnaryExpressionType.BitNot: return "~"; case UnaryExpressionType.Negative: return "-"; case UnaryExpressionType.Positive: return "+"; case UnaryExpressionType.Dereference: return "*"; default: throw new ExpressionEvaluatorException("unknown unary operator"); } }
public UnaryExpression(UnaryExpressionType type, Expression expression) { this.type = type; this.expression = expression; }
public DbUnaryExpression(UnaryExpressionType type, Expression operand) : base(type, operand) { }