Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Feb 2, 2025
1 parent 19ce4cd commit ab2f8c0
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions YantraJS.Core/LinqExpressions/JSValueBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class JSValueBuilder
//private static MethodInfo _StrictEqualsLiteralString
// = type.PublicMethod(nameof(JSValue.StrictEqualsLiteral), typeof(string));

private static MethodInfo _Negate
= type.PublicMethod(nameof(JSValue.Negate));
//private static MethodInfo _Negate
// = type.PublicMethod(nameof(JSValue.Negate));

public static Expression AddString(Expression target, Expression @string)
{
Expand Down Expand Up @@ -141,16 +141,17 @@ public static Expression PrototypeChain(Expression exp)

public static Expression Negate(Expression exp)
{
return Expression.Call(exp, _Negate);
// return Expression.Call(exp, _Negate);
return exp.CallExpression<JSValue, JSValue>(() => (x) => x.Negate());
}

public static Expression Power(Expression left,Expression right) {
// return Expression.Call(left, _Power, right);
return left.CallExpression<JSValue, JSValue, JSValue>(() => (x, a) => x.Power(a), right);
}

private static PropertyInfo _BooleanValue =
type.Property(nameof(JSValue.BooleanValue));
//private static PropertyInfo _BooleanValue =
// type.Property(nameof(JSValue.BooleanValue));
public static Expression BooleanValue(Expression exp)
{
if(exp.NodeType == Expressions.YExpressionType.Conditional && exp is YConditionalExpression ce)
Expand All @@ -168,16 +169,18 @@ public static Expression BooleanValue(Expression exp)
{
return YExpression.Constant(false);
}
return Expression.Property(exp, _BooleanValue);
// return Expression.Property(exp, _BooleanValue);
return exp.PropertyExpression<JSValue, bool>(() => (x) => x.BooleanValue);
}


private static MethodInfo _Add =
type.InternalMethod(nameof(Core.JSValue.AddValue), typeof(JSValue));
//private static MethodInfo _Add =
// type.InternalMethod(nameof(Core.JSValue.AddValue), typeof(JSValue));

public static Expression Add(Expression target, Expression value)
{
return Expression.Call(target, _Add, value);
// return Expression.Call(target, _Add, value);
return target.CallExpression<JSValue, JSValue, JSValue>(() => (x, a) => x.AddValue(a), value);
}

private static MethodInfo _TypeOf =
Expand Down Expand Up @@ -390,6 +393,7 @@ internal static MethodInfo _CreateInstance
public static Expression CreateInstance(Expression target, Expression args)
{
return Expression.Call(target, _CreateInstance, args);
// return target.CallExpression<JSValue, JSValue>(() => (x) => x.CreateInstance())
}

internal static MethodInfo StaticEquals
Expand Down Expand Up @@ -520,14 +524,14 @@ public static Expression GetAllKeys(Expression target)
;
}

private static MethodInfo _ConvertTo =
type.InternalMethod(nameof(JSValue.TryConvertTo), typeof(Type), typeof(object).MakeByRefType());
//private static MethodInfo _ConvertTo =
// type.InternalMethod(nameof(JSValue.TryConvertTo), typeof(Type), typeof(object).MakeByRefType());

private static MethodInfo _ForceConvert =
type.PublicMethod(nameof(JSValue.ForceConvert), typeof(Type));
//private static MethodInfo _ForceConvert =
// type.PublicMethod(nameof(JSValue.ForceConvert), typeof(Type));

private static MethodInfo _Convert =
type.InternalMethod(nameof(JSValue.Convert), typeof(Type), typeof(object));
//private static MethodInfo _Convert =
// type.InternalMethod(nameof(JSValue.Convert), typeof(Type), typeof(object));

//public static Expression Convert(Expression jsValue, Type type, Expression defaultValue)
//{
Expand Down

0 comments on commit ab2f8c0

Please sign in to comment.