Skip to content

Commit 2b158aa

Browse files
committed
wip: #314 other arithmetic
1 parent 877af00 commit 2b158aa

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

src/FastExpressionCompiler.LightExpression/Expression.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ public static ConditionalExpression IfThenElse(Expression test, Expression ifTru
11501150
public static DefaultExpression Default(Type type) =>
11511151
type == typeof(void) ? VoidDefault : new DefaultExpression(type);
11521152

1153-
public static BinaryExpression GetArithmeticLeftTypedBinary(ExpressionType nodeType, Expression left, Expression right, MethodInfo method = null)
1153+
public static BinaryExpression GetArithmeticBinary(ExpressionType nodeType, Expression left, Expression right, MethodInfo method = null)
11541154
{
11551155
if (method == null)
11561156
{
@@ -1168,17 +1168,17 @@ public static BinaryExpression GetLeftTypedBinary(ExpressionType nodeType, Expre
11681168

11691169
/// <summary>Creates a BinaryExpression that represents an arithmetic addition operation that does not have overflow checking.</summary>
11701170
public static BinaryExpression Add(Expression left, Expression right) =>
1171-
GetArithmeticLeftTypedBinary(ExpressionType.Add, left, right, null);
1171+
GetArithmeticBinary(ExpressionType.Add, left, right, null);
11721172

11731173
public static BinaryExpression Add(Expression left, Expression right, MethodInfo method) =>
1174-
GetArithmeticLeftTypedBinary(ExpressionType.Add, left, right, method);
1174+
GetArithmeticBinary(ExpressionType.Add, left, right, method);
11751175

11761176
/// <summary>Creates a BinaryExpression that represents an arithmetic addition operation that has overflow checking.</summary>
11771177
public static BinaryExpression AddChecked(Expression left, Expression right) =>
1178-
GetArithmeticLeftTypedBinary(ExpressionType.AddChecked, left, right);
1178+
GetArithmeticBinary(ExpressionType.AddChecked, left, right);
11791179

11801180
public static BinaryExpression AddChecked(Expression left, Expression right, MethodInfo method) =>
1181-
GetArithmeticLeftTypedBinary(ExpressionType.AddChecked, left, right, method);
1181+
GetArithmeticBinary(ExpressionType.AddChecked, left, right, method);
11821182

11831183
/// <summary>Creates a BinaryExpression that represents a bitwise XOR operation.</summary>
11841184
public static BinaryExpression ExclusiveOr(Expression left, Expression right) =>
@@ -1194,9 +1194,10 @@ public static BinaryExpression LeftShift(Expression left, Expression right) =>
11941194

11951195
/// <summary>Creates a BinaryExpression that represents an arithmetic remainder operation.</summary>
11961196
public static BinaryExpression Modulo(Expression left, Expression right) =>
1197-
new LeftTypedBinaryExpression(ExpressionType.Modulo, left, right);
1197+
GetArithmeticBinary(ExpressionType.Modulo, left, right);
11981198

1199-
public static BinaryExpression Modulo(Expression left, Expression right, MethodInfo method) => GetLeftTypedBinary(ExpressionType.Modulo, left, right, method);
1199+
public static BinaryExpression Modulo(Expression left, Expression right, MethodInfo method) =>
1200+
GetArithmeticBinary(ExpressionType.Modulo, left, right, method);
12001201

12011202
/// <summary>Creates a BinaryExpression that represents a bitwise right-shift operation.</summary>
12021203
public static BinaryExpression RightShift(Expression left, Expression right) =>
@@ -1206,35 +1207,38 @@ public static BinaryExpression RightShift(Expression left, Expression right) =>
12061207

12071208
/// <summary>Creates a BinaryExpression that represents an arithmetic subtraction operation that does not have overflow checking.</summary>
12081209
public static BinaryExpression Subtract(Expression left, Expression right) =>
1209-
GetArithmeticLeftTypedBinary(ExpressionType.Subtract, left, right);
1210+
GetArithmeticBinary(ExpressionType.Subtract, left, right);
12101211

12111212
public static BinaryExpression Subtract(Expression left, Expression right, MethodInfo method) =>
1212-
GetArithmeticLeftTypedBinary(ExpressionType.Subtract, left, right, method);
1213+
GetArithmeticBinary(ExpressionType.Subtract, left, right, method);
12131214

12141215
/// <summary>Creates a BinaryExpression that represents an arithmetic subtraction operation that has overflow checking.</summary>
12151216
public static BinaryExpression SubtractChecked(Expression left, Expression right) =>
1216-
GetArithmeticLeftTypedBinary(ExpressionType.SubtractChecked, left, right);
1217+
GetArithmeticBinary(ExpressionType.SubtractChecked, left, right);
12171218

12181219
public static BinaryExpression SubtractChecked(Expression left, Expression right, MethodInfo method) =>
1219-
GetArithmeticLeftTypedBinary(ExpressionType.SubtractChecked, left, right, method);
1220+
GetArithmeticBinary(ExpressionType.SubtractChecked, left, right, method);
12201221

12211222
/// <summary>Creates a BinaryExpression that represents an arithmetic multiplication operation that does not have overflow checking.</summary>
12221223
public static BinaryExpression Multiply(Expression left, Expression right) =>
1223-
new LeftTypedBinaryExpression(ExpressionType.Multiply, left, right);
1224+
GetArithmeticBinary(ExpressionType.Multiply, left, right);
12241225

1225-
public static BinaryExpression Multiply(Expression left, Expression right, MethodInfo method) => GetLeftTypedBinary(ExpressionType.Multiply, left, right, method);
1226+
public static BinaryExpression Multiply(Expression left, Expression right, MethodInfo method) =>
1227+
GetArithmeticBinary(ExpressionType.Multiply, left, right, method);
12261228

12271229
/// <summary>Creates a BinaryExpression that represents an arithmetic multiplication operation that has overflow checking.</summary>
12281230
public static BinaryExpression MultiplyChecked(Expression left, Expression right) =>
1229-
new LeftTypedBinaryExpression(ExpressionType.MultiplyChecked, left, right);
1231+
GetArithmeticBinary(ExpressionType.MultiplyChecked, left, right);
12301232

1231-
public static BinaryExpression MultiplyChecked(Expression left, Expression right, MethodInfo method) => GetLeftTypedBinary(ExpressionType.MultiplyChecked, left, right, method);
1233+
public static BinaryExpression MultiplyChecked(Expression left, Expression right, MethodInfo method) =>
1234+
GetArithmeticBinary(ExpressionType.MultiplyChecked, left, right, method);
12321235

12331236
/// <summary>Creates a BinaryExpression that represents an arithmetic division operation.</summary>
12341237
public static BinaryExpression Divide(Expression left, Expression right) =>
1235-
new LeftTypedBinaryExpression(ExpressionType.Divide, left, right);
1238+
GetArithmeticBinary(ExpressionType.Divide, left, right);
12361239

1237-
public static BinaryExpression Divide(Expression left, Expression right, MethodInfo method) => GetLeftTypedBinary(ExpressionType.Divide, left, right, method);
1240+
public static BinaryExpression Divide(Expression left, Expression right, MethodInfo method) =>
1241+
GetArithmeticBinary(ExpressionType.Divide, left, right, method);
12381242

12391243
/// <summary>Creates a BinaryExpression that represents raising a number to a power.</summary>
12401244
public static BinaryExpression Power(Expression left, Expression right) =>

0 commit comments

Comments
 (0)