Exemple #1
0
        public static void Generate(string filename)
        {
            try
            {
                G25.Specification S = new G25.Specification(filename);

                // get the code generator and plugins ready
                CodeGeneratorLoader L = new CodeGeneratorLoader(S.GetOutputLanguageString());
                LoadDefaultCodeGenerators(L);
                // todo: load custom plugins (their location will be in the specification XML?)
                if (L.GetMainCodeGenerator() == null)
                    throw new G25.UserException("No code generator for language " + S.GetOutputLanguageString());

                // generate the code
                List<string> generatedFiles = L.GetMainCodeGenerator().GenerateCode(S, L.GetCodeGeneratorPlugins());

                // insert verbatim code:
                S.InsertVerbatimCode(generatedFiles);

                // write list of generated files
                if (OptionSaveFileListFile != null)
                    SaveGenerateFileList(OptionSaveFileListFile, generatedFiles);
            }
            catch (G25.UserException E)
            {
                System.Console.WriteLine("Error:");
                System.Console.Write(E.GetErrorReport());
            }
            catch (System.Exception E)
            {
                System.Console.WriteLine("Exception:");
                System.Console.WriteLine(E.ToString());
                System.Console.WriteLine(E.Message);
            }
        }
Exemple #2
0
        public static void Generate(string filename)
        {
            try
            {
                G25.Specification S = new G25.Specification(filename);

                // get the code generator and plugins ready
                CodeGeneratorLoader L = new CodeGeneratorLoader(S.GetOutputLanguageString());
                LoadDefaultCodeGenerators(L);
                // todo: load custom plugins (their location will be in the specification XML?)
                if (L.GetMainCodeGenerator() == null)
                {
                    throw new G25.UserException("No code generator for language " + S.GetOutputLanguageString());
                }

                // generate the code
                List <string> generatedFiles = L.GetMainCodeGenerator().GenerateCode(S, L.GetCodeGeneratorPlugins());

                // insert verbatim code:
                S.InsertVerbatimCode(generatedFiles);

                // write list of generated files
                if (OptionSaveFileListFile != null)
                {
                    SaveGenerateFileList(OptionSaveFileListFile, generatedFiles);
                }
            }
            catch (G25.UserException E)
            {
                System.Console.WriteLine("Error:");
                System.Console.Write(E.GetErrorReport());
            }
            catch (System.Exception E)
            {
                System.Console.WriteLine("Exception:");
                System.Console.WriteLine(E.ToString());
                System.Console.WriteLine(E.Message);
            }
        }
Exemple #3
0
        } // end of function BinaryScalarOpToLangString()

        public static string OpNameToLangString(G25.Specification S, G25.FloatType FT, string opName)
        {
            switch (S.m_outputLanguage)
            {
            case OUTPUT_LANGUAGE.C:
                if (FT.type == "float")
                {
                    return(m_floatOpsC[opName]);
                }
                else
                {
                    return(m_doubleOpsC[opName]);
                }

            case OUTPUT_LANGUAGE.CPP:
                if (FT.type == "float")
                {
                    return(m_floatOpsCpp[opName]);
                }
                else
                {
                    return(m_doubleOpsCpp[opName]);
                }

            case OUTPUT_LANGUAGE.CSHARP:
                if (FT.type == "float")
                {
                    return(m_floatOpsCSharp[opName]);
                }
                else
                {
                    return(m_doubleOpsCSharp[opName]);
                }

            case OUTPUT_LANGUAGE.JAVA:
                if (FT.type == "float")
                {
                    return(m_floatOpsJava[opName]);
                }
                else
                {
                    return(m_doubleOpsJava[opName]);
                }

            default:
                throw new Exception("G25.CG.Shared.BasisBlade.ScalarOpToLangString(): todo: language " + S.GetOutputLanguageString());
            }
        }