Exemplo n.º 1
0
        /// <summary>
        /// Returns the name of a generated function (for example <c>gp_mv_mv</c>).
        /// The function is found by looking through all G25.FGS in the Specification.
        ///
        /// If the function is not found, a fictional name is returned, i.e. "missingFunction_" + functionName.
        /// This name will then show up in the generated code, which will not compile as a result.
        ///
        /// 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="functionName">Basic name of the function to be found.</param>
        /// <param name="argumentTypes">Names of the arguments types (not mangled).</param>
        /// <param name="returnTypeName">Name of the return type (can be null or "" for default return type).</param>
        /// <param name="FT">Floating point type.</param>
        /// <param name="metricName">(optional, can be null for don't care)</param>
        /// <returns>The mangled name of the function.</returns>
        public static string GetDependency(Specification S, CGdata cgd, string functionName,
                                           string[] argumentTypes, string returnTypeName, G25.FloatType FT, string metricName)
        {
            // bool returnTrueName = dependent on cgd.mode
            try
            {
                return(GetFunctionName(S, functionName, argumentTypes, returnTypeName, FT, metricName));
            }
            catch (DependencyException)
            { // function not found, return a fictional name, and remember dependency
                G25.fgs F = null;
                {
                    // get name of dep, and make sure it does not get mangled
                    string outputName = functionName + cgd.GetDontMangleUniqueId();
                    if (returnTypeName != null)
                    {
                        outputName = outputName + "_returns_" + returnTypeName;
                    }

                    // add dependency to list of missing deps:
                    string[] argVarNames = null;
                    Dictionary <String, String> options = null;
                    string  comment = null;
                    G25.fgs tmpF    = new G25.fgs(functionName, outputName, returnTypeName, argumentTypes, argVarNames, new String[] { FT.type }, metricName, comment, options);

                    F = cgd.AddMissingDependency(S, tmpF);
                }

                return(cgd.m_dependencyPrefix + F.OutputName);
            }
        } // end of GetDependency()
Exemplo n.º 2
0
 /// <returns>A unique name for the testing function of 'funcName'.</returns>
 public static string GetTestingFunctionName(Specification S, CGdata cgd, string funcName)
 {
     if (S.OutputC())
     {
         return("test_" + funcName);
     }
     else
     {
         return("test_" + funcName + cgd.GetDontMangleUniqueId());
     }
 }
Exemplo n.º 3
0
 /// <returns>A unique name for the testing function of 'funcName'.</returns>
 public static string GetTestingFunctionName(Specification S, CGdata cgd, string funcName)
 {
     if (S.OutputC())
         return "test_" + funcName;
     else return "test_" + funcName + cgd.GetDontMangleUniqueId();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the name of a generated function (for example <c>gp_mv_mv</c>).
        /// The function is found by looking through all G25.FGS in the Specification.
        /// 
        /// If the function is not found, a fictional name is returned, i.e. "missingFunction_" + functionName.
        /// This name will then show up in the generated code, which will not compile as a result.
        /// 
        /// 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="functionName">Basic name of the function to be found.</param>
        /// <param name="argumentTypes">Names of the arguments types (not mangled).</param>
        /// <param name="returnTypeName">Name of the return type (can be null or "" for default return type).</param>
        /// <param name="FT">Floating point type.</param>
        /// <param name="metricName">(optional, can be null for don't care)</param>
        /// <returns>The mangled name of the function.</returns>
        public static string GetDependency(Specification S, CGdata cgd, string functionName, 
            string[] argumentTypes, string returnTypeName, G25.FloatType FT, string metricName)
        {
            // bool returnTrueName = dependent on cgd.mode
            try
            {
                return GetFunctionName(S, functionName, argumentTypes, returnTypeName, FT, metricName);
            }
            catch (DependencyException)
            { // function not found, return a fictional name, and remember dependency
                G25.fgs F = null;
                {
                    // get name of dep, and make sure it does not get mangled
                    string outputName = functionName + cgd.GetDontMangleUniqueId();
                    if (returnTypeName != null) outputName = outputName + "_returns_" + returnTypeName;

                    // add dependency to list of missing deps:
                    string[] argVarNames = null;
                    Dictionary<String, String> options = null;
                    string comment = null;
                    G25.fgs tmpF = new G25.fgs(functionName, outputName, returnTypeName, argumentTypes, argVarNames, new String[] { FT.type }, metricName, comment, options);

                    F = cgd.AddMissingDependency(S, tmpF);
                }

                return cgd.m_dependencyPrefix + F.OutputName;
            }
        }