private bool TryHandleMethodCall(string name, Expression[] expressions, List<object> dotOperatorStack, ref object result )
{
object last = dotOperatorStack.Last();
if (last is EmitterList // add more types that we want to support
)
{
try
{
Type type = last.GetType();
Type[] argTypes = new Type[expressions.Length];
List<object> evaluatedExpressions = new List<object>();
for(int i = 0; i < expressions.Length; i++)
{
var expression = expressions[i];
object evaluated = expression.Evaluate();
evaluatedExpressions.Add(evaluated);
if (evaluated != null)
{
argTypes[i] = evaluated.GetType();
}
else
{
// This shouldn't happen...should it? Hard to say
argTypes[i] = typeof(object);
}
}
MethodInfo method = type.GetMethod(name, argTypes);
result = method.Invoke(last, evaluatedExpressions.ToArray());
}
catch (Exception e)
{
int m = 3;
}
return true;
}
else
{
return false;
}
}