当前位置: 首页>>代码示例>>C#>>正文


C# Specification.GetOutputPath方法代码示例

本文整理汇总了C#中Specification.GetOutputPath方法的典型用法代码示例。如果您正苦于以下问题:C# Specification.GetOutputPath方法的具体用法?C# Specification.GetOutputPath怎么用?C# Specification.GetOutputPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Specification的用法示例。


在下文中一共展示了Specification.GetOutputPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get list of generated filenames
            List<string> generatedFiles = new List<string>();
            if (S.m_parserType == PARSER.NONE) return generatedFiles; // nothing to do

            // get header filename
            string headerFilename = S.GetOutputFilename(G25.CG.CPP.Header.GetRawHeaderFilename(S));

            // get parser c source output path
            string parserSourceFilename = S.GetOutputPath(G25.CG.CPP.Parser.GetRawParserSourceFilename(S));
            generatedFiles.Add(parserSourceFilename);

            // get grammar output path
            string rawGrammarFilename = G25.CG.CPP.Parser.GetRawANTLRgrammarFilename(S);
            string grammarFilename = S.GetOutputPath(rawGrammarFilename);
            if (S.m_parserType == PARSER.ANTLR) // only really generated when parser is ANTLR
                generatedFiles.Add(grammarFilename);

            // get StringBuilder where all generated code goes
            StringBuilder sourceSB = new StringBuilder(); // parser source (if any) goes here
            StringBuilder grammarSB = new StringBuilder(); // grammar (if any) goes here

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(sourceSB, S);
            G25.CG.Shared.Util.WriteLicense(sourceSB, S);

            // parser declarations:
            if (S.m_parserType == PARSER.BUILTIN)
            {
                cgd.m_cog.EmitTemplate(sourceSB, "BuiltinParserSource_C_CPP", "S=", S, "FT=", S.m_floatTypes[0], "headerFilename=", headerFilename);
            }
            else if (S.m_parserType == PARSER.ANTLR)
            {
                // ANTLR cannot handle custom float types (like myDouble) the way it handles 'float' and 'double'.
                // So once again we have to apply a hack to get around this.
                // All this thank to Jim Lazy^H^H^H^HIdle who's too lazy to write a true C++ target for ANTLR. Thanks Jim.
                FloatType realFT = S.m_floatTypes[0];
                FloatType FT = GetANTLRfloatType(S);

                cgd.m_cog.EmitTemplate(sourceSB, "ANTLRparserSource_C_CPP", "S=", S, "FT=", FT, "realFT=", realFT, "headerFilename=", headerFilename, "grammarFilename=", S.GetOutputFilename(rawGrammarFilename));
                cgd.m_cog.EmitTemplate(grammarSB, "ANTLRgrammar_C_CPP", "S=", S, "FT=", FT, "realFT=", realFT, "headerFilename=", headerFilename);
            }

            // write all to file
            G25.CG.Shared.Util.WriteFile(parserSourceFilename, sourceSB.ToString());
            if (S.m_parserType == PARSER.ANTLR)
                G25.CG.Shared.Util.WriteFile(grammarFilename, grammarSB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:51,代码来源:parser.cs

示例2: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get list of generated filenames
            List<string> generatedFiles = new List<string>();
            if (S.m_parserType == PARSER.NONE) return generatedFiles; // nothing to do

            // get parser C# source output path
            string parserSourceFilename = S.GetOutputPath(GetRawParserSourceFilename(S));
            if (S.m_parserType == PARSER.BUILTIN)
                generatedFiles.Add(parserSourceFilename);

            // get parser exception source output path
            string parseExceptionSourceFilename = S.GetOutputPath(GetRawParseExceptionSourceFilename(S));
            generatedFiles.Add(parseExceptionSourceFilename);

            // get grammar output path
            string rawGrammarFilename = GetRawANTLRgrammarFilename(S);
            string grammarFilename = S.GetOutputPath(rawGrammarFilename);
            if (S.m_parserType == PARSER.ANTLR) // only really generated when parser is ANTLR
                generatedFiles.Add(grammarFilename);

            // get StringBuilder where all generated code goes
            StringBuilder sourceSB = new StringBuilder(); // parser source (if any) goes here
            StringBuilder exceptionSB = new StringBuilder(); // ParseException source goes here
            StringBuilder grammarSB = new StringBuilder(); // grammar (if any) goes here

            // parser exception
            G25.CG.Shared.Util.WriteCopyright(exceptionSB, S);
            G25.CG.Shared.Util.WriteLicense(exceptionSB, S);
            cgd.m_cog.EmitTemplate(exceptionSB, "ParseExceptionSource_CSharp", "S=", S);
            G25.CG.Shared.Util.WriteFile(parseExceptionSourceFilename, exceptionSB.ToString());

            // parser declarations:
            if (S.m_parserType == PARSER.BUILTIN)
            {
                // using ...
                Util.WriteGenericUsing(sourceSB, S);
                G25.CG.Shared.Util.WriteCopyright(sourceSB, S);
                G25.CG.Shared.Util.WriteLicense(sourceSB, S);
                cgd.m_cog.EmitTemplate(sourceSB, "BuiltinParserSource_CSharp_Java", "S=", S, "FT=", S.m_floatTypes[0]);
                G25.CG.Shared.Util.WriteFile(parserSourceFilename, sourceSB.ToString());
            }
            else if (S.m_parserType == PARSER.ANTLR)
            {
                cgd.m_cog.EmitTemplate(grammarSB, "ANTLRgrammar_CSharp_Java", "S=", S, "FT=", S.m_floatTypes[0]);
                G25.CG.Shared.Util.WriteFile(grammarFilename, grammarSB.ToString());
            }

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:50,代码来源:parser.cs

示例3: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();

            if (!S.m_reportUsage) return generatedFiles;

            string sourceFilename = S.GetOutputPath(GetRawSourceFilename(S));
            generatedFiles.Add(sourceFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // using ...
            Util.WriteGenericUsing(SB, S);
            SB.AppendLine("using System.Collections.Generic;");
            SB.AppendLine("using System.Text;");

            // open namespace
            G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

            cgd.m_cog.EmitTemplate(SB, "reportUsage");

            // close namespace
            G25.CG.Shared.Util.WriteCloseNamespace(SB, S);

            // write all to file
            G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:35,代码来源:reportusage.cs

示例4: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get list of generated filenames
            List<string> generatedFiles = new List<string>();
            if (S.m_parserType == PARSER.NONE) return generatedFiles; // nothing to do

            // get header filename
            string headerFilename = S.GetOutputFilename(G25.CG.C.Header.GetRawHeaderFilename(S));

            // get parser c source output path
            string parserSourceFilename = S.GetOutputPath(G25.CG.C.Parser.GetRawParserSourceFilename(S));
            generatedFiles.Add(parserSourceFilename);

            // get grammar output path
            string rawGrammarFilename = G25.CG.C.Parser.GetRawANTLRgrammarFilename(S);
            string grammarFilename = S.GetOutputPath(rawGrammarFilename);
            if (S.m_parserType == PARSER.ANTLR) // only really generated when parser is ANTLR
                generatedFiles.Add(grammarFilename);

            // get StringBuilder where all generated code goes
            StringBuilder sourceSB = new StringBuilder(); // parser source (if any) goes here
            StringBuilder grammarSB = new StringBuilder(); // grammar (if any) goes here

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(sourceSB, S);
            G25.CG.Shared.Util.WriteLicense(sourceSB, S);

            // parser declarations:
            if (S.m_parserType == PARSER.BUILTIN)
            {
                cgd.m_cog.EmitTemplate(sourceSB, "BuiltinParserSource_C_CPP", "S=", S, "FT=", S.m_floatTypes[0], "headerFilename=", headerFilename);
            }
            else if (S.m_parserType == PARSER.ANTLR)
            {
                cgd.m_cog.EmitTemplate(sourceSB, "ANTLRparserSource_C_CPP", "S=", S, "FT=", S.m_floatTypes[0], "headerFilename=", headerFilename, "grammarFilename=", S.GetOutputFilename(rawGrammarFilename));
                cgd.m_cog.EmitTemplate(grammarSB, "ANTLRgrammar_C_CPP", "S=", S, "FT=", S.m_floatTypes[0], "realFT=", S.m_floatTypes[0], "headerFilename=", headerFilename);
            }

            // write all to file
            G25.CG.Shared.Util.WriteFile(parserSourceFilename, sourceSB.ToString());
            if (S.m_parserType == PARSER.ANTLR)
                G25.CG.Shared.Util.WriteFile(grammarFilename, grammarSB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:45,代码来源:parser.cs

示例5: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();
            string sourceFilename = S.GetOutputPath(GetRawSourceFilename(S));
            generatedFiles.Add(sourceFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // open namespace
            G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

            SB.AppendLine("public interface GroupBitmap {");

            // group
            int[] gradeBitmap = new int[S.m_dimension + 1];
            for (int i = 0; i < S.m_GMV.NbGroups; i++)
            {
                gradeBitmap[S.m_GMV.Group(i)[0].Grade()] |= 1 << i;

                SB.Append("\tpublic static final int " + G25.CG.CSJ.GroupBitmap.GetGroupBitmapName(i) + "  = " + (1 << i) + "; // ");

                for (int j = 0; j < S.m_GMV.Group(i).Length; j++)
                {
                    if (j > 0) SB.Append(", ");
                    SB.Append(S.m_GMV.Group(i)[j].ToString(S.m_basisVectorNames));
                }
                SB.AppendLine();
            }
            SB.AppendLine();
            SB.AppendLine("\tpublic static final int ALL_GROUPS = " + ((1 << S.m_GMV.NbGroups) - 1) + "; // all groups");
            SB.AppendLine();

            // grade
            for (int i = 0; i <= S.m_dimension; i++)
            {
                SB.AppendLine("\tpublic static final int " + G25.CG.CSJ.GroupBitmap.GetGradeBitmapName(i) + " = " + gradeBitmap[i] + ";");
            }
            SB.AppendLine();
            SB.AppendLine("\tpublic static final int ALL_GRADES = " + ((1 << S.m_GMV.NbGroups) - 1) + "; // all grades");
            SB.AppendLine();

            SB.AppendLine("}");

            // close namespace
            G25.CG.Shared.Util.WriteCloseNamespace(SB, S);

            // write all to file
            G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:57,代码来源:groupbitmap.cs

示例6: GenerateCode

        /// <summary>
        /// Generates files for random number generation using MT.
        /// </summary>
        /// <param name="S">Specification of algebra.</param>
        /// <param name="cgd">Intermediate data for code generation. Also contains plugins and cog.</param>
        /// <returns>a list of filenames which were generated (full path).</returns>
        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();

            string headerFilename = S.GetOutputPath(G25.CG.C.RandomMT.GetRawMtHeaderFilename(S));
            string sourceFilename = S.GetOutputPath(G25.CG.C.RandomMT.GetRawMtSourceFilename(S));
            generatedFiles.Add(headerFilename);

            { // header
                StringBuilder SB = new StringBuilder();
                cgd.m_cog.EmitTemplate(SB, "mersenneTwisterHeader", "S=", S);
                G25.CG.Shared.Util.WriteFile(headerFilename, SB.ToString());
            }

            { // source
                StringBuilder SB = new StringBuilder();
                cgd.m_cog.EmitTemplate(SB, "mersenneTwisterSource", "S=", S);
                G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());
            }

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:29,代码来源:randommt.cs

示例7: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();
            string sourceFilename = S.GetOutputPath(GetRawSourceFilename(S));
            generatedFiles.Add(sourceFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // open namespace
            G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

            SB.AppendLine("public enum " + G25.CG.CSJ.GMV.SMV_TYPE + " {");

            Dictionary<string, int> STD = G25.CG.Shared.SmvUtil.GetSpecializedTypeDictionary(S);

            STD.Add("invalid", STD.Count);
            STD.Add("none", -1);

            bool appendComma = false;
            foreach (KeyValuePair<string, int> kvp in STD)
            {
                string name = G25.CG.Shared.ReportUsage.GetSpecializedConstantName(S, kvp.Key);
                if (appendComma) SB.AppendLine(",");
                SB.Append("\t" + name + "(" + kvp.Value + ", \"" + kvp.Key + "\")");
                appendComma = true;
            }
            SB.AppendLine(";");

            cgd.m_cog.EmitTemplate(SB, "SmvTypeEnum");

            // close namespace
            G25.CG.Shared.Util.WriteCloseNamespace(SB, S);

            // write all to file
            G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:44,代码来源:smvtype.cs

示例8: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();

            foreach (FloatType FT in S.m_floatTypes)
            {
                string sourceFilename = S.GetOutputPath(GetRawSourceFilename(S, FT));
                generatedFiles.Add(sourceFilename);

                // get StringBuilder where all generated code goes
                StringBuilder SB = new StringBuilder();

                // output license, copyright
                G25.CG.Shared.Util.WriteCopyright(SB, S);
                G25.CG.Shared.Util.WriteLicense(SB, S);

                // open namespace
                G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

                SB.AppendLine("public interface " + GetMvInterfaceName(S, FT) + " {");

                string gmvName = FT.GetMangledName(S, S.m_GMV.Name);
                cgd.m_cog.EmitTemplate(SB, "mvInterface", "gmvName=", gmvName);

                SB.AppendLine("}");

                // close namespace
                G25.CG.Shared.Util.WriteCloseNamespace(SB, S);

                // write all to file
                G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());
            }

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:36,代码来源:mvinterface.cs

示例9: GenerateCode

        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();
            string sourceFilename = S.GetOutputPath(G25.CG.C.Source.GetRawSourceFilename(S));
            generatedFiles.Add(sourceFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            { // #includes
                SB.AppendLine("#include <stdio.h>");
                if (cgd.GetFeedback(G25.CG.Shared.Main.NEED_TIME) == "true")
                    SB.AppendLine("#include <time.h> /* used to seed random generator */");
                SB.AppendLine("#include \"" + S.GetOutputFilename(G25.CG.C.Header.GetRawHeaderFilename(S)) + "\"");
            }

            GenerateTables(S, cgd, SB);

            // the list of names of smv types
            G25.CG.C.SMV.WriteSMVtypenames(SB, S, cgd);

            // write constant definitions
            G25.CG.C.Constants.WriteDefinitions(SB, S, cgd);

            // set to zero / copy floats
            cgd.m_cog.EmitTemplate(SB, "float_zero_copy_def", "S=", S, "MAX_N=", G25.CG.Shared.Main.MAX_EXPLICIT_ZERO);

            if (S.m_gmvCodeGeneration == GMV_CODE.RUNTIME)
            {
                cgd.m_cog.EmitTemplate(SB, "runtimeGpTablesDefs", "S=", S);
                cgd.m_cog.EmitTemplate(SB, "bitmapGp", "S=", S);
                cgd.m_cog.EmitTemplate(SB, "runtimeGpTable", "S=", S);
                foreach (G25.FloatType FT in S.m_floatTypes)
                {
                    cgd.m_cog.EmitTemplate(SB, "runtimeComputeGp", "S=", S, "FT=", FT);
                }
                cgd.m_cog.EmitTemplate(SB, "runtimeGpInitTables", "S=", S);
                cgd.m_cog.EmitTemplate(SB, "runtimeGpFreeTables", "S=", S);
            }

            // write compress source code
            WriteCompressSource(SB, S, cgd);

            cgd.m_cog.EmitTemplate(SB, "swapPointer");

            { // write toString
                bool def = true;
                G25.CG.C.ToString.WriteToString(SB, S, cgd, def);
            }

            //SB.AppendLine("/* def SB: */");
            SB.Append(cgd.m_defSB);

            // write all to file
            G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());

            return generatedFiles;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:63,代码来源:source.cs

示例10: GetClassOutputPath

        /// <summary>
        /// Path for output of source file  'name' with 'extension'
        /// </summary>
        /// <param name="S"></param>
        /// <param name="name">Name of class / source file.</param>
        /// <param name="extension">Do not include the dot.</param>
        /// <returns>Output path for name.extension</returns>
        internal static string GetClassOutputPath(Specification S, string name, string extension)
        {
            string packageName = G25.CG.Shared.Util.GetNamespaceName(S);
            string path =
                packageName.Replace('.', System.IO.Path.DirectorySeparatorChar) +  // package dir
                System.IO.Path.DirectorySeparatorChar +  // slash
                name +  // class
                "." +
                extension; // extension

            return S.GetOutputPath(path);
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:19,代码来源:main.cs

示例11: GenerateCode

        /// <summary>
        /// Generates a header file named S.m_namespace.h.
        /// </summary>
        /// <param name="S">Specification of algebra.</param>
        /// <param name="cgd">Intermediate data for code generation. Also contains plugins and cog.</param>
        /// <returns>a list of filenames which were generated (full path).</returns>
        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();
            string headerFilename = S.GetOutputPath(G25.CG.C.Header.GetRawHeaderFilename(S));
            generatedFiles.Add(headerFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // write main documentation
            WriteDoxyMainPage(SB, S, cgd);

            // open include guard
            G25.CG.Shared.Util.WriteOpenIncludeGuard(SB, GetRawHeaderFilename(S));

            { // #includes
                SB.AppendLine("");
                SB.AppendLine("#include <stdio.h>");
                SB.AppendLine("#include <stdlib.h>");
                SB.AppendLine("#include <string.h>");
                SB.AppendLine("#include <math.h>");
                if (cgd.GetFeedback(G25.CG.C.MainGenerator.MERSENNE_TWISTER) == "true")
                    SB.AppendLine("#include \"" + S.m_namespace + "_mt.h\"");
            }

            { // basic info

                {    // #define GROUP_ and GRADE_
                    SB.AppendLine("");

                    // group
                    int[] gradeBitmap = new int[S.m_dimension + 1];
                    for (int i = 0; i < S.m_GMV.NbGroups; i++)
                    {
                        gradeBitmap[S.m_GMV.Group(i)[0].Grade()] |= 1 << i;

                        SB.Append("/* group: ");
                        for (int j = 0; j < S.m_GMV.Group(i).Length; j++)
                        {
                            if (j > 0) SB.Append(", ");
                            SB.Append(S.m_GMV.Group(i)[j].ToString(S.m_basisVectorNames));
                        }
                        SB.AppendLine("*/");
                        SB.AppendLine("#define GROUP_" + i + " " + (1 << i));
                    }

                    // grade
                    for (int i = 0; i <= S.m_dimension; i++)
                        SB.AppendLine("#define GRADE_" + i + " " + gradeBitmap[i]);
                }

                cgd.m_cog.EmitTemplate(SB, "basicInfo", "S=", S);

                if (S.m_gmvCodeGeneration == GMV_CODE.RUNTIME)
                    cgd.m_cog.EmitTemplate(SB, "runtimeGpTablesHeader", "S=", S);
            }

            // #define for all specialized MV types
            if (S.m_reportUsage)
                G25.CG.C.SMV.WriteSMVtypeConstants(SB, S, cgd);

            // write structs for all GMV (all float types)
            G25.CG.C.GMV.WriteGMVstructs(SB, S, cgd);

            // write structs for all SMVs (all float types)
            G25.CG.C.SMV.WriteSMVstructs(SB, S, cgd);

            // write structs for all GOM (all float types)
            if (S.m_GOM != null)
                G25.CG.C.GOM.WriteGOMstructs(SB, S, cgd);

            // write structs for all SOMs (all float types)
            G25.CG.C.SOM.WriteSOMstructs(SB, S, cgd);

            { // write toString
                bool def = false;
                G25.CG.C.ToString.WriteToString(SB, S, cgd, def);
            }

            // write constant declarations
            G25.CG.C.Constants.WriteDeclarations(SB, S, cgd);

            // set to zero / copy floats
            cgd.m_cog.EmitTemplate(SB, "float_zero_copy_decl", "S=", S, "MAX_N=", G25.CG.Shared.Main.MAX_EXPLICIT_ZERO);

            //SB.AppendLine("/* decl SB: */");
            SB.Append(cgd.m_declSB);

            //SB.AppendLine("/* inline def SB: */");
//.........这里部分代码省略.........
开发者ID:Sciumo,项目名称:gaigen,代码行数:101,代码来源:header.cs

示例12: GetRawANTLRgrammarFilename

 public static string GetRawANTLRgrammarFilename(Specification S)
 {
     return S.GetOutputPath(S.m_namespace + ".g");
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:4,代码来源:parser.cs

示例13: GenerateDoxyfile

        /// <summary>
        /// Generates the Doxyfile which can be used to let Doxygen process the generate source code 
        /// to order to extract documentation from it.
        /// </summary>
        /// <param name="S">The specification, used for the output path and namespaces</param>
        /// <param name="cgd">CG data. Contains the code generator; the function uses the "doxyfile" template.</param>
        /// <returns>The full path of the generated doygen file.</returns>
        public static string GenerateDoxyfile(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename
            string rawFilename = "Doxyfile";
            string doxyFilename = S.GetOutputPath(rawFilename);

            // emit template
            cgd.m_cog.ClearOutput(); // get rid of any junk other users may have left behind
            cgd.m_cog.EmitTemplate("doxyfile", "S=", S, "Namespace=", S.m_namespace);

            // write all to file
            System.IO.StreamWriter W = null;
            try
            {
                // open "namespace.h" for writing
                try
                {
                    W = System.IO.File.CreateText(doxyFilename);
                }
                catch (Exception )
                {
                    throw new G25.UserException("Could create output file: " + doxyFilename);
                }
                W.Write(cgd.m_cog.GetOutputAndClear());
            }
            finally
            {
                if (W != null) W.Close();
                W = null;
            }
            return doxyFilename;
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:39,代码来源:util.cs

示例14: GenerateCode

        /// <summary>
        /// Generates a header file named S.m_namespace.h.
        /// </summary>
        /// <param name="S">Specification of algebra.</param>
        /// <param name="cgd">Intermediate data for code generation. Also contains plugins and cog.</param>
        /// <returns>a list of filenames which were generated (full path).</returns>
        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd)
        {
            // get filename, list of generated filenames
            List<string> generatedFiles = new List<string>();
            string headerFilename = S.GetOutputPath(GetRawHeaderFilename(S));
            generatedFiles.Add(headerFilename);

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // output license, copyright
            G25.CG.Shared.Util.WriteCopyright(SB, S);
            G25.CG.Shared.Util.WriteLicense(SB, S);

            // write main documentation
            WriteDoxyMainPage(SB, S, cgd);

            // open include guard
            G25.CG.Shared.Util.WriteOpenIncludeGuard(SB, GetRawHeaderFilename(S));

            { // #includes
                SB.AppendLine("");
                SB.AppendLine("#include <stdio.h>");
                SB.AppendLine("#include <stdlib.h>");
                SB.AppendLine("#include <string.h>");
                SB.AppendLine("#include <math.h>");
                SB.AppendLine("#include <string>");
                if (cgd.GetFeedback(G25.CG.Shared.Main.NEED_TIME) == "true")
                    SB.AppendLine("#include <time.h> /* used to seed random generator */");
                if (cgd.GetFeedback(G25.CG.Shared.Main.MERSENNE_TWISTER) == "true")
                    SB.AppendLine("#include \"" + S.m_namespace + "_mt.h\"");
                if (S.m_reportUsage)
                {
                    SB.AppendLine("#include <map>");
                }
            }

            G25.CG.Shared.Util.WriteOpenNamespace(SB, S);

            { // basic info

                {    // #define GROUP_ and GRADE_
                    SB.AppendLine("");

                    // group
                    int[] gradeBitmap = new int[S.m_dimension + 1];
                    for (int i = 0; i < S.m_GMV.NbGroups; i++)
                    {
                        gradeBitmap[S.m_GMV.Group(i)[0].Grade()] |= 1 << i;

                        SB.Append("// group: ");
                        for (int j = 0; j < S.m_GMV.Group(i).Length; j++)
                        {
                            if (j > 0) SB.Append(", ");
                            SB.Append(S.m_GMV.Group(i)[j].ToString(S.m_basisVectorNames));
                        }
                        SB.AppendLine("");
                        SB.AppendLine("#define GROUP_" + i + " " + (1 << i));
                    }

                    // grade
                    for (int i = 0; i <= S.m_dimension; i++)
                        SB.AppendLine("#define GRADE_" + i + " " + gradeBitmap[i]);
                }

                cgd.m_cog.EmitTemplate(SB, "basicInfo", "S=", S);

                if (S.m_gmvCodeGeneration == GMV_CODE.RUNTIME)
                {
                    G25.CG.Shared.Util.WriteOpenNamespace(SB, S, G25.CG.Shared.Main.RUNTIME_NAMESPACE);
                    cgd.m_cog.EmitTemplate(SB, "runtimeGpTablesHeader", "S=", S);
                    G25.CG.Shared.Util.WriteCloseNamespace(SB, S, G25.CG.Shared.Main.RUNTIME_NAMESPACE);
                }
            }

            // #define for all specialized MV types
            if (S.m_reportUsage)
                G25.CG.CPP.SMV.WriteSMVtypeConstants(SB, S, cgd);

            { // write all class types
                // write types for all GMV (all float types)
                G25.CG.CPP.GMV.WriteGMVtypes(SB, S, cgd);

                // write types for all SMVs (all float types)
                G25.CG.CPP.SMV.WriteSMVtypes(SB, S, cgd);

                // write types for all GOM (all float types)
                if (S.m_GOM != null)
                    G25.CG.CPP.GOM.WriteGOMtypes(SB, S, cgd);

                // write types for all SOMs (all float types)
                G25.CG.CPP.SOM.WriteSOMtypes(SB, S, cgd);
            }

//.........这里部分代码省略.........
开发者ID:Sciumo,项目名称:gaigen,代码行数:101,代码来源:header.cs

示例15: GenerateCode

        /// <summary>
        /// Generates a complete testing suite, including a main function.
        /// 
        /// The testing suite should test every function implemented, but depends
        /// on the code generator plugins to actually generate those tests.
        /// </summary>
        /// <param name="S">Specification of algebra.</param>
        /// <param name="cgd">Used to pass all kinds of info around.</param>
        /// <param name="FGI">Info about what FunctionGenerator to use for each FGS. Recycled from
        /// Function.WriteFunctions() for efficiency.</param>
        /// <returns></returns>
        public static List<string> GenerateCode(Specification S, G25.CG.Shared.CGdata cgd, G25.CG.Shared.FunctionGeneratorInfo FGI)
        {
            System.Console.WriteLine("Generating test suite . . .\n");
            cgd.SetDependencyPrefix(""); // we want missing dependencies to actually compile, and not generate an error based on function name

            // get list of generated filenames
            List<string> generatedFiles = new List<string>();
            string sourceFilename = S.GetOutputPath(G25.CG.C.TestSuite.GetRawTestSuiteFilename(S));
            generatedFiles.Add(sourceFilename);

            // reset code in cgd (get rid of all the code that was generated for the regular non-testsuite output)
            cgd.ResetSB();

            // get StringBuilder where all generated code goes
            StringBuilder SB = new StringBuilder();

            // #include all relevant headers
            SB.AppendLine("#include <time.h> /* used to seed random generator */");
            SB.AppendLine("#include \"" + S.GetOutputFilename(G25.CG.C.Header.GetRawHeaderFilename(S)) + "\"");
            if (S.m_parserType != PARSER.NONE)
            {
                //                        SB.AppendLine("#include \"" + S.GetOutputFilename(G25.CG.C.Parser.GetRawParserSourceFilename(S)) + "\"");
                if (S.m_parserType == PARSER.ANTLR)
                {
                    SB.AppendLine("#include \"" + S.GetOutputFilename(G25.CG.C.Parser.GetANTLRlexerHeaderFilename(S)) + "\"");
                    SB.AppendLine("#include \"" + S.GetOutputFilename(G25.CG.C.Parser.GetANTLRparserHeaderFilename(S)) + "\"");
                }
            }
            if (cgd.GetFeedback(G25.CG.C.MainGenerator.MERSENNE_TWISTER) == "true")
                SB.AppendLine("#include \"" + S.GetOutputFilename(G25.CG.C.RandomMT.GetRawMtHeaderFilename(S)) + "\"");

            // generate declarations for parts of the geometric product, dual, etc (works in parallel internally)
            try
            {
                bool declOnly = true;
                G25.CG.Shared.PartsCode.GeneratePartsCode(S, cgd, declOnly);
            }
            catch (G25.UserException E) { cgd.AddError(E); }

            // generate extra declarations
            foreach (FloatType FT in S.m_floatTypes)
            {
                // output internal compress function for all float types
                cgd.m_cog.EmitTemplate(cgd.m_defSB, "compress_decl",
                    "S=", S,
                    "FT=", FT,
                    "gmv=", S.m_GMV);
            }

            cgd.m_cog.EmitTemplate(cgd.m_defSB, "swapPointerDecl");

            // reset generated code (StringBuilders) of all CGDs
            for (int i = 0; i < FGI.m_functionFGS.Count; i++)
                if (FGI.m_functionGenerators[i] != null)
                    FGI.m_functionGenerators[i].ResetCGdata();

            // figure out all dependencies
            // Note that m_errors and m_missingDependencies of each function cgd are shared with main cgd, but a mutex is used to avoid racing
            {
                // serial:
                for (int i = 0; i < FGI.m_functionFGS.Count; i++)
                {
                    if (FGI.m_functionGenerators[i] != null)
                    {
                        FGI.m_functionGenerators[i].CheckTestingDepenciesEntryPoint();
                    }
                }/*
                // in parallel:
                Thread[] depFunctionThreads = new Thread[FGI.m_functionFGS.Count];
                for (int i = 0; i < FGI.m_functionFGS.Count; i++)
                {
                    if (FGI.m_functionGenerators[i] != null)
                    {
                        depFunctionThreads[i] = new Thread(FGI.m_functionGenerators[i].CheckTestingDepenciesEntryPoint);
                    }
                }
                G25.CG.Shared.Threads.StartThreadArray(depFunctionThreads);
                G25.CG.Shared.Threads.JoinThreadArray(depFunctionThreads);*/
            }

            // get random number generator FGS for each float type
            List<string> randomNumberGenerators = new List<string>();
            List<string> randomNumberTimeSeedFuncs = new List<string>();
            foreach (FloatType FT in S.m_floatTypes)
            {
                //bool returnTrueName = true;
                string funcName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "random_" + FT.type, new String[0], FT, null);
                randomNumberGenerators.Add(funcName);
                randomNumberTimeSeedFuncs.Add(funcName + "_timeSeed");
//.........这里部分代码省略.........
开发者ID:Sciumo,项目名称:gaigen,代码行数:101,代码来源:testsuite.cs


注:本文中的Specification.GetOutputPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。