本文整理汇总了C#中Specification.GetOutputFilename方法的典型用法代码示例。如果您正苦于以下问题:C# Specification.GetOutputFilename方法的具体用法?C# Specification.GetOutputFilename怎么用?C# Specification.GetOutputFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Specification
的用法示例。
在下文中一共展示了Specification.GetOutputFilename方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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 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;
}
示例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>();
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;
}
示例4: 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);
{ // #includes
SB.AppendLine("#include <stdio.h>");
SB.AppendLine("#include <utility> // for std::swap");
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.CPP.Header.GetRawHeaderFilename(S)) + "\"");
}
G25.CG.Shared.Util.WriteOpenNamespace(SB, S);
GenerateTables(S, cgd, SB);
// the list of names of smv types
G25.CG.CPP.SMV.WriteSMVtypenames(SB, S, cgd);
// write constant definitions
G25.CG.CPP.Constants.WriteDefinitions(SB, S, cgd);
// write report usage
cgd.m_cog.EmitTemplate(SB, (S.m_reportUsage) ? "ReportUsageSource" : "NoReportUsageSource");
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, "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);
G25.CG.Shared.Util.WriteCloseNamespace(SB, S, G25.CG.Shared.Main.RUNTIME_NAMESPACE);
}
{ // write toString
bool def = true;
G25.CG.CPP.ToString.WriteToString(SB, S, cgd, def);
}
// write operators
if (!S.m_inlineOperators)
Operators.WriteOperatorDefinitions(SB, S, cgd);
SB.AppendLine("// def SB:");
SB.Append(cgd.m_defSB);
// close namespace
G25.CG.Shared.Util.WriteCloseNamespace(SB, S);
// write all to file
G25.CG.Shared.Util.WriteFile(sourceFilename, SB.ToString());
return generatedFiles;
}
示例5: 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");
//.........这里部分代码省略.........