Esempio n. 1
0
        } // end of WriteAssignmentFunction()

        /// <summary>
        ///
        /// </summary>
        /// <param name="S">Used for all kinds of stuff.</param>
        /// <param name="cgd">Results go into cgd.m_defSB, and so on</param>
        /// <param name="inline">Should the function we inline?</param>
        /// <param name="staticFunc">Static function?</param>
        /// <param name="functionName">The name of the function which is to be generated.</param>
        /// <param name="arguments">Array of FuncArg which describes the arguments of the function.</param>
        /// <param name="returnFT">Floating point type of return variable.</param>
        /// <param name="mustCastDst">set to true if coordinates of 'value' must be cast to 'dstFT'.</param>
        /// <param name="returnType">The type to be returned.</param>
        /// <param name="value">Value to be written to the returned.</param>
        public static void WriteReturnFunction(
            Specification S, G25.CG.Shared.CGdata cgd,
            bool inline, bool staticFunc, string functionName,
            FuncArgInfo[] arguments,
            FloatType returnFT, bool mustCastDst, G25.VariableType returnType, RefGA.Multivector value)
        {
            string returnTypeName;
            bool   returnSMV = returnType is G25.SMV;

            if (returnSMV)
            {
                returnTypeName = returnFT.GetMangledName(S, (returnType as G25.SMV).Name);
            }
            else
            {
                returnTypeName = (returnType as G25.FloatType).type;
            }

            // where the definition goes:
            StringBuilder defSB = (inline) ? cgd.m_inlineDefSB : cgd.m_defSB;

            // declaration:
            if (S.OutputCppOrC())
            {
                WriteDeclaration(cgd.m_declSB, S, cgd, false, staticFunc, returnTypeName, functionName, null, arguments);
                cgd.m_declSB.AppendLine(";");
            }

            WriteDeclaration(defSB, S, cgd, inline, staticFunc, returnTypeName, functionName, null, arguments);


            defSB.AppendLine("");
            defSB.AppendLine("{");

            int nbTabs           = 1;
            ReturnInstruction RI = new ReturnInstruction(nbTabs, returnType, returnFT, mustCastDst, value);

            RI.Write(defSB, S, cgd);

            defSB.Append("\n");

            defSB.AppendLine("}");
        } // end of WriteReturnFunction()
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="S">Used for all kinds of stuff.</param>
        /// <param name="cgd">Results go into cgd.m_defSB, and so on</param>
        /// <param name="inline">Should the function we inline?</param>
        /// <param name="staticFunc">Static function?</param>
        /// <param name="functionName">The name of the function which is to be generated.</param>
        /// <param name="arguments">Array of FuncArg which describes the arguments of the function.</param>
        /// <param name="returnFT">Floating point type of return variable.</param>
        /// <param name="mustCastDst">set to true if coordinates of 'value' must be cast to 'dstFT'.</param>
        /// <param name="returnType">The type to be returned.</param>
        /// <param name="value">Value to be written to the returned.</param>
        public static void WriteReturnFunction(
            Specification S, G25.CG.Shared.CGdata cgd,
            bool inline, bool staticFunc, string functionName,
            FuncArgInfo[] arguments,
            FloatType returnFT, bool mustCastDst, G25.VariableType returnType, RefGA.Multivector value)
        {
            string returnTypeName;
            bool returnSMV = returnType is G25.SMV;

            if (returnSMV) returnTypeName = returnFT.GetMangledName(S, (returnType as G25.SMV).Name);
            else returnTypeName = (returnType as G25.FloatType).type;

            // where the definition goes:
            StringBuilder defSB = (inline) ? cgd.m_inlineDefSB : cgd.m_defSB;

            // declaration:
            if (S.OutputCppOrC())
            {
                WriteDeclaration(cgd.m_declSB, S, cgd, false, staticFunc, returnTypeName, functionName, null, arguments);
                cgd.m_declSB.AppendLine(";");
            }

            WriteDeclaration(defSB, S, cgd, inline, staticFunc, returnTypeName, functionName, null, arguments);

            defSB.AppendLine("");
            defSB.AppendLine("{");

            int nbTabs = 1;
            ReturnInstruction RI = new ReturnInstruction(nbTabs, returnType, returnFT, mustCastDst, value);
            RI.Write(defSB, S, cgd);

            defSB.Append("\n");

            defSB.AppendLine("}");
        }