本文整理汇总了C#中G25.GetMissingDependenciesList方法的典型用法代码示例。如果您正苦于以下问题:C# G25.GetMissingDependenciesList方法的具体用法?C# G25.GetMissingDependenciesList怎么用?C# G25.GetMissingDependenciesList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类G25
的用法示例。
在下文中一共展示了G25.GetMissingDependenciesList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 = 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();
// output license, copyright
G25.CG.Shared.Util.WriteCopyright(SB, S);
G25.CG.Shared.Util.WriteLicense(SB, S);
// using ...
//Util.WriteGenericUsing(SB, S);
G25.CG.Shared.Util.WriteOpenNamespace(SB, S);
G25.CG.Shared.Util.WriteOpenClass(SB, S, G25.CG.Shared.AccessModifier.AM_public, "TestSuite", new string[]{S.m_namespace}, null);
// 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); }
// 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 (todo: in parallel (is easy because they all have their own CGdata, just see in Functions.WriteFunctions() how it's done)
// NOTE THAT m_errors and m_missingDependencies of each function cgd are shared with main cgd!
for (int i = 0; i < FGI.m_functionFGS.Count; i++)
{
if (FGI.m_functionGenerators[i] != null)
{
FGI.m_functionGenerators[i].CheckTestingDepenciesEntryPoint();
}
}
// 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)
{
string funcName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "random_" + FT.type, new String[0], FT, null);
randomNumberGenerators.Add(funcName);
randomNumberTimeSeedFuncs.Add(funcName + "_timeSeed");
}
// for parsing test, subtract is required (first float type):
string subtractGmvFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "subtract", new String[] { S.m_GMV.Name, S.m_GMV.Name }, S.m_GMV.Name, S.m_floatTypes[0], null);
string randomVersorFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "random_versor", new String[0], S.m_GMV.Name, S.m_floatTypes[0], null);
Dictionary<String, String> gpGmvFuncName = new Dictionary<string, string>();
// geometric product of all metrics and float types:
{
foreach (FloatType FT in S.m_floatTypes)
foreach (Metric M in S.m_metric)
gpGmvFuncName[FT.type + "_" + M.m_name] = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "gp", new String[] { S.m_GMV.Name, S.m_GMV.Name }, S.m_GMV.Name, FT, M.m_name);
}
{ // iteratively get all dependencies and generate their code
int count = 0;
List<fgs> missingFunctions = null, alreadyGeneratedMissingFunctions = new List<fgs>();
do
{
count = cgd.m_missingDependencies.Count; // we loop until the number of dependencies doesn't grow anymore
missingFunctions = cgd.GetMissingDependenciesList(alreadyGeneratedMissingFunctions);
G25.CG.Shared.Functions.WriteFunctions(S, cgd, null, Functions.GetFunctionGeneratorPlugins(cgd), missingFunctions);
alreadyGeneratedMissingFunctions.AddRange(missingFunctions);
} while (count < cgd.m_missingDependencies.Count);
}
// write code for all dependencies to output
SB.AppendLine("// Missing dependencies definitions:");
SB.Append(cgd.m_defSB);
cgd.ResetSB();
//.........这里部分代码省略.........
示例2: GenerateCode
//.........这里部分代码省略.........
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");
}
// for parsing test, subtract is required (first float type):
string subtractGmvFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "subtract", new String[] { S.m_GMV.Name, S.m_GMV.Name }, S.m_GMV.Name, S.m_floatTypes[0], null);
string randomVersorFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "random_versor", new String[0], S.m_GMV.Name, S.m_floatTypes[0], null);
// for metric / getter setter:
Dictionary<string, string> randomVersorFuncNames = new Dictionary<string, string>();
Dictionary<string, string> gpGmvFuncName = new Dictionary<string, string>();
// geometric product of all metrics and float types:
{
foreach (FloatType FT in S.m_floatTypes)
{
randomVersorFuncNames[FT.type] = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "random_versor", new String[0], S.m_GMV.Name, FT, null);
foreach (Metric M in S.m_metric)
gpGmvFuncName[FT.type + "_" + M.m_name] = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "gp", new String[] { S.m_GMV.Name, S.m_GMV.Name }, S.m_GMV.Name, FT, M.m_name);
}
}
{ // iteratively get all dependencies and generate their code
int count = 0;
List<fgs> missingFunctions = null, alreadyGeneratedMissingFunctions = new List<fgs>();
do
{
count = cgd.m_missingDependencies.Count; // we loop until the number of dependencies doesn't grow anymore
missingFunctions = cgd.GetMissingDependenciesList(alreadyGeneratedMissingFunctions);
G25.CG.Shared.Functions.WriteFunctions(S, cgd, null, Functions.GetFunctionGeneratorPlugins(cgd), missingFunctions);
alreadyGeneratedMissingFunctions.AddRange(missingFunctions);
} while (count < cgd.m_missingDependencies.Count);
}
// write code for all dependencies to output
SB.AppendLine("// Missing dependencies declarations:");
SB.Append(cgd.m_declSB);
SB.AppendLine("// Missing dependencies inline definitions:");
SB.Append(cgd.m_inlineDefSB);
SB.AppendLine("// Missing dependencies definitions:");
SB.Append(cgd.m_defSB);
cgd.ResetSB();
List<string> testFunctionNames = new List<string>(); // list of names of bool functionName(void) goes here
{ // write all 'other' test code
// metric
testFunctionNames.AddRange(WriteMetricTests(S, cgd, gpGmvFuncName));
// converters
// todo . . .
// get / set coordinates
testFunctionNames.AddRange(WriteGetterSetterTests(S, cgd, randomNumberGenerators, randomVersorFuncNames));
// toString & parser (if available)
if (S.m_parserType != PARSER.NONE)
testFunctionNames.Add(WriteParserTest(S, cgd, randomNumberGenerators[0], randomVersorFuncName, subtractGmvFuncName));
}