本文整理汇总了C#中G25.GetMangledName方法的典型用法代码示例。如果您正苦于以下问题:C# G25.GetMangledName方法的具体用法?C# G25.GetMangledName怎么用?C# G25.GetMangledName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类G25
的用法示例。
在下文中一共展示了G25.GetMangledName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetConverterDependency
/// <summary>
/// Resolves a converter (underscore constructor) dependency.
/// Searches for a converter from 'fromType' to 'toType'.
///
/// If the function is not found, this is also enlisted in cgd.m_missingDependencies.
/// Call cgd.PrintMissingDependencies() should be called to report the missing dependencies
/// to the end-user.
/// </summary>
/// <param name="S">The spec.</param>
/// <param name="cgd">Missing dependencies go into cgd.m_missingDependencies.</param>
/// <param name="fromType"></param>
/// <param name="toType"></param>
/// <param name="FT"></param>
/// <returns></returns>
public static string GetConverterDependency(Specification S, CGdata cgd, string fromType, string toType, G25.FloatType FT)
{
// look for 'funcName' in all G25.fgs in the spec
// string funcName = "_" + FT.GetMangledName(S, toType);
string funcName = "_" + toType;
foreach (G25.fgs F in S.m_functions)
{
if (F.IsConverter(S)) // is 'F' a converter (underscore constructor)?
{
if ((F.Name == funcName) &&
(F.ArgumentTypeNames[0] == fromType))
{
return G25.CG.Shared.Converter.GetConverterName(S, F, FT.GetMangledName(S, fromType), FT.GetMangledName(S, toType));
}
}
}
// converter not found: add it to missing deps:
{
// add dependency to list of missing deps:
string outputName = null;
string[] argumentTypes = new string[] { fromType };
string[] argVarNames = null;
string returnTypeName = null;
string metricName = null;
string comment = null;
Dictionary<string, string> options = null;
G25.fgs F = new G25.fgs(funcName, outputName, returnTypeName, argumentTypes, argVarNames, new string[] { FT.type }, metricName, comment, options);
cgd.AddMissingDependency(S, F);
}
// return fictional name:
G25.fgs tmpF = null;
return "missingFunction_" + G25.CG.Shared.Converter.GetConverterName(S, tmpF, FT.GetMangledName(S, fromType), FT.GetMangledName(S, toType));
}
示例2: GetFuncDecl
private static string GetFuncDecl(Specification S, bool declOnly, G25.fgs FGS, G25.Operator op, G25.FloatType FT, bool assign, bool constVal, bool returnByReference)
{
StringBuilder SB = new StringBuilder();
string inlineStr = G25.CG.Shared.Util.GetInlineString(S, (!declOnly) && S.m_inlineOperators, " ");
string returnTypeName = (FGS.m_returnTypeName.Length > 0) ? FGS.m_returnTypeName : FT.type;
if (!S.IsFloatType(returnTypeName)) returnTypeName = FT.GetMangledName(S, returnTypeName);
string arg1typeName = FT.GetMangledName(S, FGS.ArgumentTypeNames[0]);
string arg2typeName = (FGS.NbArguments > 1) ? FT.GetMangledName(S, FGS.ArgumentTypeNames[1]) : "";
SB.Append(inlineStr);
SB.Append(returnTypeName);
SB.Append(" ");
if (returnByReference) SB.Append("&");
SB.Append("operator");
SB.Append(op.Symbol);
if (assign) SB.Append("=");
SB.Append("(");
if (constVal) SB.Append("const ");
SB.Append(arg1typeName);
SB.Append(" &");
SB.Append(FGS.ArgumentVariableNames[0]);
if (op.IsBinary())
{
SB.Append(", const ");
SB.Append(arg2typeName);
SB.Append(" &");
SB.Append(FGS.ArgumentVariableNames[1]);
}
else if ((S.OutputCpp()) && op.IsPostfixUnary())
{ // add a dummy int argument so C++ knows this is a unary postfix op
SB.Append(", int");
}
SB.Append(")");
return SB.ToString();
}
示例3: WriteLargestCoordinates
/// <summary>
/// Writes function for obtaining the largest coordinate of a multivector.
/// </summary>
/// <param name="SB"></param>
/// <param name="S"></param>
/// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param>
/// <param name="FT"></param>
public static void WriteLargestCoordinates(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT)
{
string fabsFuncName = G25.CG.Shared.CodeUtil.OpNameToLangString(S, FT, RefGA.Symbolic.UnaryScalarOp.ABS);
cgd.m_cog.EmitTemplate(SB, "GMVlargestCoordinate", "S=", S, "FT=", FT, "gmvName=", FT.GetMangledName(S, S.m_GMV.Name), "fabsFunc=", fabsFuncName);
}
示例4: GetGradeCodeCppOrC
private static string GetGradeCodeCppOrC(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT,
int gradeIdx,
G25.CG.Shared.FuncArgInfo[] FAI, string resultName, string groupBitmapName)
{
G25.GMV gmv = S.m_GMV;
if (gradeIdx >= 0)
{ // if a specific grade is requested, convert it into a group bitmap, and call the grade(A, groupBitmap) function
// get name of grade function
//bool returnTrueName = false;
string gradeFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, EXTRACT_GRADE, new string[] { gmv.Name, G25.GroupBitmapType.GROUP_BITMAP }, FT, null);
// turn grade into group
int groupBitmap = gmv.GradeToGroupBitmap(gradeIdx);
if (S.OutputC())
{
return gradeFuncName + "(" + resultName + ", " + FAI[0].Name + ", " + groupBitmap + ");";
}
else
{
return "return " + gradeFuncName + "(" + FAI[0].Name + ", " + groupBitmap + ");";
}
}
else
{
StringBuilder SB = new StringBuilder();
// get indices into coordinates for input and output
SB.AppendLine("int aidx = 0, cidx = 0;");
string agu = (S.OutputC()) ? FAI[0].Name + "->gu" : FAI[0].Name + ".gu()";
string ac = (S.OutputC()) ? FAI[0].Name + "->c" : FAI[0].Name + ".getC()";
if (S.OutputC())
{
SB.AppendLine(resultName + "->gu = " + agu +" & " + groupBitmapName + ";");
}
else
{
SB.AppendLine("int gu = " + agu + " & " + groupBitmapName + ";");
SB.AppendLine(FT.type + " c[" + (1 << S.m_dimension) + "];");
}
string resultCoordPtr = (S.OutputC()) ? resultName + "->c" : "c";
// for each group, test if present
int nbGroups = gmv.NbGroups;
for (int g = 0; g < nbGroups; g++)
{
SB.AppendLine("");
string funcName = GetCopyPartFunctionName(S, FT, g);
SB.AppendLine("if (" + agu + " & " + (1 << g) + ") {");
SB.AppendLine("\tif (" + groupBitmapName + " & " + (1 << g) + ") {");
SB.AppendLine("\t\t" + funcName + "(" + ac + " + aidx, " + resultCoordPtr + " + cidx);");
if (g < (nbGroups - 1)) SB.AppendLine("\t\tcidx += " + gmv.Group(g).Length + ";");
SB.AppendLine("\t}");
if (g < (nbGroups - 1)) SB.AppendLine("\taidx += " + gmv.Group(g).Length + ";");
SB.AppendLine("}");
}
// return result
if (S.m_outputLanguage != OUTPUT_LANGUAGE.C)
{
SB.AppendLine("return " + FT.GetMangledName(S, gmv.Name) + "(gu, c);");
}
return SB.ToString();
}
}
示例5: WriteGetCoord
/// <summary>
/// Writes functions to extract coordinates from the GMV
/// </summary>
/// <param name="S"></param>
/// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param>
/// <param name="FT"></param>
/// <param name="SB"></param>
public static void WriteGetCoord(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT, StringBuilder SB)
{
G25.GMV gmv = S.m_GMV;
string typeName = FT.GetMangledName(S, gmv.Name);
for (int groupIdx = 0; groupIdx < gmv.NbGroups; groupIdx++)
{
for (int elementIdx = 0; elementIdx < gmv.Group(groupIdx).Length; elementIdx++)
{
WriteGetCoordFunction(S, cgd, FT, SB, typeName, groupIdx, elementIdx, gmv.Group(groupIdx)[elementIdx]);
}
}
SB.AppendLine("\t/// Returns array of compressed coordinates.");
SB.AppendLine("\tinline const " + FT.type + " *getC() const { return m_c;}");
}
示例6: GetIGPcode
/// <summary>
/// Returns the code for a inverse geometric product.
///
/// The returned code is only the body. The function declaration is not included.
/// </summary>
/// <param name="S">Specification of algebra (used for output language and to obtain general multivector type).</param>
/// <param name="cgd">Used for <c>m_gmvGPpartFuncNames</c>.</param>
/// <param name="FT">Floating point type.</param>
/// <param name="M">Metric type.</param>
/// <param name="T">The product (e.g., geometric, outer, etc)</param>
/// <param name="FAI">Info about function arguments. Used to know whether arguments are general multivectors or scalars.</param>
/// <param name="resultName">Name of variable where the result goes (in the generated code).</param>
/// <returns>code for the requested product type.</returns>
public static string GetIGPcode(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT, G25.Metric M,
G25.CG.Shared.FuncArgInfo[] FAI, string resultName)
{
G25.GMV gmv = S.m_GMV;
StringBuilder SB = new StringBuilder();
string divFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "div", new String[] { gmv.Name, FT.type }, FT, null);
System.Collections.Hashtable argTable = new System.Collections.Hashtable();
argTable["S"] = S;
argTable["gmvName"] = FT.GetMangledName(S, gmv.Name);
argTable["FT"] = FT;
argTable["arg1name"] = FAI[0].Name;
argTable["arg2name"] = FAI[1].Name;
argTable["divFuncName"] = divFuncName;
if (S.OutputC())
argTable["dstName"] = resultName;
bool arg1isGmv = FAI[0].Type is G25.GMV;
bool arg2isGmv = FAI[1].Type is G25.GMV;
if (arg2isGmv)
{
string norm2FuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "norm2", new String[] { gmv.Name }, FT, M.m_name) + CANSparts.RETURNS_SCALAR;
string reverseFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "reverse", new String[] { gmv.Name }, FT, null);
argTable["reverseFuncName"] = reverseFuncName;
argTable["norm2FuncName"] = norm2FuncName;
if (arg1isGmv)
{
string gpFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "gp", new String[] { gmv.Name, gmv.Name }, FT, M.m_name);
argTable["gpFuncName"] = gpFuncName;
cgd.m_cog.EmitTemplate(SB, "igp_GMV_GMV_body", argTable);
}
else
{
string gpFuncName = G25.CG.Shared.Dependencies.GetDependency(S, cgd, "gp", new String[] { gmv.Name, FT.type }, FT, M.m_name);
argTable["mulFuncName"] = gpFuncName;
cgd.m_cog.EmitTemplate(SB, "igp_float_GMV_body", argTable);
}
}
else if (arg1isGmv)
{
cgd.m_cog.EmitTemplate(SB, "igp_GMV_float_body", argTable);
}
return SB.ToString();
}
示例7: GetExpandCodeCppOrC
private static string GetExpandCodeCppOrC(Specification S, G25.CG.Shared.CGdata cgd,
G25.FloatType FT, G25.CG.Shared.FuncArgInfo[] FAI, bool resultIsScalar, bool initResultToZero)
{
StringBuilder SB = new StringBuilder();
// result coordinates code:
int nbCoords = (resultIsScalar) ? 1 : (1 << S.m_dimension);
SB.AppendLine(FT.type + " c[" + nbCoords + "];");
// expand code
if (FAI != null)
{
for (int i = 0; i < FAI.Length; i++)
{
if (FAI[i].IsScalar())
{
// 'expand' scalar
SB.AppendLine("const " + FAI[i].FloatType.type + "* _" + FAI[i].Name + "[1] = {&" + FAI[i].Name + "};");
}
else
{
// expand general multivector
// SB.AppendLine("const " + FAI[i].FloatType.type + "* _" + FAI[i].Name + "[" + (S.m_dimension + 1) + "];");
SB.AppendLine("const " + FAI[i].FloatType.type + "* _" + FAI[i].Name + "[" + (S.m_GMV.NbGroups) + "];");
}
}
for (int i = 0; i < FAI.Length; i++)
{
if (!FAI[i].IsScalar())
{
if (S.OutputC())
SB.AppendLine(FT.GetMangledName(S, "expand") + "(_" + FAI[i].Name + ", " + FAI[i].Name + ");");
else SB.AppendLine(FAI[i].Name + ".expand(_" + FAI[i].Name + ");");
}
}
}
// set coordinates of 'c' to zero
if (initResultToZero)
{
SB.Append(Util.GetSetToZeroCode(S, FT, "c", nbCoords));
}
return SB.ToString();
}
示例8: WriteSetGroupUsage
/// <summary>
/// Writes function for setting grade/group usage, reallocting memory
/// </summary>
/// <param name="SB"></param>
/// <param name="S"></param>
/// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param>
/// <param name="FT"></param>
public static void WriteSetGroupUsage(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT)
{
string className = FT.GetMangledName(S, S.m_GMV.Name);
cgd.m_cog.EmitTemplate(SB, "GMVsetGroupUsage", "S=", S, "FT=", FT, "className=", className, "gmv=", S.m_GMV);
}
示例9: GetSAScodeCppOrC
private static string GetSAScodeCppOrC(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT,
G25.CG.Shared.FuncArgInfo[] FAI, string resultName)
{
G25.GMV gmv = S.m_GMV;
StringBuilder SB = new StringBuilder();
SB.AppendLine("int idxa = 0, idxc = 0;");
string agu = (S.OutputC()) ? FAI[0].Name + "->gu" : FAI[0].Name + ".gu()";
string ac = (S.OutputC()) ? FAI[0].Name + "->c" : FAI[0].Name + ".getC()";
string resultCoordPtr = (S.OutputC()) ? resultName + "->c" : "C";
// copy group usage / allocate memory for result
if (S.OutputC())
{
SB.AppendLine(resultName + "->gu = " + agu + " | ((" + FAI[2].Name + " != 0.0) ? GRADE_0 : 0); /* '| GRADE_0' to make sure the scalar part is included */");
}
else
{
SB.AppendLine("int gu = " + agu + " | ((" + FAI[2].Name + " != 0.0) ? GRADE_0 : 0); // '| GRADE_0' to make sure the scalar part is included");
SB.AppendLine(FT.type + " C[" + (1 << S.m_dimension) + "];");
}
int nbGroups = gmv.NbGroups;
for (int g = 0; g < nbGroups; g++)
{
SB.AppendLine("");
// get func name
string funcName = GetCopyMulPartFunctionName(S, FT, g);
SB.AppendLine("if (" + agu + " & " + (1 << g) + ") {");
SB.AppendLine("\t" + funcName + "(" + ac + " + idxa, " + resultCoordPtr + " + idxc, " + FAI[1].Name + ");");
if (g == 0)
{ // also add scalar
SB.AppendLine("\tif (" + FAI[2].Name + " != 0.0) " + resultCoordPtr + "[idxc] += " + FAI[2].Name + ";");
}
if (g < (nbGroups - 1))
{
SB.AppendLine("\tidxa += " + gmv.Group(g).Length + ";");
SB.AppendLine("\tidxc += " + gmv.Group(g).Length + ";");
}
SB.AppendLine("}");
if (g == 0)
{ // always add the scalar:
SB.AppendLine("else if (" + FAI[2].Name + " != 0.0) {");
SB.AppendLine("\t" + resultCoordPtr + "[idxc] = " + FAI[2].Name + ";");
SB.AppendLine("\tidxc += " + gmv.Group(g).Length + ";");
SB.AppendLine("}");
}
}
// return result
if (S.m_outputLanguage != OUTPUT_LANGUAGE.C)
{
SB.AppendLine("return " + FT.GetMangledName(S, gmv.Name) + "(gu, C);");
}
return SB.ToString();
}
示例10: GetSubPartFunctionName
/// <summary>
/// Returns the name of a partial subtraction function.
/// </summary>
/// <param name="FT">Float type (used for mangled name).</param>
/// <param name="g">Grade/group of arguments.</param>
/// <returns>name of a partial subtraction function.</returns>
public static string GetSubPartFunctionName(Specification S, G25.FloatType FT, int g)
{
return FT.GetMangledName(S, "sub") + "_" + g;
}
示例11: GetZeroPartFunctionName
/// <summary>
/// Returns the name of a partial is-zero function
/// </summary>
/// <param name="FT">Float type (used for mangled name).</param>
/// <param name="g">Grade/group of arguments.</param>
/// <returns>name of a partial Hadamard product function.</returns>
public static string GetZeroPartFunctionName(Specification S, G25.FloatType FT, int g)
{
return FT.GetMangledName(S, "zeroGroup") + "_" + g;
}
示例12: GetEqualsPartFunctionName
/// <summary>
/// Returns the name of a partial equality function
/// </summary>
/// <param name="FT">Float type (used for mangled name).</param>
/// <param name="g">Grade/group of arguments.</param>
/// <returns>name of a partial Hadamard product function.</returns>
public static string GetEqualsPartFunctionName(Specification S, G25.FloatType FT, int g)
{
return FT.GetMangledName(S, "equals") + "_" + g + "_" + g;
}
示例13: GetInverseHadamardProductPartFunctionName
/// <summary>
/// Returns the name of a partial Hadamard product function
/// </summary>
/// <param name="FT">Float type (used for mangled name).</param>
/// <param name="g">Grade/group of arguments.</param>
/// <returns>name of a partial Hadamard product function.</returns>
public static string GetInverseHadamardProductPartFunctionName(Specification S, G25.FloatType FT, int g)
{
return FT.GetMangledName(S, "ihp") + "_" + g + "_" + g;
}
示例14: GetUnaryToggleSignCodeCSharpOrJava
private static string GetUnaryToggleSignCodeCSharpOrJava(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT,
UnaryToggleSignType T,
G25.CG.Shared.FuncArgInfo[] FAI, string resultName)
{
G25.GMV gmv = S.m_GMV;
StringBuilder SB = new StringBuilder();
// get number of groups:
int nbGroups = gmv.NbGroups;
bool resultIsScalar = false , initResultToZero = false;
SB.Append(GPparts.GetExpandCode(S, cgd, FT, FAI, resultIsScalar, initResultToZero));
// for each group
// test if present, then code / negate, etc
for (int g = 0; g < nbGroups; g++)
{
SB.AppendLine("");
// do we need to negate this group?
bool neg = NeedToNegate(gmv, g, T);
string funcName = (neg) ? GetNegPartFunctionName(S, FT, g) : GetCopyPartFunctionName(S, FT, g);
SB.AppendLine("if (ac[" + g + "] != null) {");
SB.AppendLine("\tcc[" + g + "] = new " + FT.type + "[" + gmv.Group(g).Length + "];");
SB.AppendLine("\t" + funcName + "(ac[" + g + "], cc[" + g + "]);");
SB.AppendLine("}");
}
SB.AppendLine("return new " + FT.GetMangledName(S, gmv.Name) + "(cc);");
return SB.ToString();
}
示例15: GetUnaryToggleSignCodeCppOrC
private static string GetUnaryToggleSignCodeCppOrC(Specification S, G25.CG.Shared.CGdata cgd, G25.FloatType FT,
UnaryToggleSignType T,
G25.CG.Shared.FuncArgInfo[] FAI, string resultName)
{
G25.GMV gmv = S.m_GMV;
StringBuilder SB= new StringBuilder();
string agu = (S.OutputC()) ? FAI[0].Name + "->gu" : FAI[0].Name + ".gu()";
string ac = (S.OutputC()) ? FAI[0].Name + "->c" : FAI[0].Name + ".getC()";
string resultCoordPtr = (S.OutputC()) ? resultName + "->c" : "c";
SB.AppendLine("int idx = 0;");
if (S.OutputC())
{
SB.AppendLine(resultName + "->gu = " + agu + ";");
}
else
{
SB.AppendLine("int gu = " + agu + ";");
SB.AppendLine(FT.type + " c[" + (1 << S.m_dimension) + "];");
}
// get number of groups:
int nbGroups = gmv.NbGroups;
// for each group
// test if present, then code / negate, etc
for (int g = 0; g < nbGroups; g++)
{
SB.AppendLine("");
// do we need to negate this group?
bool neg = NeedToNegate(gmv, g, T);
string funcName = (neg) ? GetNegPartFunctionName(S, FT, g) : GetCopyPartFunctionName(S, FT, g);
SB.AppendLine("if (" + agu + " & " + (1 << g) + ") {");
SB.AppendLine("\t" + funcName + "(" + ac + " + idx, " + resultCoordPtr + " + idx);");
if (g < (nbGroups - 1)) SB.AppendLine("\tidx += " + gmv.Group(g).Length + ";");
SB.AppendLine("}");
}
// return result
if (S.m_outputLanguage != OUTPUT_LANGUAGE.C)
{
SB.AppendLine("return " + FT.GetMangledName(S, gmv.Name) + "(gu, c);");
}
return SB.ToString();
}