// try and find an appropriate return type by looking for a return instruction. if one cannot be found then we will return void public XzaarType GetReturnType(XzaarTypeFinderContext typeFinderContext) { if ((object)this.returnType != null) { return(returnType); } var typeFinder = new TypeFinderVisitor(typeFinderContext); returnType = FindReturnType(Body, typeFinder) ?? (XzaarType)typeof(void); return(returnType); }
private XzaarType FindReturnType(AstNode child, TypeFinderVisitor typeFinder) { child.Accept(typeFinder); if (typeFinder.FoundType) { return(typeFinder.Type); } foreach (var child1 in child.Children) { var returnType = FindReturnType(child1, typeFinder); if (returnType != null) { return(returnType); } } return(null); }