public Expression ToExpression(ParseContext context) { var variable = context.GetVariable(Name); if (variable != null) { if (variable.Expression == null) { variable.Expression = Expression.Parameter(ParsedType, Name); } return variable.Expression; } return Expression.Parameter(ParsedType, Name); }
public void PreParseExpression(ParseContext context) { _paramTypes = new List<Type>(); for (int i = 0; i < Parameters.Length; i++) { Parameters[i].PreParseExpression(context); _paramTypes.Add(Parameters[i].ParsedType); } Type type = StaticDataType; if (StaticDataType == null) { type = Variable.ParsedType; if (Variable is OperationVariable) { var variable = context.GetVariable(((OperationVariable)Variable).Name); type = variable.DataType; } } var methodInfo = type.GetMethod( MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |BindingFlags.Static, null, _paramTypes.ToArray(), null); ParsedType = methodInfo.ReturnType; }
public Expression ToExpression(ParseContext context) { var pars = new List<Expression>(); foreach (var param in Parameters) { pars.Add(param.ToExpression(context)); } if (_paramTypes == null) { _paramTypes = new List<Type>(); for (int i = 0; i < Parameters.Length; i++) { Parameters[i].PreParseExpression(context); _paramTypes.Add(Parameters[i].ParsedType); } } Type type = StaticDataType; if (StaticDataType == null) { type = Variable.ParsedType; if (Variable is OperationVariable) { var variable = context.GetVariable(((OperationVariable)Variable).Name); type = variable.DataType; } } var method = ReflectionUtil.GetMethod(type, MethodName, _paramTypes); if (method.GoodFrom >= 0) { var startDefault = method.GoodFrom; while (startDefault < method.ParamValues.Count) { pars.Add(Operation.Constant(method.ParamValues[method.GoodFrom]).ToExpression(context)); startDefault++; } } var my = (MethodInfo)method.Method; if ((my.Attributes & MethodAttributes.Static)==0) { return Expression.Call(Variable.ToExpression(context), method.Method as MethodInfo, pars); } return Expression.Call(method.Method as MethodInfo, pars); }
public void PreParseExpression(ParseContext context) { var resultVar = context.GetVariable(Name); ParsedType = resultVar.DataType; }