Skip to content

Commit aae5461

Browse files
committed
Methods optimized
1 parent 94697c7 commit aae5461

1 file changed

Lines changed: 19 additions & 27 deletions

File tree

YantraJS.Core/LinqExpressions/JSFunctionBuilder.cs

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
11
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;
72
using System.Reflection;
8-
using System.Security.Cryptography;
9-
using System.Security.Cryptography.X509Certificates;
10-
using System.Text;
113
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;
184
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;
255
using YantraJS.Core.LambdaGen;
266

277
namespace YantraJS.ExpHelper
@@ -68,10 +48,10 @@ public static Expression Prototype(Expression target)
6848
}
6949

7050

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) });
7555

7656
private static FieldInfo _f =
7757
type.InternalField(nameof(JSFunction.f));
@@ -111,14 +91,26 @@ public static Expression InvokeFunction(Expression target, Expression args, bool
11191
Expression.Assign(pe, target),
11292
Expression.Condition(JSValueBuilder.IsNullOrUndefined(pe),
11393
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+
));
11598
}
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);
117101
}
118102

119103
public static Expression New(Expression del, Expression name, Expression code, int length)
120104
{
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,
122114
name,
123115
code,
124116
Expression.Constant(length),

0 commit comments

Comments
 (0)