当前位置: 首页>>代码示例>>C#>>正文


C# Specification.GetFloatType方法代码示例

本文整理汇总了C#中Specification.GetFloatType方法的典型用法代码示例。如果您正苦于以下问题:C# Specification.GetFloatType方法的具体用法?C# Specification.GetFloatType怎么用?C# Specification.GetFloatType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Specification的用法示例。


在下文中一共展示了Specification.GetFloatType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteOperator

        private static void WriteOperator(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, bool declOnly, G25.fgs FGS, G25.Operator op)
        {
            bool comment = declOnly || S.m_inlineOperators;
            bool returnTypeEqualsFirstArgument = FGS.ReturnTypeName == FGS.ArgumentTypeNames[0];

            foreach (string floatName in FGS.FloatNames)
            {
                G25.FloatType FT = S.GetFloatType(floatName);

                string funcName = FGS.OutputName;

                { // regular operator
                    bool assign = false;
                    bool returnByReference = returnTypeEqualsFirstArgument && op.IsPrefixUnary() && op.IsUnaryInPlace(); // for unary prefix ++ and --, needs to return by reference (&)
                    bool constVal = !(op.IsUnaryInPlace() && returnTypeEqualsFirstArgument);
                    string funcDecl = GetFuncDecl(S, declOnly, FGS, op, FT, assign, constVal, returnByReference);

                    if (comment) // comment?
                        SB.AppendLine("/// " + GetComment(S, declOnly, FGS, op, FT, assign));
                    SB.Append(funcDecl);
                    if (declOnly) SB.AppendLine(";");
                    else
                    {
                        SB.AppendLine(" {");
                        WriteOperatorBody(SB, S, cgd, FGS, op, funcName);
                        SB.AppendLine("}");
                    }
                }

                // add an extra operator with assignment (like +=) ?
                if (op.IsBinary() && returnTypeEqualsFirstArgument)
                {
                    bool assign = true;
                    bool constVal = false;
                    bool returnByReference = true; // todo: for unary prefix ++ needs to return by reference (&)
                    string funcDecl = GetFuncDecl(S, declOnly, FGS, op, FT, assign, constVal, returnByReference);

                    if (comment) // comment?
                        SB.AppendLine("/// " + GetComment(S, declOnly, FGS, op, FT, assign));
                    SB.Append(funcDecl);
                    if (declOnly) SB.AppendLine(";");
                    else
                    {
                        SB.AppendLine(" {");
                        SB.Append("\treturn (" + FGS.ArgumentVariableNames[0] + " = " + funcName + "(" + FGS.ArgumentVariableNames[0]);
                        SB.AppendLine(", " + FGS.ArgumentVariableNames[1] + "));");
                        SB.AppendLine("}");
                    }
                }

            }
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:52,代码来源:operators.cs

示例2: GetReturnType

        /// <summary>
        /// The user may have requested a return type (F.ReturnTypeName). 
        /// In that case, the type with the same name is found, or an exception 
        /// is thrown if it does not exists.
        /// 
        /// Otherwise, finds the (tightest, best) return type for a function 'F' which 
        /// returning the (symbolic) value 'value'. 
        /// This  may or may not result in an SMV being found. If no 
        /// type is found and the return type is a scalar, then a floating
        /// point type may be returned.
        /// 
        /// If no SMV type is found, then a new type is created, and an exception
        /// is thrown which described the missing type.
        /// </summary>
        /// <param name="S">The specification (used to find SMVs)</param>
        /// <param name="cgd">Not used currently.</param>
        /// <param name="F">Function description (used for user-specified return type).</param>
        /// <param name="FT">Floating point type used in function.</param>
        /// <param name="value">The symbolic return value.</param>
        /// <returns>The SMV, FloatType or null if none found.</returns>
        public static G25.VariableType GetReturnType(Specification S, CGdata cgd, G25.fgs F, FloatType FT, RefGA.Multivector value)
        {
            if ((F.ReturnTypeName != null) && (F.ReturnTypeName.Length > 0))
            {
                // The user specified a return type
                G25.SMV returnSmv = S.GetSMV(F.ReturnTypeName); // is it a SMV?
                if (returnSmv != null) return returnSmv;
                G25.FloatType returnFT = S.GetFloatType(F.ReturnTypeName); // is it a specific float?
                if (returnFT != null) return FT; //returnFT;
                else if (F.ReturnTypeName == G25.XML.XML_SCALAR) // is it a unspecified float?
                    return FT;

                // type does not exist: abort (TODO: error message)
                else throw new G25.UserException("Non-existant user-specified return type: " + F.ReturnTypeName,
                    XML.FunctionToXmlString(S, F)); // non-existant return type
            }
            else
            {
                G25.VariableType RT = FindTightestMatch(S, value, FT);
                if (RT != null) return RT;
                else return CreateSyntheticSMVtype(S, cgd, FT, value);
            }
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:43,代码来源:specializedreturntype.cs


注:本文中的Specification.GetFloatType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。