/// <summary> /// Should generate the code according to the specification of the algebra. /// </summary> /// <param name="S">The specification of the algebra. The specification also lists the names of the files /// to be generated, or at least the base path.</param> /// <param name="plugins">The plugins which Gaigen found that support the same language as this code generator.</param> /// <returns>a list of filenames; the names of the files that were generated. This may be used /// for post processing.</returns> public List<string> GenerateCode(Specification S, List<CodeGeneratorPlugin> plugins) { // disable all inlining since the Java language does not support this: S.SetInlineNone(); CreatePackageDirectory(S); CoGsharp.CoG cog = InitCog(S); CG.Shared.CGdata cgd = new G25.CG.Shared.CGdata(plugins, cog); cgd.SetDependencyPrefix("missing_function_"); // this makes sure that the user sees the function call is a missing dependency G25.CG.Shared.FunctionGeneratorInfo FGI = (S.m_generateTestSuite) ? new G25.CG.Shared.FunctionGeneratorInfo() : null; // the fields in this variable are set by Functions.WriteFunctions() and reused by TestSuite.GenerateCode() { // pregenerated code that will go into main source // generate code for parts of the geometric product, dual, etc (works in parallel internally) try { bool declOnly = false; G25.CG.Shared.PartsCode.GeneratePartsCode(S, cgd, declOnly); } catch (G25.UserException E) { cgd.AddError(E); } // write function (works in parallel internally) G25.CG.Shared.Functions.WriteFunctions(S, cgd, FGI, Functions.GetFunctionGeneratorPlugins(cgd)); } List<string> generatedFiles = new List<string>(); // generate Doxyfile generatedFiles.Add(G25.CG.Shared.Util.GenerateDoxyfile(S, cgd)); // generate source files / classes for all GMV, SMV, GOM, SOM types generatedFiles.AddRange(GenerateClasses(S, cgd)); // generate source generatedFiles.AddRange(Source.GenerateCode(S, cgd)); // generate smv type enum generatedFiles.AddRange(SmvType.GenerateCode(S, cgd)); // generate GroupBitmap class generatedFiles.AddRange(GroupBitmap.GenerateCode(S, cgd)); // generate multivector interfaces generatedFiles.AddRange(MvInterface.GenerateCode(S, cgd)); // generate parser generatedFiles.AddRange(Parser.GenerateCode(S, cgd)); // generate report usage code generatedFiles.AddRange(ReportUsage.GenerateCode(S, cgd)); // report errors and missing deps to user cgd.PrintErrors(S); cgd.PrintMissingDependencies(S); if ((cgd.GetNbErrors() == 0) && (cgd.GetNbMissingDependencies() == 0) && S.m_generateTestSuite) { // generate test suite generatedFiles.AddRange(TestSuite.GenerateCode(S, cgd, FGI)); } return generatedFiles; }
/// <summary> /// Generate all code according to the specification of the algebra. /// </summary> /// <param name="S">The specification of the algebra. The specification also lists the names of the files /// to be generated, or at least the base path.</param> /// <param name="plugins">The plugins which Gaigen found that support the same language as this code generator.</param> /// <returns>a list of filenames; the names of the files that were generated. This may be used /// for post processing.</returns> public List <string> GenerateCode(Specification S, List <CodeGeneratorPlugin> plugins) { // disable all inlining since the C language does not support this: S.SetInlineNone(); CoGsharp.CoG cog = InitCog(S); CG.Shared.CGdata cgd = new G25.CG.Shared.CGdata(plugins, cog); cgd.SetDependencyPrefix("missing_function_"); // this makes sure that the user sees the function call is a missing dependency G25.CG.Shared.FunctionGeneratorInfo FGI = (S.m_generateTestSuite) ? new G25.CG.Shared.FunctionGeneratorInfo() : null; // the fields in this variable are set by Functions.WriteFunctions() and reused by TestSuite.GenerateCode() { // pregenerated code that will go into header, source // generate code for parts of the geometric product, dual, etc (works in parallel internally) try { bool declOnly = false; G25.CG.Shared.PartsCode.GeneratePartsCode(S, cgd, declOnly); } catch (G25.UserException E) { cgd.AddError(E); } // write set zero, set, copy, copy between float types, extract coordinate, largest coordinate, etc (works in parallel internally) try { GenerateSetFunctions(S, plugins, cgd); } catch (G25.UserException E) { cgd.AddError(E); } // write function (works in parallel internally) G25.CG.Shared.Functions.WriteFunctions(S, cgd, FGI, Functions.GetFunctionGeneratorPlugins(cgd)); } List <string> generatedFiles = new List <string>(); // generate Doxyfile generatedFiles.Add(G25.CG.Shared.Util.GenerateDoxyfile(S, cgd)); // generate header generatedFiles.AddRange(Header.GenerateCode(S, cgd)); // generate source generatedFiles.AddRange(Source.GenerateCode(S, cgd)); // generate parser generatedFiles.AddRange(Parser.GenerateCode(S, cgd)); // report errors and missing deps to user cgd.PrintErrors(S); cgd.PrintMissingDependencies(S); if ((cgd.GetNbErrors() == 0) && (cgd.GetNbMissingDependencies() == 0) && S.m_generateTestSuite) { // if no errors, then generate testing code TestSuite.GenerateCode(S, cgd, FGI); } // Generate random number generator source code (Mersenne Twister). // This must be done last since the testing code may require it! if (cgd.GetFeedback(G25.CG.C.MainGenerator.MERSENNE_TWISTER) == "true") { generatedFiles.AddRange(RandomMT.GenerateCode(S, cgd)); } return(generatedFiles); }
/// <summary> /// Should generate the code according to the specification of the algebra. /// </summary> /// <param name="S">The specification of the algebra. The specification also lists the names of the files /// to be generated, or at least the base path.</param> /// <param name="plugins">The plugins which Gaigen found that support the same language as this code generator.</param> /// <returns>a list of filenames; the names of the files that were generated. This may be used /// for post processing.</returns> public List<string> GenerateCode(Specification S, List<CodeGeneratorPlugin> plugins) { // disable all inlining since the C# language does not support this: S.SetInlineNone(); CoGsharp.CoG cog = InitCog(S); CG.Shared.CGdata cgd = new G25.CG.Shared.CGdata(plugins, cog); cgd.SetDependencyPrefix("missing_function_"); // this makes sure that the user sees the function call is a missing dependency G25.CG.Shared.FunctionGeneratorInfo FGI = (S.m_generateTestSuite) ? new G25.CG.Shared.FunctionGeneratorInfo() : null; // the fields in this variable are set by Functions.WriteFunctions() and reused by TestSuite.GenerateCode() { // pregenerated code that will go into main source // generate code for parts of the geometric product, dual, etc (works in parallel internally) try { bool declOnly = false; G25.CG.Shared.PartsCode.GeneratePartsCode(S, cgd, declOnly); } catch (G25.UserException E) { cgd.AddError(E); } // write function (works in parallel internally) G25.CG.Shared.Functions.WriteFunctions(S, cgd, FGI, Functions.GetFunctionGeneratorPlugins(cgd)); } List<string> generatedFiles = new List<string>(); // generate Doxyfile generatedFiles.Add(G25.CG.Shared.Util.GenerateDoxyfile(S, cgd)); // generate source files / classes for all GMV, SMV, GOM, SOM types generatedFiles.AddRange(GenerateClasses(S, cgd)); // generate source generatedFiles.AddRange(Source.GenerateCode(S, cgd)); // generate multivector interfaces generatedFiles.AddRange(MvInterface.GenerateCode(S, cgd)); // generate parser code generatedFiles.AddRange(Parser.GenerateCode(S, cgd)); // generate report usage code generatedFiles.AddRange(ReportUsage.GenerateCode(S, cgd)); // report errors and missing deps to user cgd.PrintErrors(S); cgd.PrintMissingDependencies(S); if ((cgd.GetNbErrors() == 0) && (cgd.GetNbMissingDependencies() == 0) && S.m_generateTestSuite) { // if no errors, then generate testing code TestSuite.GenerateCode(S, cgd, FGI); } return generatedFiles; }
/// <summary> /// Generate all code according to the specification of the algebra. /// </summary> /// <param name="S">The specification of the algebra. The specification also lists the names of the files /// to be generated, or at least the base path.</param> /// <param name="plugins">The plugins which Gaigen found that support the same language as this code generator.</param> /// <returns>a list of filenames; the names of the files that were generated. This may be used /// for post processing.</returns> public List<string> GenerateCode(Specification S, List<CodeGeneratorPlugin> plugins) { // disable all inlining since the C language does not support this: S.SetInlineNone(); CoGsharp.CoG cog = InitCog(S); CG.Shared.CGdata cgd = new G25.CG.Shared.CGdata(plugins, cog); cgd.SetDependencyPrefix("missing_function_"); // this makes sure that the user sees the function call is a missing dependency G25.CG.Shared.FunctionGeneratorInfo FGI = (S.m_generateTestSuite) ? new G25.CG.Shared.FunctionGeneratorInfo() : null; // the fields in this variable are set by Functions.WriteFunctions() and reused by TestSuite.GenerateCode() { // pregenerated code that will go into header, source // generate code for parts of the geometric product, dual, etc (works in parallel internally) try { bool declOnly = false; G25.CG.Shared.PartsCode.GeneratePartsCode(S, cgd, declOnly); } catch (G25.UserException E) {cgd.AddError(E);} // write set zero, set, copy, copy between float types, extract coordinate, largest coordinate, etc (works in parallel internally) try { GenerateSetFunctions(S, plugins, cgd); } catch (G25.UserException E) { cgd.AddError(E); } // write function (works in parallel internally) G25.CG.Shared.Functions.WriteFunctions(S, cgd, FGI, Functions.GetFunctionGeneratorPlugins(cgd)); } List<string> generatedFiles = new List<string>(); // generate Doxyfile generatedFiles.Add(G25.CG.Shared.Util.GenerateDoxyfile(S, cgd)); // generate header generatedFiles.AddRange(Header.GenerateCode(S, cgd)); // generate source generatedFiles.AddRange(Source.GenerateCode(S, cgd)); // generate parser generatedFiles.AddRange(Parser.GenerateCode(S, cgd)); // report errors and missing deps to user cgd.PrintErrors(S); cgd.PrintMissingDependencies(S); if ((cgd.GetNbErrors() == 0) && (cgd.GetNbMissingDependencies() == 0) && S.m_generateTestSuite) { // if no errors, then generate testing code TestSuite.GenerateCode(S, cgd, FGI); } // Generate random number generator source code (Mersenne Twister). // This must be done last since the testing code may require it! if (cgd.GetFeedback(G25.CG.C.MainGenerator.MERSENNE_TWISTER) == "true") generatedFiles.AddRange(RandomMT.GenerateCode(S, cgd)); return generatedFiles; }