|
1 | 1 | using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Diagnostics.Contracts; |
4 | | -using System.Linq; |
5 | | -using System.Linq.Expressions; |
6 | | -using System.Net.Http.Headers; |
7 | 2 | using System.Reflection; |
8 | | -using System.Security.Cryptography; |
9 | | -using System.Security.Cryptography.X509Certificates; |
10 | | -using System.Text; |
11 | 3 | using YantraJS.Core; |
12 | | -using YantraJS.Core.CodeGen; |
13 | | -using YantraJS.Core.Generator; |
14 | | -using YantraJS.Core.String; |
15 | | -using YantraJS.Extensions; |
16 | | - |
17 | | -using Exp = YantraJS.Expressions.YExpression; |
18 | 4 | using Expression = YantraJS.Expressions.YExpression; |
19 | | -using ParameterExpression = YantraJS.Expressions.YParameterExpression; |
20 | | -using LambdaExpression = YantraJS.Expressions.YLambdaExpression; |
21 | | -using LabelTarget = YantraJS.Expressions.YLabelTarget; |
22 | | -using SwitchCase = YantraJS.Expressions.YSwitchCaseExpression; |
23 | | -using GotoExpression = YantraJS.Expressions.YGoToExpression; |
24 | | -using TryExpression = YantraJS.Expressions.YTryCatchFinallyExpression; |
25 | 5 | using YantraJS.Core.LambdaGen; |
26 | 6 |
|
27 | 7 | namespace YantraJS.ExpHelper |
@@ -68,10 +48,10 @@ public static Expression Prototype(Expression target) |
68 | 48 | } |
69 | 49 |
|
70 | 50 |
|
71 | | - private static ConstructorInfo _New = |
72 | | - type.Constructor(new Type[] { typeof(JSFunctionDelegate), |
73 | | - StringSpanBuilder.RefType, |
74 | | - StringSpanBuilder.RefType, typeof(int), typeof(bool) }); |
| 51 | + //private static ConstructorInfo _New = |
| 52 | + // type.Constructor(new Type[] { typeof(JSFunctionDelegate), |
| 53 | + // StringSpanBuilder.RefType, |
| 54 | + // StringSpanBuilder.RefType, typeof(int), typeof(bool) }); |
75 | 55 |
|
76 | 56 | private static FieldInfo _f = |
77 | 57 | type.InternalField(nameof(JSFunction.f)); |
@@ -111,14 +91,26 @@ public static Expression InvokeFunction(Expression target, Expression args, bool |
111 | 91 | Expression.Assign(pe, target), |
112 | 92 | Expression.Condition(JSValueBuilder.IsNullOrUndefined(pe), |
113 | 93 | JSUndefinedBuilder.Value, |
114 | | - Expression.Call(pe, invokeFunction, args))); |
| 94 | + // Expression.Call(pe, invokeFunction, args) |
| 95 | + pe.CallExpression<JSFunction, Arguments, JSValue>(() => (x,a) => x.InvokeFunction(a), |
| 96 | + args) |
| 97 | + )); |
115 | 98 | } |
116 | | - return Expression.Call(target, invokeFunction, args); |
| 99 | + //return Expression.Call(target, invokeFunction, args); |
| 100 | + return target.CallExpression<JSFunction, Arguments, JSValue>(() => (x, a) => x.InvokeFunction(a), args); |
117 | 101 | } |
118 | 102 |
|
119 | 103 | public static Expression New(Expression del, Expression name, Expression code, int length) |
120 | 104 | { |
121 | | - return Expression.New(_New , del, |
| 105 | + return NewLambdaExpression.NewExpression<JSFunction>( |
| 106 | + () => () => new JSFunction( |
| 107 | + (JSFunctionDelegate)null, |
| 108 | + "", |
| 109 | + "", |
| 110 | + 0, |
| 111 | + false |
| 112 | + ) |
| 113 | + , del, |
122 | 114 | name, |
123 | 115 | code, |
124 | 116 | Expression.Constant(length), |
|
0 commit comments