You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/FastExpressionCompiler/FastExpressionCompiler.cs
+80-31Lines changed: 80 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,10 @@ public enum CompilerFlags : byte
76
76
/// <summary>Adds the Expression, ExpressionString, and CSharpString to the delegate closure for the debugging inspection</summary>
77
77
EnableDelegateDebugInfo = 1 << 1,
78
78
/// <summary>When the flag is set then instead of the returning `null` the specific exception is thrown*346</summary>
79
-
ThrowOnNotSupportedExpression = 1 << 2
79
+
ThrowOnNotSupportedExpression = 1 << 2,
80
+
/// <summary>Will try to evalaute constant, arithmetic, logical, comparison expressions consisting of the former expression types,
81
+
/// and emit the result only to the IL instead the whole computation. Minimizes IL and moves optimization to the compilation phase if possible.</summary>
82
+
EvaluateExpressionIfPossible = 1 << 4
80
83
}
81
84
82
85
/// <summary>FEC Not Supported exception</summary>
@@ -2073,6 +2076,13 @@ public static bool TryEmit(Expression expr,
2073
2076
case ExpressionType.LessThanOrEqual:
2074
2077
case ExpressionType.Equal:
2075
2078
case ExpressionType.NotEqual:
2079
+
if ((setup & CompilerFlags.EvaluateExpressionIfPossible) != 0 && expr.Type.IsPrimitive &&
2080
+
TryEvalExpressionAndCatchExceptions(out var evalResult, expr))
Copy file name to clipboardExpand all lines: test/FastExpressionCompiler.IssueTests/Issue468_Optimize_the_delegate_access_to_the_Closure_object_for_the_modern_NET.cs
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,10 @@ public void Original_expression(TestContext t)
0 commit comments