-
Notifications
You must be signed in to change notification settings - Fork 75
/
Compile.Linq.Definition.cs
379 lines (361 loc) · 16.5 KB
/
Compile.Linq.Definition.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
/*
* Copyright (c) 2019-2021 Angouri.
* AngouriMath is licensed under MIT.
* Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
* Website: https://am.angouri.org.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using AngouriMath.Core;
using AngouriMath.Core.Compilation.IntoLinq;
using static AngouriMath.Core.FastExpression;
namespace AngouriMath
{
partial record Entity
{
/// <summary>
/// Compiles a given expression into a native lambda
/// </summary>
/// <typeparam name="TDelegate">
/// The type of your delegate to convert to
/// </typeparam>
/// <param name="protocol">
/// This is a protocol, according to which all nodes get compiled. Use this
/// if you want to use the compilation for types different from those standard
/// </param>
/// <param name="returnType">
/// The type to which the resulting type will be casted
/// </param>
/// <param name="typesAndNames">
/// An <see cref="IEnumerable"/> of pairs, where the first element is the type of your argument,
/// and the second one is the corresponding variable from the expression
/// </param>
/// <returns>
/// Returnes a natively compiled expression of type <typeparamref name="TDelegate"/>
/// </returns>
public TDelegate Compile<TDelegate>(CompilationProtocol protocol, Type returnType, IEnumerable<(Type type, Variable variable)> typesAndNames) where TDelegate : Delegate
=> IntoLinqCompiler.Compile<TDelegate>(this, returnType, protocol, typesAndNames);
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TOut> Compile<TIn1, TOut>(Variable var1)
=> IntoLinqCompiler.Compile<Func<TIn1, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TOut> Compile<TIn1, TIn2, TOut>(Variable var1, Variable var2)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TIn3">
/// The type of the passed argument number 3
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <param name="var3">
/// The variable corresponding to the function's argument number 3
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TIn3, TOut> Compile<TIn1, TIn2, TIn3, TOut>(Variable var1, Variable var2, Variable var3)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TIn3, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TIn3">
/// The type of the passed argument number 3
/// </typeparam>
/// <typeparam name="TIn4">
/// The type of the passed argument number 4
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <param name="var3">
/// The variable corresponding to the function's argument number 3
/// </param>
/// <param name="var4">
/// The variable corresponding to the function's argument number 4
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TIn3, TIn4, TOut> Compile<TIn1, TIn2, TIn3, TIn4, TOut>(Variable var1, Variable var2, Variable var3, Variable var4)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TIn3, TIn4, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3) , (typeof(TIn4), var4) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TIn3">
/// The type of the passed argument number 3
/// </typeparam>
/// <typeparam name="TIn4">
/// The type of the passed argument number 4
/// </typeparam>
/// <typeparam name="TIn5">
/// The type of the passed argument number 5
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <param name="var3">
/// The variable corresponding to the function's argument number 3
/// </param>
/// <param name="var4">
/// The variable corresponding to the function's argument number 4
/// </param>
/// <param name="var5">
/// The variable corresponding to the function's argument number 5
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TIn3, TIn4, TIn5, TOut> Compile<TIn1, TIn2, TIn3, TIn4, TIn5, TOut>(Variable var1, Variable var2, Variable var3, Variable var4, Variable var5)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TIn3, TIn4, TIn5, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3) , (typeof(TIn4), var4) , (typeof(TIn5), var5) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TIn3">
/// The type of the passed argument number 3
/// </typeparam>
/// <typeparam name="TIn4">
/// The type of the passed argument number 4
/// </typeparam>
/// <typeparam name="TIn5">
/// The type of the passed argument number 5
/// </typeparam>
/// <typeparam name="TIn6">
/// The type of the passed argument number 6
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <param name="var3">
/// The variable corresponding to the function's argument number 3
/// </param>
/// <param name="var4">
/// The variable corresponding to the function's argument number 4
/// </param>
/// <param name="var5">
/// The variable corresponding to the function's argument number 5
/// </param>
/// <param name="var6">
/// The variable corresponding to the function's argument number 6
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TOut> Compile<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TOut>(Variable var1, Variable var2, Variable var3, Variable var4, Variable var5, Variable var6)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3) , (typeof(TIn4), var4) , (typeof(TIn5), var5) , (typeof(TIn6), var6) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TIn3">
/// The type of the passed argument number 3
/// </typeparam>
/// <typeparam name="TIn4">
/// The type of the passed argument number 4
/// </typeparam>
/// <typeparam name="TIn5">
/// The type of the passed argument number 5
/// </typeparam>
/// <typeparam name="TIn6">
/// The type of the passed argument number 6
/// </typeparam>
/// <typeparam name="TIn7">
/// The type of the passed argument number 7
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <param name="var3">
/// The variable corresponding to the function's argument number 3
/// </param>
/// <param name="var4">
/// The variable corresponding to the function's argument number 4
/// </param>
/// <param name="var5">
/// The variable corresponding to the function's argument number 5
/// </param>
/// <param name="var6">
/// The variable corresponding to the function's argument number 6
/// </param>
/// <param name="var7">
/// The variable corresponding to the function's argument number 7
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TIn7, TOut> Compile<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TIn7, TOut>(Variable var1, Variable var2, Variable var3, Variable var4, Variable var5, Variable var6, Variable var7)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TIn7, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3) , (typeof(TIn4), var4) , (typeof(TIn5), var5) , (typeof(TIn6), var6) , (typeof(TIn7), var7) });
/// <summary>
/// Compiles a given expression into a native lambda. We use the default protocol.
/// If you plan using non-standard types, consider passing a compilation protocol
/// </summary>
/// <typeparam name="TIn1">
/// The type of the passed argument number 1
/// </typeparam>
/// <typeparam name="TIn2">
/// The type of the passed argument number 2
/// </typeparam>
/// <typeparam name="TIn3">
/// The type of the passed argument number 3
/// </typeparam>
/// <typeparam name="TIn4">
/// The type of the passed argument number 4
/// </typeparam>
/// <typeparam name="TIn5">
/// The type of the passed argument number 5
/// </typeparam>
/// <typeparam name="TIn6">
/// The type of the passed argument number 6
/// </typeparam>
/// <typeparam name="TIn7">
/// The type of the passed argument number 7
/// </typeparam>
/// <typeparam name="TIn8">
/// The type of the passed argument number 8
/// </typeparam>
/// <typeparam name="TOut">
/// The return type
/// </typeparam>
/// <param name="var1">
/// The variable corresponding to the function's argument number 1
/// </param>
/// <param name="var2">
/// The variable corresponding to the function's argument number 2
/// </param>
/// <param name="var3">
/// The variable corresponding to the function's argument number 3
/// </param>
/// <param name="var4">
/// The variable corresponding to the function's argument number 4
/// </param>
/// <param name="var5">
/// The variable corresponding to the function's argument number 5
/// </param>
/// <param name="var6">
/// The variable corresponding to the function's argument number 6
/// </param>
/// <param name="var7">
/// The variable corresponding to the function's argument number 7
/// </param>
/// <param name="var8">
/// The variable corresponding to the function's argument number 8
/// </param>
/// <returns>
/// Returns a natively-compiled delegate
/// </returns>
public Func<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TIn7, TIn8, TOut> Compile<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TIn7, TIn8, TOut>(Variable var1, Variable var2, Variable var3, Variable var4, Variable var5, Variable var6, Variable var7, Variable var8)
=> IntoLinqCompiler.Compile<Func<TIn1, TIn2, TIn3, TIn4, TIn5, TIn6, TIn7, TIn8, TOut>>(this, typeof(TOut), new(),
new[] { (typeof(TIn1), var1), (typeof(TIn2), var2) , (typeof(TIn3), var3) , (typeof(TIn4), var4) , (typeof(TIn5), var5) , (typeof(TIn6), var6) , (typeof(TIn7), var7) , (typeof(TIn8), var8) });
}
}