{"id":319497,"date":"2021-03-13T09:00:15","date_gmt":"2021-03-13T09:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=319497"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=319497","title":{"rendered":"\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442. \u0412 \u044d\u0442\u043e\u043c \u043e\u0447\u0435\u0440\u043a\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 (\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445) \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Linq Expression.<\/p>\n<p><strong>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f:<em> <\/em><\/strong><a href=\"#task\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 <\/em><\/strong><\/a><strong><em>\u00b7 <\/em><\/strong><a href=\"#protocol\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#compiler\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <\/em><\/strong><\/a><strong><em>\u00b7 <\/em><\/strong><a href=\"#assumptions\" rel=\"noopener noreferrer nofollow\"><strong><em>\u0414\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#api\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 API<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#performance\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#examples\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#conclusion\" rel=\"noopener noreferrer nofollow\"><strong><em>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#links\" rel=\"noopener noreferrer nofollow\"><strong><em>\u0421\u0441\u044b\u043b\u043a\u0438<\/em><\/strong><\/a><\/p>\n<p><a class=\"anchor\" name=\"task\" id=\"task\"><\/a><\/p>\n<h3>\u0427\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c?<\/h3>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u043e \u0438 \u0431\u0443\u043b\u0435\u0432\u043e\u0433\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"cs\">var func = \"x + sin(y) + 2ch(0)\".Compile&lt;Complex, double, Complex&gt;(\"x\", \"y\"); Console.WriteLine(func(new(3, 4), 1.2d)); &gt;&gt;&gt; (5.932039085967226, 4)    var func = \"x &gt; 3 and (a implies b)\".Compile&lt;int, bool, bool, bool&gt;(\"x\", \"a\", \"b\"); Console.WriteLine(func(4, false, true)); &gt;&gt;&gt; True<\/code><\/pre>\n<h3>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c?<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0434\u0435\u043b\u0430\u044e \u044d\u0442\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b, \u0442\u043e \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0443\u0436\u0435 \u0438\u043c\u044f \u043f\u0430\u0440\u0441\u0435\u0440 \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 Entity \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432.<\/p>\n<pre><code>Entity | +--Operators   |   +--Sumf   |   +--Minusf   |   ... +--Trigonometry   |   +--Sinf   |   +--Cosf   |   ... +--Discrete   |   +--Andf   |   +--Lessf   |<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u0442\u0438\u043f\u043e\u0432. \u0414\u0435\u0440\u0435\u0432\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u0440\u0430\u0444, \u0433\u0434\u0435 \u0434\u0435\u0442\u0438 \u043d\u043e\u0434\u044b \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f \u043b\u0438\u0431\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 (\u0441\u043b\u0443\u0436\u0438\u0442 \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432), \u043b\u0438\u0431\u043e \u0437\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u043d\u043d\u044b\u0439. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438\/\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b\/\u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 (\u0431\u0443\u0434\u044c \u0442\u043e \u043f\u043b\u044e\u0441, \u0441\u0438\u043d\u0443\u0441, \u043a\u043e\u043d\u044a\u044e\u043a\u0446\u0438\u044f, \u0447\u0438\u0441\u043b\u043e, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0438 \u0442. \u0434.).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/ffc1d6efcaae3b2429d3d95d028e0027e1d00d38\/Sources\/AngouriMath\/Core\/Entity\/Continuous\/Entity.Continuous.Operators.Classes.cs#L20\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a <\/a>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u0443\u043c\u043c\u044b.<\/p>\n<p><a class=\"anchor\" name=\"protocol\" id=\"protocol\"><\/a><\/p>\n<h3>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/h3>\n<p>\u0422\u0430\u043a \u044f \u043d\u0430\u0437\u0432\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\/\u043a\u043b\u0430\u0441\u0441 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u044b Entity \u0432 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e, \u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<pre><code class=\"cs\">public sealed record CompilationProtocol { \tpublic Func&lt;Entity, Expression&gt; ConstantConverter { get; init; }  \tpublic Func&lt;Expression, Expression, Entity, Expression&gt; BinaryNodeConverter { get; init; }  \tpublic Func&lt;Expression, Entity, Expression&gt; UnaryNodeConverter { get; init; }  \tpublic Func&lt;IEnumerable&lt;Expression&gt;, Entity, Expression&gt; AnyArgumentConverter { get; init; } }<\/code><\/pre>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> <code>ConstantConverter<\/code>, <code>BinaryNodeConverter<\/code>, \u0438 <code>UnaryNodeConverter <\/code>\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u043b\u044f\u043c\u0431\u0434\u044b \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0443\u043d\u0430\u0440\u043d\u044b\u0435 \u043d\u043e\u0434\u044b, \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043d\u043e\u0434\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 \u043d\u043e\u0434\u044b, \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0432 Linq.Expression.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u043e\u0434\u0443. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0430\u043c &#171;\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440&#187;, \u0442\u043e\u0447\u043d\u0435\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<p><a class=\"anchor\" name=\"compiler\" id=\"compiler\"><\/a><\/p>\n<h3>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440<\/h3>\n<p>\u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">internal static TDelegate Compile&lt;TDelegate&gt;(             Entity expr,              Type? returnType,             CompilationProtocol protocol,             IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames             ) where TDelegate : Delegate<\/code><\/pre>\n<ol>\n<li>\n<p><code>Entity expr<\/code> &#8212; \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p><code>Type? returnType<\/code> &#8212; \u044d\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f. \u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c &#171;\u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c&#187; \u0435\u0433\u043e \u0438\u0437 \u0442\u0438\u043f\u0430 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><code>CompilationProtocol protocol<\/code> &#8212; \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0440\u0430\u0432\u0438\u043b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><code>IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames<\/code> &#8212; \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440 \u0442\u0438\u043f-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0439 \u0434\u0435\u043b\u0435\u0433\u0430\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e x \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e y \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0435, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c <code>new[] { (typeof(int), \"x\"), (typeof(Complex), \"y\") }<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0432\u043e\u0442 \u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">internal static TDelegate Compile&lt;TDelegate&gt;(Entity expr, Type? returnType, CompilationProtocol protocol, IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames) where TDelegate : Delegate {   \/\/ \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0435\u0441\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0434\u0435\u0440\u0436\u0438\u043c \u0437\u0434\u0435\u0441\u044c \tvar subexpressionsCache = typesAndNames.ToDictionary(c =&gt; (Entity)c.variable, c =&gt; Expression.Parameter(c.type));   \/\/ \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438: \u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0435, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \tvar functionArguments = subexpressionsCache.Select(c =&gt; c.Value).ToArray(); \/\/ copying   \/\/ \u0430 \u044d\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043c\u044b \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \tvar localVars = new List&lt;ParameterExpression&gt;();   \/\/ \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439-\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439 (\u043e \u043d\u0435\u043c \u043f\u043e\u0437\u0436\u0435) \tvar variableAssignments = new List&lt;Expression&gt;();    \/\/ \u043f\u043e \u0432\u0441\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0441\u0442\u0440\u043e\u0438\u043c \u0434\u0435\u0440\u0435\u0432\u043e \tvar tree = BuildTree(expr, subexpressionsCache, variableAssignments, localVars, protocol);   \/\/ \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u043b\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \tvar treeWithLocals = Expression.Block(localVars, variableAssignments.Append(tree));   \/\/ \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043b returnType, \u0442\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u044f\u0432\u043d\u043e \u0441\u043a\u0430\u0441\u0442\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \tExpression entireExpresion = returnType is not null ? Expression.Convert(treeWithLocals, returnType) : treeWithLocals;   \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u044f\u043c\u0431\u0434\u0443 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \tvar finalLambda = Expression.Lambda&lt;TDelegate&gt;(entireExpresion, functionArguments);    \/\/ \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \treturn finalLambda.Compile(); }<\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0434\u043b\u044f \u043a\u0435\u0448\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u0421\u0430\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0442\u0443\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044d\u0442\u043e <code>BuildTree<\/code>. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e linq-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e <code>Entity<\/code>. \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f:<\/p>\n<pre><code class=\"cs\">internal static Expression BuildTree( \tEntity expr,  \tDictionary&lt;Entity, ParameterExpression&gt; cachedSubexpressions,  \tList&lt;Expression&gt; variableAssignments,  \tList&lt;ParameterExpression&gt; newLocalVars, \tCompilationProtocol protocol)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b BuildTree<\/summary>\n<div class=\"spoiler__content\">\n<ol>\n<li>\n<p><code>Entity expr<\/code> &#8212; \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<\/li>\n<li>\n<p><code>Dictionary&lt;Entity, ParameterExpression&gt; cachedSubexpressions<\/code> &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 (\u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435).<\/p>\n<\/li>\n<li>\n<p><code>List&lt;Expression&gt; variableAssignments<\/code> &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p><code>List&lt;ParameterExpression&gt; newLocalVars<\/code> &#8212; \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>BuildTree <\/code>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 (\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432).<\/p>\n<\/li>\n<li>\n<p><code>CompilationProtocol protocol<\/code> &#8212; \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043d\u043e\u0434\u0443 <code>Entity<\/code> \u0432 \u043d\u043e\u0434\u0443 <code>Linq.Expression<\/code>. \u041e\u043d \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b <code>BuildTree<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p>\u0410 \u0432\u043e\u0442 \u0438 \u0441\u0430\u043c\u0430\u044f \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f &#8212; <code>BuildTree<\/code>:<\/p>\n<pre><code class=\"cs\">internal static Expression BuildTree(Entity expr, ...) {   \/\/ \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u043e\u0441\u044c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \tif (cachedSubexpressions.TryGetValue(expr, out var readyVar)) \t\treturn readyVar;  \tExpression subTree = expr switch \t{ \t  ... \t\t     \/\/ \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 - \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 ConstantConverter \t\t\/\/ \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \t\tEntity.Boolean or Number =&gt; protocol.ConstantConverter(expr),      \/\/ \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441 \u0443\u043d\u0430\u0440\u043d\u043e\u0439, \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439, \u0438 n-\u0430\u0440\u043d\u044b\u043c\u0438 \u043d\u043e\u0434\u0430\u043c\u0438 \t\tIUnaryNode oneArg \t\t\t=&gt; protocol.UnaryNodeConverter(BuildTree(oneArg.NodeChild, ...), expr),  \t\tIBinaryNode twoArg \t\t\t=&gt; protocol.BinaryNodeConverter( \t\t\t\tBuildTree(twoArg.NodeFirstChild, ...),  \t\t\t\tBuildTree(twoArg.NodeSecondChild, ...),  \t\t\t\texpr),  \t\tvar other =&gt; protocol.AnyArgumentConverter( \t\t\t\tother.DirectChildren.Select(c =&gt; BuildTree(c, ...)),  \t\t\texpr) \t};    \/\/ \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \tvar newVar = Expression.Variable(subTree.Type); \t \t\/\/ \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0430 var5 = subTree \tvariableAssignments.Add(Expression.Assign(newVar, subTree)); \t \t\/\/ \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \tcachedSubexpressions[expr] = newVar; \t \t\/\/ \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \tnewLocalVars.Add(newVar); \t \treturn newVar; }<\/code><\/pre>\n<p>\u042f \u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043a\u0443\u0441\u043a\u0438 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u0418\u0442\u0430\u043a, \u0432 \u043d\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u043c\u044b \u043b\u0438\u0431\u043e \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043b\u0438\u0431\u043e \u0441\u0442\u0440\u043e\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e Linq.Expression, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u043e\u0432\u0443\u044e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0435.<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0435, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0433\u043e\u0442\u043e\u0432. \u041d\u043e \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 <code>Linq.Expression<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043c\u044b \u0436\u0434\u0435\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432?<\/p>\n<p>\u041e\u0441\u0442\u0430\u0442\u043e\u043a \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<p><a class=\"anchor\" name=\"assumptions\" id=\"assumptions\"><\/a><\/p>\n<h3>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f (assumptions)<\/h3>\n<p>\u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <code>Compile&lt;TDelegate&gt;(Entity, Type?, CompilationProtocol, IEnumerable&lt;(Type, Variable)&gt;)<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0438 \u043d\u0435\u0443\u043a\u043b\u044e\u0436\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0433\u0438\u043a\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0434\u044b \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0434\u0430 \u0438 \u0441\u0430\u043c\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0438 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438 (<code>bool<\/code>, <code>int<\/code>, <code>long<\/code>, <code>float<\/code>, <code>double<\/code>, <code>Complex<\/code>, <code>BigInteger<\/code>).<\/p>\n<p><strong>ConstantConverter:<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u0437 Entity \u0432 Linq.Constant \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public static Expression ConverterConstant(Entity e) \t=&gt; e switch \t{ \t\tNumber n =&gt; Expression.Constant(DownCast(n)), \t\tEntity.Boolean b =&gt; Expression.Constant((bool)b), \t\t_ =&gt; throw new AngouriBugException(\"Undefined constant type\") \t};<\/code><\/pre>\n<p>\u0427\u0438\u0441\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432 \u0447\u0438\u0441\u043b\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u0431\u0443\u043b\u0435\u0432\u0443 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 <code>bool<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e DownCast<\/summary>\n<div class=\"spoiler__content\">\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 Entity.Number \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">private static object DownCast(Number num) { \tif (num is Integer) \t\treturn (long)num; \tif (num is Real) \t\treturn (double)num; \tif (num is Number.Complex) \t\treturn (System.Numerics.Complex)num; \tthrow new InvalidProtocolProvided(\"Undefined type, provide valid compilation protocol\"); }<\/code><\/pre>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>object <\/code>\u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>Expression.Constant<\/code>. \u0410 \u043d\u0430\u043c \u044d\u0442\u043e \u043d\u0430 \u0440\u0443\u043a\u0443: \u0438\u043d\u0430\u0447\u0435 \u043f\u043e\u0434 \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0442\u0440\u0438?<\/p>\n<\/div>\n<\/details>\n<p><strong>UnaryNodeConverter:<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u043b\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 &#8212; \u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0439 \u043d\u043e\u0434\u0443 \u0441 \u043e\u0434\u043d\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0432 <code>Linq.Expression<\/code>.<\/p>\n<pre><code class=\"cs\">public static Expression OneArgumentEntity(Expression e, Entity typeHolder)   =&gt; typeHolder switch \t{ \t\tSinf =&gt;         Expression.Call(GetDef(\"Sin\", 1, e.Type), e), \t\t... \t\tCosecantf =&gt;    Expression.Call(GetDef(\"Csc\", 1, e.Type), e),  \t\tArcsinf =&gt;      Expression.Call(GetDef(\"Asin\", 1, e.Type), e), \t\t... \t\tArccosecantf =&gt; Expression.Call(GetDef(\"Acsc\", 1, e.Type), e),  \t\tAbsf =&gt;         Expression.Call(GetDef(\"Abs\", 1, e.Type), e), \t\tSignumf =&gt;      Expression.Call(GetDef(\"Sgn\", 1, e.Type), e),  \t\tNotf =&gt;         Expression.Not(e),  \t\t_ =&gt; throw new AngouriBugException(\"A node seems to be not added\") \t};<\/code><\/pre>\n<p>\u042f \u043e\u043f\u0443\u0441\u0442\u0438\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0431\u043b\u043e\u043a\u0438 (\u0432\u0435\u0441\u044c \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/b8d57a373135c97724c37cf3c9fcac3114b3b424\/Sources\/AngouriMath\/Functions\/Compilation\/IntoLinq\/DefaultConverters.cs#L114\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>). \u0418\u0442\u0430\u043a, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u044b, \u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u043e\u0432\u0435\u0440\u043b\u043e\u0430\u0434 \u043d\u0443\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <code>GetDef <\/code>\u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e GetDef<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0434\u0443\u043c\u0430\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 <code>Math <\/code>\u0438 <code>Complex<\/code>. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0437\u0434\u0435 if-\u0430\u0442\u044c, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 <code>Math<\/code>, \u0432 \u043a\u0430\u043a\u0438\u0445 <code>Complex<\/code>, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0432\u043e\u043e\u0431\u0449\u0435 BigInteger. \u0410 \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0435 \u0438 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0443 <code>Math <\/code>\u043d\u0435\u0442 <code>int Pow(int, int)<\/code>, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043a\u0430\u0441\u0442\u0438\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/master\/Sources\/AngouriMath\/Functions\/Compilation\/IntoLinq\/MathAllMethods.tt\" rel=\"noopener noreferrer nofollow\">MathAllMethods <\/a>(\u043d\u0430 T4), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u043b \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u043e\u0434\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438.<\/p>\n<p><code>GetDef <\/code>\u0438\u0449\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0442\u0438\u043f\u043e\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u043e\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043a\u0440\u0430\u0442\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043d\u0443\u0436\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u0430\u043c.<\/p>\n<\/div>\n<\/details>\n<p><strong>BinaryNodeConverter:<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043d\u043e\u0434\u0443 \u0441 \u0434\u0432\u0443\u043c\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0432 <code>Linq.Expression<\/code>.<\/p>\n<pre><code class=\"cs\">public static Expression TwoArgumentEntity(Expression left, Expression right, Entity typeHolder) { \tvar typeToCastTo = MaxType(left.Type, right.Type); \tif (left.Type != typeToCastTo) \t\tleft = Expression.Convert(left, typeToCastTo); \tif (right.Type != typeToCastTo) \t\tright = Expression.Convert(right, typeToCastTo); \treturn typeHolder switch \t{ \t\tSumf =&gt; Expression.Add(left, right), \t\t... \t\tAndf =&gt; Expression.And(left, right), \t\t... \t\tLessf =&gt; Expression.LessThan(left, right), \t\t... \t\t_ =&gt; throw new AngouriBugException(\"A node seems to be not added\") \t}; }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0435\u0441\u0442\u044c <code>upcast<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0434\u0432\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0442\u0438\u043f, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043a\u0430\u0441\u0442\u044f\u0442\u0441\u044f \u043e\u0431\u0430 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u042f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0442\u0430\u043a:<\/p>\n<pre><code>Complex:   10 double:     9 float:      8 long:       8 BigInteger: 8 int:        7<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0438\u043f\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435, <code>MaxType<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>MaxType(int, int) -&gt; int<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0442\u0438\u043f\u0430 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430 A \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u0443 \u0442\u0438\u043f\u0430 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430 B, \u0442\u043e B \u043a\u0430\u0441\u0442\u0438\u0442\u0441\u044f \u0432 A. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>MaxType(long, double) -&gt; double<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0440\u043e\u0432\u043d\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435, \u0430 \u0442\u0438\u043f\u044b &#8212; \u043d\u0435\u0442, \u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0430\u044f \u043e\u0431\u0449\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430 \u043e\u0434\u0438\u043d \u0432\u044b\u0448\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>MaxType(long, float) -&gt; double<\/code>.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u043d\u0434\u044b, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u0430\u0441\u0442\u044f\u0442\u0441\u044f \u043a \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u0438 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u043e\u0432\u0435\u0440\u043b\u043e\u0430\u0434 \u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f <code>Sumf <\/code>\u043c\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u043c <code>Expression.Add<\/code>, \u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u044a\u044e\u043a\u0446\u0438\u0438, <code>Andf<\/code>, \u0431\u0443\u0434\u0435\u0442 <code>Expression.And<\/code>.<\/p>\n<p><strong>\u041e\u0441\u043e\u0437\u043d\u0430\u0435\u043c.<\/strong><\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<p><a class=\"anchor\" name=\"api\" id=\"api\"><\/a><\/p>\n<h3>\u041a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 API<\/h3>\n<p>\u041d\u0430\u0447\u0430\u043b\u0438 \u043c\u044b \u0441 \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c API \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">public TDelegate Compile&lt;TDelegate&gt;(CompilationProtocol protocol, Type returnType, IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames) where TDelegate : Delegate<\/code><\/pre>\n<p>\u041e\u043d \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0443\u0441\u0438\u043b\u0438\u0439. \u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0418 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0434\u0432\u0443\u0445, \u0442\u0440\u0435\u0445, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0443\u0436\u0435 <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/b8d57a373135c97724c37cf3c9fcac3114b3b424\/Sources\/AngouriMath\/Functions\/Compilation\/IntoLinq\/CompilationProtocol.cs#L19\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e <\/a>\u043d\u0430\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0441. \u0421\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 &#8212; \u044f \u0440\u0435\u0448\u0438\u043b \u044d\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e T4 Text Template. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">\/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439                             \u0430 \u0437\u0434\u0435\u0441\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f public Func&lt;TIn1, TIn2, TIn3, TOut&gt; Compile&lt;TIn1, TIn2, TIn3, TOut&gt;(Variable var1, Variable var2, Variable var3)                                        \/\/ \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c\u0438        \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0438\u043f \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d   new() \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e               =&gt; IntoLinqCompiler.Compile&lt;Func&lt;TIn1, TIn2, TIn3, TOut&gt;&gt;(this, typeof(TOut),         new(),                  new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3)  });<\/code><\/pre>\n<p>\u041e\u043d \u0436\u0435 \u0432 <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/b8d57a373135c97724c37cf3c9fcac3114b3b424\/Sources\/AngouriMath\/Functions\/Compilation\/Compile.Linq.Definition.cs#L119\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0422\u0435\u043a\u0441\u0442 T4-\u0442\u0435\u043c\u043f\u043b\u0435\u0439\u0442\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>&lt;# for (var i = 1; i &lt;= 8; i++) { #&gt;         public Func&lt;&lt;# for(var t=1;t&lt;=i;t++){ #&gt;TIn&lt;#= t #&gt;, &lt;# } #&gt;TOut&gt; Compile&lt;&lt;# for(var t=1;t&lt;=i;t++){ #&gt;TIn&lt;#= t #&gt;, &lt;# } #&gt;TOut&gt;(Variable var1&lt;# for(var t=2; t&lt;=i; t++){ #&gt;, Variable var&lt;#= t #&gt;&lt;# } #&gt;)             =&gt; IntoLinqCompiler.Compile&lt;Func&lt;&lt;# for(var t=1;t&lt;=i;t++){ #&gt;TIn&lt;#= t #&gt;, &lt;# } #&gt;TOut&gt;&gt;(this, typeof(TOut), new(),                  new[] { (typeof(TIn1), var1)&lt;# for(var t=2;t&lt;=i;t++){ #&gt;, (typeof(TIn&lt;#= t #&gt;), var&lt;#= t #&gt;) &lt;# } #&gt; }); &lt;# } #&gt;<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e:<\/p>\n<pre><code class=\"cs\">public static Func&lt;TIn1, TIn2, TOut&gt; Compile&lt;TIn1, TIn2, TOut&gt;(this string @this, Variable var1, Variable var2) \t=&gt; IntoLinqCompiler.Compile&lt;Func&lt;TIn1, TIn2, TOut&gt;&gt;(@this, typeof(TOut), new(),  \t\tnew[] { (typeof(TIn1), var1), (typeof(TIn2), var2)  });<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u043f\u043e\u043c\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p><a class=\"anchor\" name=\"performance\" id=\"performance\"><\/a><\/p>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>BenchNormalSimple &#8212; \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043b\u044f\u043c\u0431\u0434\u0430, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>BenchMySimple &#8212; \u0442\u0430 \u0436\u0435 \u043b\u044f\u043c\u0431\u0434\u0430, \u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043c\u043d\u043e\u044e.<\/p>\n<p>BenchNormalComplicated &#8212; \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0442\u043e\u043b\u0441\u0442\u0430\u044f \u043b\u044f\u043c\u0431\u0434\u0430 \u0441 \u043a\u0443\u0447\u0435\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>BenchmyComplicated &#8212; \u0442\u0430 \u0436\u0435 \u043b\u044f\u043c\u0431\u0434\u0430, \u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043c\u043d\u043e\u044e.<\/p>\n<pre><code>|                 Method |       Mean |    Error |   StdDev | |----------------------- |-----------:|---------:|---------:| |      BenchNormalSimple |   189.1 ns |  3.75 ns |  5.83 ns | |          BenchMySimple |   195.7 ns |  3.92 ns |  5.50 ns | | BenchNormalComplicated | 1,383.0 ns | 26.82 ns | 35.80 ns | |     BenchMyComplicated |   293.6 ns |  5.74 ns |  8.77 ns |<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u0448\u0442\u0443\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0431\u044b\u0441\u0442\u0440\u043e, \u0430 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043c\u043e\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442. \u0412 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e, \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u0433\u0435\u043d\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0443\u0442 \u043d\u0435\u0442.<\/p>\n<p>\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/638b4bd9db1b822b144cda85cdfd0deddf2cb9b2\/Sources\/Tests\/DotnetBenchmark\/BenchLinqCompilation.cs#L12\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"examples\" id=\"examples\"><\/a><\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<pre><code class=\"cs\">var func = \"sin(x)\".Compile&lt;double, double&gt;(\"x\"); Console.WriteLine(func(Math.PI \/ 2)); &gt;&gt;&gt; 1  var func1 = \"a &gt; b\".Compile&lt;float, int, bool&gt;(\"a\", \"b\"); Console.WriteLine(func1(5.4f, 4)); Console.WriteLine(func1(4f, 4)); &gt;&gt;&gt; True &gt;&gt;&gt; False  var cr = new CompilationProtocol() {      ConstantConverter = ent =&gt; Expression.Constant(ent.ToString()),     BinaryNodeConverter = (a, b, t) =&gt; t switch     {         Sumf =&gt; Expression.Call(typeof(string)             .GetMethod(\"Concat\", new[] { typeof(string), typeof(string) }) ?? throw new Exception(), a, b),         _ =&gt; throw new Exception()     } }; var func2 = \"a + b + c + 1234\"     .Compile&lt;Func&lt;string, string, string, string&gt;&gt;(         cr, typeof(string),                   new[] {              (typeof(string), Var(\"a\")),              (typeof(string), Var(\"b\")),              (typeof(string), Var(\"c\")) }          ); Console.WriteLine(func2(\"White\", \"Black\", \"Goose\")); &gt;&gt;&gt; WhiteBlackGoose1234<\/code><\/pre>\n<p>(\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 &#8212; \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0430\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439. \u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043b\u044f\u043c\u0431\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438).<\/p>\n<p><a class=\"anchor\" name=\"conclusion\" id=\"conclusion\"><\/a><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<ol>\n<li>\n<p><code>Linq.Expression<\/code> \u043f\u043e \u0438\u0441\u0442\u0438\u043d\u0435 \u0433\u0435\u043d\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0449\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b, \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u044f\u0441\u044c, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435. <\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432, \u043c\u044b \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043a\u043e\u0434\u0430, \u043c\u044b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0439 \u0440\u044f\u0434 \u043e\u0432\u0435\u0440\u043b\u043e\u0430\u0434\u043e\u0432 \u0441 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c, \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c \u0441 \u0446\u0435\u043b\u044b\u043c \u0440\u044f\u0434\u043e\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0430\u043f\u043a\u0430\u0441\u0442\u0438\u0442 \u0442\u0438\u043f\u044b \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043e\u0431\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043c, \u0433\u0434\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e-\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u0442 \u0435\u0449\u0435 \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u041a\u0441\u0442\u0430\u0442\u0438, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u044f \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u0434\u0440\u0443\u0433\u043e\u043c <a href=\"https:\/\/github.com\/asc-community\/GenericTensor\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 (\u0438 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0434\u0440\u0430\u0433\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b).<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435! \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f <em>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e <\/em>\u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0438\u043b\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433.<\/p>\n<p><a class=\"anchor\" name=\"links\" id=\"links\"><\/a><\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/github.com\/asc-community\/AngouriMath\" rel=\"noopener noreferrer nofollow\">GitHub \u043f\u0440\u043e\u0435\u043a\u0442\u0430 AngouriMath<\/a>, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0438 \u0434\u0435\u043b\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/tree\/master\/Sources\/AngouriMath\/Functions\/Compilation\/IntoLinq\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<\/li>\n<li>\n<p>\u0422\u0435\u0441\u0442\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/master\/Sources\/Tests\/UnitTests\/Common\/CompilationIntoLinqTest.cs\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/546622\/\"> https:\/\/habr.com\/ru\/post\/546622\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442. \u0412 \u044d\u0442\u043e\u043c \u043e\u0447\u0435\u0440\u043a\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 (\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445) \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Linq Expression.<\/p>\n<p><strong>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f:<em> <\/em><\/strong><a href=\"#task\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 <\/em><\/strong><\/a><strong><em>\u00b7 <\/em><\/strong><a href=\"#protocol\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#compiler\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <\/em><\/strong><\/a><strong><em>\u00b7 <\/em><\/strong><a href=\"#assumptions\" rel=\"noopener noreferrer nofollow\"><strong><em>\u0414\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#api\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 API<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#performance\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#examples\" rel=\"noopener noreferrer nofollow\"><strong><em>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#conclusion\" rel=\"noopener noreferrer nofollow\"><strong><em>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/em><\/strong><\/a><strong><em> \u00b7 <\/em><\/strong><a href=\"#links\" rel=\"noopener noreferrer nofollow\"><strong><em>\u0421\u0441\u044b\u043b\u043a\u0438<\/em><\/strong><\/a><\/p>\n<p><a class=\"anchor\" name=\"task\" id=\"task\"><\/a><\/p>\n<h3>\u0427\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c?<\/h3>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u043e \u0438 \u0431\u0443\u043b\u0435\u0432\u043e\u0433\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"cs\">var func = \"x + sin(y) + 2ch(0)\".Compile&lt;Complex, double, Complex&gt;(\"x\", \"y\"); Console.WriteLine(func(new(3, 4), 1.2d)); &gt;&gt;&gt; (5.932039085967226, 4)    var func = \"x &gt; 3 and (a implies b)\".Compile&lt;int, bool, bool, bool&gt;(\"x\", \"a\", \"b\"); Console.WriteLine(func(4, false, true)); &gt;&gt;&gt; True<\/code><\/pre>\n<h3>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c?<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0434\u0435\u043b\u0430\u044e \u044d\u0442\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b, \u0442\u043e \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0443\u0436\u0435 \u0438\u043c\u044f \u043f\u0430\u0440\u0441\u0435\u0440 \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 Entity \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432.<\/p>\n<pre><code>Entity | +--Operators   |   +--Sumf   |   +--Minusf   |   ... +--Trigonometry   |   +--Sinf   |   +--Cosf   |   ... +--Discrete   |   +--Andf   |   +--Lessf   |<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u0442\u0438\u043f\u043e\u0432. \u0414\u0435\u0440\u0435\u0432\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u0440\u0430\u0444, \u0433\u0434\u0435 \u0434\u0435\u0442\u0438 \u043d\u043e\u0434\u044b \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f \u043b\u0438\u0431\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 (\u0441\u043b\u0443\u0436\u0438\u0442 \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432), \u043b\u0438\u0431\u043e \u0437\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u043d\u043d\u044b\u0439. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438\/\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b\/\u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 (\u0431\u0443\u0434\u044c \u0442\u043e \u043f\u043b\u044e\u0441, \u0441\u0438\u043d\u0443\u0441, \u043a\u043e\u043d\u044a\u044e\u043a\u0446\u0438\u044f, \u0447\u0438\u0441\u043b\u043e, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0438 \u0442. \u0434.).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/asc-community\/AngouriMath\/blob\/ffc1d6efcaae3b2429d3d95d028e0027e1d00d38\/Sources\/AngouriMath\/Core\/Entity\/Continuous\/Entity.Continuous.Operators.Classes.cs#L20\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a <\/a>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u0443\u043c\u043c\u044b.<\/p>\n<p><a class=\"anchor\" name=\"protocol\" id=\"protocol\"><\/a><\/p>\n<h3>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/h3>\n<p>\u0422\u0430\u043a \u044f \u043d\u0430\u0437\u0432\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\/\u043a\u043b\u0430\u0441\u0441 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u044b Entity \u0432 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e, \u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<pre><code class=\"cs\">public sealed record CompilationProtocol { \tpublic Func&lt;Entity, Expression&gt; ConstantConverter { get; init; }  \tpublic Func&lt;Expression, Expression, Entity, Expression&gt; BinaryNodeConverter { get; init; }  \tpublic Func&lt;Expression, Entity, Expression&gt; UnaryNodeConverter { get; init; }  \tpublic Func&lt;IEnumerable&lt;Expression&gt;, Entity, Expression&gt; AnyArgumentConverter { get; init; } }<\/code><\/pre>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> <code>ConstantConverter<\/code>, <code>BinaryNodeConverter<\/code>, \u0438 <code>UnaryNodeConverter <\/code>\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u0438 \u043b\u044f\u043c\u0431\u0434\u044b \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0443\u043d\u0430\u0440\u043d\u044b\u0435 \u043d\u043e\u0434\u044b, \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043d\u043e\u0434\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 \u043d\u043e\u0434\u044b, \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0432 Linq.Expression.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u043e\u0434\u0443. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0430\u043c &#171;\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440&#187;, \u0442\u043e\u0447\u043d\u0435\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<p><a class=\"anchor\" name=\"compiler\" id=\"compiler\"><\/a><\/p>\n<h3>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440<\/h3>\n<p>\u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">internal static TDelegate Compile&lt;TDelegate&gt;(             Entity expr,              Type? returnType,             CompilationProtocol protocol,             IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames             ) where TDelegate : Delegate<\/code><\/pre>\n<ol>\n<li>\n<p><code>Entity expr<\/code> &#8212; \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p><code>Type? returnType<\/code> &#8212; \u044d\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f. \u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c &#171;\u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c&#187; \u0435\u0433\u043e \u0438\u0437 \u0442\u0438\u043f\u0430 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><code>CompilationProtocol protocol<\/code> &#8212; \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0440\u0430\u0432\u0438\u043b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><code>IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames<\/code> &#8212; \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440 \u0442\u0438\u043f-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0445\u043e\u0447\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0439 \u0434\u0435\u043b\u0435\u0433\u0430\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e x \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e y \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0435, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c <code>new[] { (typeof(int), \"x\"), (typeof(Complex), \"y\") }<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0432\u043e\u0442 \u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">internal static TDelegate Compile&lt;TDelegate&gt;(Entity expr, Type? returnType, CompilationProtocol protocol, IEnumerable&lt;(Type type, Variable variable)&gt; typesAndNames) where TDelegate : Delegate {   \/\/ \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0435\u0441\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0434\u0435\u0440\u0436\u0438\u043c \u0437\u0434\u0435\u0441\u044c \tvar subexpressionsCache = typesAndNames.ToDictionary(c =&gt; (Entity)c.variable, c =&gt; Expression.Parameter(c.type));   \/\/ \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438: \u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0435, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \tvar functionArguments = subexpressionsCache.Select(c =&gt; c.Value).ToArray(); \/\/ copying   \/\/ \u0430 \u044d\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043c\u044b \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \tvar localVars = new List&lt;ParameterExpression&gt;();   \/\/ \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439-\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0439 (\u043e \u043d\u0435\u043c \u043f\u043e\u0437\u0436\u0435) \tvar variableAssignments = new List&lt;Expression&gt;();    \/\/ \u043f\u043e \u0432\u0441\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0441\u0442\u0440\u043e\u0438\u043c \u0434\u0435\u0440\u0435\u0432\u043e \tvar tree = BuildTree(expr, subexpressionsCache, variableAssignments, localVars, protocol);   \/\/ \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u043b\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \tvar treeWithLocals = Expression.Block(localVars, variableAssignments.Append(tree));   \/\/ \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043b returnType, \u0442\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u044f\u0432\u043d\u043e \u0441\u043a\u0430\u0441\u0442\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \tExpression entireExpresion = returnType is not null ? Expression.Convert(treeWithLocals, returnType) : treeWithLocals;   \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u044f\u043c\u0431\u0434\u0443 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \tvar finalLambda = Expression.Lambda&lt;TDelegate&gt;(entireExpresion, functionArguments);    \/\/ \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \treturn finalLambda.Compile(); }<\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0434\u043b\u044f \u043a\u0435\u0448\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u0421\u0430\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0442\u0443\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044d\u0442\u043e <code>BuildTree<\/code>. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e linq-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e <code>Entity<\/code>. \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f:<\/p>\n<pre><code class=\"cs\">internal static Expression BuildTree( \tEntity expr,  \tDictionary&lt;Entity, ParameterExpression&gt; cachedSubexpressions,  \tList&lt;Expression&gt; variableAssignments,  \tList&lt;ParameterExpression&gt; newLocalVars, \tCompilationProtocol protocol)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b BuildTree<\/summary>\n<div class=\"spoiler__content\">\n<ol>\n<li>\n<p><code>Entity expr<\/code> &#8212; \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<\/li>\n<li>\n<p><code>Dictionary&lt;Entity, ParameterExpression&gt; cachedSubexpressions<\/code> &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 (\u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435).<\/p>\n<\/li>\n<li>\n<p><code>List&lt;Expression&gt; variableAssignments<\/code> &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p><code>List&lt;ParameterExpression&gt; newLocalVars<\/code> &#8212; \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>BuildTree <\/code>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 (\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432).<\/p>\n<\/li>\n<li>\n<p><code>CompilationProtocol protocol<\/code> &#8212; \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043d\u043e\u0434\u0443 <code>Entity<\/code> \u0432 \u043d\u043e\u0434\u0443 <code>Linq.Expression<\/code>. \u041e\u043d \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b <code>BuildTree<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p>\u0410 \u0432\u043e\u0442 \u0438 \u0441\u0430\u043c\u0430\u044f \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f &#8212; <code>BuildTree<\/code>:<\/p>\n<pre><code class=\"cs\">internal static Expression BuildTree(Entity expr, ...) {   \/\/ \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u043e\u0441\u044c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \tif (cachedSubexpressions.TryGetValue(expr, out var readyVar)) \t\treturn readyVar;  \tExpression subTree = expr switch \t{ \t  ... \t\t     \/\/ \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 - \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 ConstantConverter \t\t\/\/ \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \t\tEntity.Boolean or Number =&gt; protocol.ConstantConverter(expr),      \/\/ \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441 \u0443\u043d\u0430\u0440\u043d\u043e\u0439, \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439, \u0438 n-\u0430\u0440\u043d\u044b\u043c\u0438 \u043d\u043e\u0434\u0430\u043c\u0438 \t\tIUnaryNode oneArg \t\t\t=&gt; protocol.UnaryNodeConverter(BuildTree(oneArg.NodeChild, ...), expr),  \t\tIBinaryNode twoArg \t\t\t=&gt; protocol.BinaryNodeConverter( \t\t\t\tBuildTree(twoArg.NodeFirstChild, ...),  \t\t\t\tBuildTree(twoArg.NodeSecondChild, ...),  \t\t\t\texpr),  \t\tvar other =&gt; protocol.AnyArgumentConverter( \t\t\t\tother.DirectChildren.Select(c =&gt; BuildTree(c, ...)),  \t\t\texpr) \t};    \/\/ \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \tvar newVar = Expression.Variable(subTree.Type); \t \t\/\/ \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0430 var5 = subTree \tvariableAssignments.Add(Expression.Assign(newVar, subTree)); \t \t\/\/ \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \tcachedSubexpressions[expr] = newVar; \t \t\/\/ \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \tnewLocalVars.Add(newVar); \t \treturn newVar; }<\/code><\/pre>\n<p>\u042f \u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043a\u0443\u0441\u043a\u0438 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u0418\u0442\u0430\u043a, \u0432 \u043d\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u043c\u044b \u043b\u0438\u0431\u043e \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043b\u0438\u0431\u043e \u0441\u0442\u0440\u043e\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e Linq.Expression, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u043e\u0432\u0443\u044e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0435.<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0435, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0433\u043e\u0442\u043e\u0432. \u041d\u043e \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 <code>Linq.Expression<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043c\u044b \u0436\u0434\u0435\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432?<\/p>\n<p>\u041e\u0441\u0442\u0430\u0442\u043e\u043a \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<p><a class=\"anchor\" name=\"assumptions\" id=\"assumptions\"><\/a><\/p>\n<h3>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f (assumptions)<\/h3>\n<p>\u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <code>Compile&lt;TDelegate&gt;(Entity, Type?, CompilationProtocol, IEnumerable&lt;(Type, Variable)&gt;)<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0438 \u043d\u0435\u0443\u043a\u043b\u044e\u0436\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0433\u0438\u043a\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0434\u044b \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0434\u0430 \u0438 \u0441\u0430\u043c\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0438 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430\u043c\u0438 (<code>bool<\/code>, <code>int<\/code>, <code>long<\/code>, <code>float<\/code>, <code>double<\/code>, <code>Complex<\/code>, <code>BigInteger<\/code>).<\/p>\n<p><strong>ConstantConverter:<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u0437 Entity \u0432 Linq.Constant \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public static Expression ConverterConstant(Entity e) \t=&gt; e switch \t{ \t\tNumber n =&gt; Expression.Constant(DownCast(n)), \t\tEntity.Boolean b =&gt; Expression.Constant((bool)b), \t\t_ =&gt; throw new AngouriBugException(\"Undefined constant type\") \t};<\/code><\/pre>\n<p>\u0427\u0438\u0441\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432 \u0447\u0438\u0441\u043b\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u0431\u0443\u043b\u0435\u0432\u0443 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 <code>bool<\/code>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e DownCast<\/summary>\n<div class=\"spoiler__content\">\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 Entity.Number \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">private static object DownCast(Number num) { \tif (num is Integer) \t\treturn (long)num; \tif (num is Real) \t\treturn (double)num; \tif (num is Number.Complex) \t\treturn (System.Numerics.Complex)num; \tthrow new InvalidProtocolProvided(\"Undefined type, provide valid compilation protocol\"); }<\/code><\/pre>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>object <\/code>\u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>Expression.Constant<\/code>. \u0410 \u043d\u0430\u043c \u044d\u0442\u043e \u043d\u0430 \u0440\u0443\u043a\u0443: \u0438\u043d\u0430\u0447\u0435 \u043f\u043e\u0434 \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0442\u0440\u0438?<\/p>\n<\/div>\n<\/details>\n<p><strong>UnaryNodeConverter:<\/strong><\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u043b\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 &#8212; \u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0439 \u043d\u043e\u0434\u0443 \u0441 \u043e\u0434\u043d\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0432 <code>Linq.Expression<\/code>.<\/p>\n<pre><code class=\"cs\">public static Expression OneArgumentEntity(Expression e, Entity typeHolder)   =&gt; typeHolder switch \t{ \t\tSinf =&gt;         Expression.Call(GetDef(\"Sin\", 1, e.Type), e), \t\t... \t\tCosecantf =&gt;<\/code><\/pre>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-319497","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/319497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319497"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/319497\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}