void TypeDecl.IVisitor.Visit(FunctionTypeDecl decl) { Fix(decl); Execute(decl.ReturnType); foreach (var paremter in decl.Parameters) { Execute(paremter.Type); } }
internal static void ParseTypeContinueAfterName(string[] tokens, ref int index, ref CallingConvention callingConvention, out TypeDecl decl, out Action <TypeDecl> continuation) { decl = null; continuation = null; while (true) { if (CppParser.Token(tokens, ref index, "[")) { var oldIndex = index; CppParser.SkipUntil(tokens, ref index, "]"); var arrayDecl = new ArrayTypeDecl { Expression = tokens .Skip(oldIndex) .Take(index - 1 - oldIndex) .Aggregate("", (a, b) => a == "" ? b : a + " " + b), }; if (decl == null) { continuation = x => arrayDecl.Element = x; } else { arrayDecl.Element = decl; } decl = arrayDecl; } else if (CppParser.Token(tokens, ref index, "(")) { var funcDecl = new FunctionTypeDecl { Const = false, CallingConvention = callingConvention, Parameters = new List <VarDecl>(), }; callingConvention = CallingConvention.Default; if (decl == null) { continuation = x => funcDecl.ReturnType = x; } else { funcDecl.ReturnType = decl; } decl = funcDecl; bool skipParameters = false; if (CppParser.Token(tokens, ref index, "void")) { if (CppParser.Token(tokens, ref index, ")")) { skipParameters = true; } else { index--; } } if (!skipParameters && !CppParser.Token(tokens, ref index, ")")) { while (true) { string name = null; var parameterType = EnsureType(tokens, ref index, out name); funcDecl.Parameters.Add(new VarDecl { Static = false, Name = name, Type = parameterType, }); if (CppParser.Token(tokens, ref index, "=")) { CppParser.SkipUntilInTemplate(tokens, ref index, ",", ")", ";"); index--; } if (CppParser.Token(tokens, ref index, ")")) { break; } CppParser.EnsureToken(tokens, ref index, ","); } } while (true) { if (CppParser.Token(tokens, ref index, "const")) { funcDecl.Const = true; } else if (CppParser.Token(tokens, ref index, "override")) { } else { break; } } } else { break; } } }