public override InoTypeEnum Visit(FunctionDeclarationAstNode node) { if (node.Body != null) { Visit(node.Parameters); if (IsFirstWalk) { ParamDict.Add(node.Symbol, CopyNodeList(ParamNodes)); //Add the functions current parameters for later checking, then clear it for next time ParamNodes.Clear(); } Visit(node.Body); } else { return(InoTypeEnum.undefined); } if (IsFirstWalk) { node.InoType = CurrentReturnType; FunctionTypes.Add(node.Symbol, CurrentReturnType); } CurrentReturnType = InoTypeEnum.undefined; return(InoTypeEnum.undefined); }
public override string Visit(FunctionDeclarationAstNode node) { string id = Visit(node.Id); string body = ""; if (node.InoType != InoTypeEnum.undefined) { id = node.InoType + " " + id; } if (IsLoop && node.Symbol.Name == "main") { IndentationDepth++; if (node.Body != null) { body = Visit(node.Body); } IndentationDepth--; return(body); } if (node.Symbol.Name.ToLower() == "setup") { HasSetup = true; } if (IsGlobal && node.Symbol.Name != "main") { string parameters = $"({Visit(node.Parameters)})"; IndentationDepth++; if (node.Body != null) { body = Visit(node.Body); } IndentationDepth--; return(id + parameters + "{\n" + body + "\n}"); } else { return(""); } }