Skip to content

Commit e0628eb

Browse files
committed
Formatting
1 parent 3e464f8 commit e0628eb

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/Ramstack.ExpressionParser/ExpressionBuilder.Helpers.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,25 +288,25 @@ private static void ApplyBinaryNumericPromotions(Identifier op, ref Expression l
288288
}
289289
}
290290

291-
private static Func<Expression, Expression, Expression> CreateOperatorFactory(string @operator)
291+
private static Func<Expression, Expression, Expression> ResolveBinaryOperatorFactory(string @operator)
292292
{
293293
return @operator switch
294294
{
295295
"??" => Expression.Coalesce,
296-
"||" => Expression.OrElse,
297296
"&&" => Expression.AndAlso,
298-
"|" => Expression.Or,
299-
"^" => Expression.ExclusiveOr,
300-
"&" => Expression.And,
297+
"||" => Expression.OrElse,
301298
"==" => Expression.Equal,
302299
"!=" => Expression.NotEqual,
303300
"<=" => Expression.LessThanOrEqual,
304-
"<" => Expression.LessThan,
305301
">=" => Expression.GreaterThanOrEqual,
306-
">" => Expression.GreaterThan,
307302
">>" => Expression.RightShift,
308-
">>>" => Expression.RightShift,
309303
"<<" => Expression.LeftShift,
304+
">>>" => Expression.RightShift,
305+
"<" => Expression.LessThan,
306+
">" => Expression.GreaterThan,
307+
"&" => Expression.And,
308+
"|" => Expression.Or,
309+
"^" => Expression.ExclusiveOr,
310310
"+" => Expression.Add,
311311
"-" => Expression.Subtract,
312312
"*" => Expression.Multiply,

src/Ramstack.ExpressionParser/ExpressionBuilder.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,38 @@ protected internal override Expression VisitBinary(Expr.Binary expr)
3737
var lhs = Visit(expr.Left);
3838
var rhs = Visit(expr.Right);
3939

40-
var factory = CreateOperatorFactory(expr.Operator.Name);
40+
var lhsType = lhs.Type;
41+
var rhsType = rhs.Type;
4142

42-
var l = lhs;
43-
var r = rhs;
43+
var factory = ResolveBinaryOperatorFactory(expr.Operator.Name);
4444

4545
switch (expr.Operator.Name)
4646
{
4747
case "&&":
4848
case "||":
49-
l = ApplyImplicitConversion(lhs, typeof(bool));
50-
r = ApplyImplicitConversion(rhs, typeof(bool));
49+
lhs = ApplyImplicitConversion(lhs, typeof(bool));
50+
rhs = ApplyImplicitConversion(rhs, typeof(bool));
5151

52-
if (l is null)
53-
Error.MissingImplicitConversion(lhs.Type, typeof(bool));
52+
if (lhs is null)
53+
Error.MissingImplicitConversion(lhsType, typeof(bool));
5454

55-
if (r is null)
56-
Error.MissingImplicitConversion(rhs.Type, typeof(bool));
55+
if (rhs is null)
56+
Error.MissingImplicitConversion(rhsType, typeof(bool));
5757

5858
break;
5959

6060
case "??":
61-
if (lhs.Type.IsValueType && !lhs.Type.IsNullable())
62-
Error.NonApplicableBinaryOperator(expr.Operator, lhs.Type, rhs.Type);
61+
if (lhsType.IsValueType && !lhsType.IsNullable())
62+
Error.NonApplicableBinaryOperator(expr.Operator, lhsType, rhsType);
6363

64-
r = ApplyImplicitConversion(rhs, lhs.Type);
65-
if (r is null)
66-
Error.NonApplicableBinaryOperator(expr.Operator, lhs.Type, rhs.Type);
64+
rhs = ApplyImplicitConversion(rhs, lhsType);
65+
if (rhs is null)
66+
Error.NonApplicableBinaryOperator(expr.Operator, lhsType, rhsType);
6767

6868
break;
6969

7070
case "+":
71-
if (lhs.Type != typeof(string) && rhs.Type != typeof(string))
71+
if (lhsType != typeof(string) && rhsType != typeof(string))
7272
break;
7373

7474
var arguments = new List<Expression>();
@@ -137,11 +137,11 @@ void Flatten(Expression e)
137137

138138
try
139139
{
140-
return ApplyBinaryExpression(expr.Operator, factory, l, r);
140+
return ApplyBinaryExpression(expr.Operator, factory, lhs, rhs);
141141
}
142142
catch (Exception e) when (e is not ParseErrorException)
143143
{
144-
Error.NonApplicableBinaryOperator(expr.Operator, lhs.Type, rhs.Type);
144+
Error.NonApplicableBinaryOperator(expr.Operator, lhsType, rhsType);
145145
}
146146

147147
return null!;

0 commit comments

Comments
 (0)