diff --git a/YantraJS.Core/LinqExpressions/JSGeneratorFunctionBuilderV2.cs b/YantraJS.Core/LinqExpressions/JSGeneratorFunctionBuilderV2.cs index 2f2702fc..6f2c3cb9 100644 --- a/YantraJS.Core/LinqExpressions/JSGeneratorFunctionBuilderV2.cs +++ b/YantraJS.Core/LinqExpressions/JSGeneratorFunctionBuilderV2.cs @@ -13,20 +13,21 @@ using SwitchCase = YantraJS.Expressions.YSwitchCaseExpression; using GotoExpression = YantraJS.Expressions.YGoToExpression; using TryExpression = YantraJS.Expressions.YTryCatchFinallyExpression; +using YantraJS.Core.LambdaGen; namespace YantraJS.ExpHelper { public class JSGeneratorFunctionBuilderV2 { - private static Type type = typeof(JSGeneratorFunctionV2); - - private static ConstructorInfo _New = - type.Constructor( - typeof(JSGeneratorDelegateV2), StringSpanBuilder.RefType, StringSpanBuilder.RefType); public static Expression New(Expression @delegate, Expression name, Expression code) { - return Expression.New(_New, @delegate, name, code); + return NewLambdaExpression.NewExpression(() => + () => new JSGeneratorFunctionV2((JSGeneratorDelegateV2)null, "", "") + ,@delegate + ,name + ,code); + // return Expression.New(_New, @delegate, name, code); } } } diff --git a/YantraJS.Core/LinqExpressions/JSNullBuilder.cs b/YantraJS.Core/LinqExpressions/JSNullBuilder.cs index 4314c49b..c32608af 100644 --- a/YantraJS.Core/LinqExpressions/JSNullBuilder.cs +++ b/YantraJS.Core/LinqExpressions/JSNullBuilder.cs @@ -11,6 +11,7 @@ using SwitchCase = YantraJS.Expressions.YSwitchCaseExpression; using GotoExpression = YantraJS.Expressions.YGoToExpression; using TryExpression = YantraJS.Expressions.YTryCatchFinallyExpression; +using YantraJS.Core.LambdaGen; namespace YantraJS.ExpHelper { @@ -18,11 +19,13 @@ public class JSNullBuilder { public static Expression Value = - Expression.TypeAs( - Expression.Field( - null, - typeof(JSNull) - .GetField(nameof(JSNull.Value))), - typeof(JSValue)); + // Expression.TypeAs( + NewLambdaExpression.StaticFieldExpression(() => () => JSNull.Value) + //, Expression.Field( + // null, + // typeof(JSNull) + // .GetField(nameof(JSNull.Value))), + // typeof(JSValue)) + ; } } diff --git a/YantraJS.Core/LinqExpressions/JSNumberBuilder.cs b/YantraJS.Core/LinqExpressions/JSNumberBuilder.cs index 5365c09a..132a234c 100644 --- a/YantraJS.Core/LinqExpressions/JSNumberBuilder.cs +++ b/YantraJS.Core/LinqExpressions/JSNumberBuilder.cs @@ -12,38 +12,44 @@ using SwitchCase = YantraJS.Expressions.YSwitchCaseExpression; using GotoExpression = YantraJS.Expressions.YGoToExpression; using TryExpression = YantraJS.Expressions.YTryCatchFinallyExpression; +using YantraJS.Core.LambdaGen; namespace YantraJS.ExpHelper { public class JSNumberBuilder { - static Type type = typeof(JSNumber); + // static Type type = typeof(JSNumber); public static Expression NaN = - Expression.Field(null, type.GetField(nameof(JSNumber.NaN))); + NewLambdaExpression.StaticFieldExpression(() => () => JSNumber.NaN); + // Expression.Field(null, type.GetField(nameof(JSNumber.NaN))); public static Expression Zero = - Expression.Field(null, type.GetField(nameof(JSNumber.Zero))); + NewLambdaExpression.StaticFieldExpression(() => () => JSNumber.Zero); + // Expression.Field(null, type.GetField(nameof(JSNumber.Zero))); public static Expression One = - Expression.Field(null, type.GetField(nameof(JSNumber.One))); + NewLambdaExpression.StaticFieldExpression(() => () => JSNumber.One); + // Expression.Field(null, type.GetField(nameof(JSNumber.One))); public static Expression MinusOne = - Expression.Field(null, type.GetField(nameof(JSNumber.MinusOne))); + NewLambdaExpression.StaticFieldExpression(() => () => JSNumber.MinusOne); + // Expression.Field(null, type.GetField(nameof(JSNumber.MinusOne))); public static Expression Two = - Expression.Field(null, type.GetField(nameof(JSNumber.Two))); + NewLambdaExpression.StaticFieldExpression(() => () => JSNumber.Two); + // Expression.Field(null, type.GetField(nameof(JSNumber.Two))); - private static FieldInfo _Value = - type.InternalField(nameof(Core.JSNumber.value)); + //private static FieldInfo _Value = + // type.InternalField(nameof(Core.JSNumber.value)); - public static Expression Value(Expression ex) - { - return Expression.Field(ex, _Value); - } + //public static Expression Value(Expression ex) + //{ + // return Expression.Field(ex, _Value); + //} - private static ConstructorInfo _NewDouble - = type.Constructor(typeof(double)); + //private static ConstructorInfo _NewDouble + // = type.Constructor(typeof(double)); public static Expression New(Expression exp) { @@ -51,16 +57,19 @@ public static Expression New(Expression exp) { exp = Expression.Convert(exp, typeof(double)); } - return Expression.TypeAs(Expression.New(_NewDouble, exp), typeof(JSValue)); + return Expression.TypeAs( + NewLambdaExpression.NewExpression(() => () => new JSNumber((double)0), exp) + , typeof(JSValue)); + // return Expression.TypeAs(Expression.New(_NewDouble, exp), typeof(JSValue)); } - private static MethodInfo _AddValue = - type.InternalMethod(nameof(Core.JSValue.AddValue), typeof(Core.JSValue)); + //private static MethodInfo _AddValue = + // type.InternalMethod(nameof(Core.JSValue.AddValue), typeof(Core.JSValue)); - public static Expression AddValue(Expression target, Expression value) - { - return Expression.Call(target, _AddValue, value); - } + //public static Expression AddValue(Expression target, Expression value) + //{ + // return Expression.Call(target, _AddValue, value); + //} }