public static IFunctionDefinition GetVariableOrFunctionDefinition(this IExpressionStatement es, out Variable v) {
v = null;
if (es == null || es.Expression == null) {
return null;
}
// Tree:
// <-
// x function(a)
//
//
var c = es.Expression.Children;
if (c.Count == 1) {
var op = c[0] as IOperator;
if (op != null) {
if (op.OperatorType == OperatorType.LeftAssign || op.OperatorType == OperatorType.Equals) {
v = op.LeftOperand as Variable;
if (v != null) {
return op.RightOperand as IFunctionDefinition;
}
}
else if (op.OperatorType == OperatorType.RightAssign) {
v = op.RightOperand as Variable;
}
}
}
return null;
}
}