Пример #1
0
        private static void WriteOperatorShortcut(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT, G25.VariableType type,
            G25.fgs fgs, FuncArgInfo[] FAI, G25.Operator op)
        {
            // C# does not allow return type of ++ or -- to be different from input type
            if (S.OutputCSharp() &&
                (op.IsIncrement() || op.IsDecrement()) &&
                (fgs.ReturnTypeName != type.GetName()))
                return;

            string operatorCall = getOperatorCall(S, fgs, FAI);

            SB.AppendLine("");

            int nbTabs = 1;
            // output comment
            new Comment("operator for " + operatorCall).Write(SB, S, nbTabs);

            bool inline = false;
            bool staticFunc = true;
            string returnType = FT.GetMangledName(S, fgs.ReturnTypeName);
            FuncArgInfo returnArgument = null;

            SB.Append('\t', nbTabs);
            Functions.WriteDeclaration(SB, S, cgd,
                inline, staticFunc, returnType, "operator " + op.Symbol,
                returnArgument, FAI);
            SB.AppendLine(" {");

            SB.Append('\t', nbTabs+1);
            SB.Append("return ");
            SB.Append(operatorCall);
            SB.AppendLine(";");

            SB.Append('\t', nbTabs);
            SB.AppendLine("}");
        }