예제 #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()
예제 #2
0
        /// <summary>
        /// Recurses through all instructions in 'I', searching for return instructions.
        ///
        /// Collects their types and float point types in 'returnTypes' and 'returnTypeFT'.
        /// </summary>
        /// <param name="L">Instructions to be searched for return types.</param>
        /// <param name="returnTypes">Used as output.</param>
        /// <param name="returnTypeFT">Used as output.</param>
        public static void GetReturnType(List <Instruction> L, List <G25.VariableType> returnTypes, List <G25.FloatType> returnTypeFT)
        {
            foreach (Instruction I in L)
            {
                if (I is ReturnInstruction)
                {
                    ReturnInstruction RI = I as ReturnInstruction;
                    returnTypes.Add(RI.m_type);
                    returnTypeFT.Add(RI.m_floatType);
                }

                if (I.m_childInstructions != null)
                {
                    foreach (List <Instruction> childL in I.m_childInstructions)
                    {
                        if (childL != null)
                        {
                            GetReturnType(childL, returnTypes, returnTypeFT);
                        }
                    }
                }
            }
        }
예제 #3
0
파일: functions.cs 프로젝트: Sciumo/gaigen
        /// <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("}");
        }