Пример #1
0
        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);
        }
Пример #2
0
 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);
 }