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


C# G25.IsBinary方法代码示例

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


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

示例1: GetComment

        private static string GetComment(Specification S, bool declOnly, G25.fgs FGS, G25.Operator op, G25.FloatType FT, bool assign)
        {
            StringBuilder SB = new StringBuilder();

            if ((S.OutputCpp()) && op.IsUnaryInPlace())
            {
                if (op.IsPrefix)
                {
                    SB.Append("returns (" + FGS.ArgumentVariableNames[0] + " = " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0] + "))");
                }
                else
                {
                    SB.Append("returns input value of " + FGS.ArgumentVariableNames[0] + ", but sets " + FGS.ArgumentVariableNames[0] + " to " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0] + ")");
                }
            }
            else if (assign)
            {
                SB.Append("returns (" + FGS.ArgumentVariableNames[0] + " = " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0]);
                SB.Append(", " + FGS.ArgumentVariableNames[1]);
                SB.Append("))");
            }
            else {
                SB.Append("returns " + FGS.OutputName + "(" + FGS.ArgumentVariableNames[0]);
                if (op.IsBinary())
                    SB.Append(", " + FGS.ArgumentVariableNames[1]);
                SB.Append(")");
            }

            return SB.ToString();
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:30,代码来源:operators.cs

示例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();
        }
开发者ID:Sciumo,项目名称:gaigen,代码行数:39,代码来源:operators.cs

示例3: WriteOperatorBody

 private static void WriteOperatorBody(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, G25.fgs FGS, G25.Operator op, string funcName)
 {
     bool returnTypeEqualsFirstArgument = FGS.ReturnTypeName == FGS.ArgumentTypeNames[0];
     if ((S.OutputCpp()) && op.IsUnaryInPlace() && returnTypeEqualsFirstArgument) // special unary case for C++
     {
         if (op.IsPrefix)
         {
             SB.AppendLine("\t" + FGS.ArgumentVariableNames[0] + " = " + funcName + "(" + FGS.ArgumentVariableNames[0] + ");");
             SB.AppendLine("\treturn " + FGS.ArgumentVariableNames[0] + ";");
         }
         else
         {
             SB.AppendLine("\t" + FGS.ReturnTypeName + " retVal(" + FGS.ArgumentVariableNames[0] + ");");
             SB.AppendLine("\t" + FGS.ArgumentVariableNames[0] + " = " + funcName + "(" + FGS.ArgumentVariableNames[0] + ");");
             SB.AppendLine("\treturn retVal;");
         }
     }
     else // regular operator function
     {
         SB.Append("\treturn " + funcName + "(" + FGS.ArgumentVariableNames[0]);
         if (op.IsBinary()) SB.Append(", " + FGS.ArgumentVariableNames[1]);
         SB.AppendLine(");");
     }
 }
开发者ID:Sciumo,项目名称:gaigen,代码行数:24,代码来源:operators.cs

示例4: 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


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