private FunctionNode TryGetCurrentFunctionFromExpression(ReturnNode returnNode) { AstNode node = returnNode; while (node != null && node.Kind != SyntaxKind.FunctionDefinitionExpression) { node = node.Parent; if (node != null && node.Kind == SyntaxKind.FunctionDefinitionExpression) { return(node as FunctionNode); } } return(null); }
public override XzaarExpression Visit(ReturnNode returnNode) { if (returnNode.ReturnExpression != null) { var currentFunction = TryGetCurrentFunctionFromExpression(returnNode); var t = TryGetTypeFromExpression(returnNode.ReturnExpression, currentFunction); if (t != null) { Found(t); } if (t == null) { // we know that this function isnt returning void, so lets return 'object' Found(XzaarBaseTypes.Any); } } return(null); }