Beispiel #1
0
        public override void OutputPre(OutputStream os, OutputFlags flags)
        {
            if (Pointee.Kind == NodeKind.FunctionSignature)
            {
                FunctionSignatureNode sig = (FunctionSignatureNode)Pointee;
                sig.OutputPre(os, OutputFlags.NoCallingConvention);
            }
            else
            {
                Pointee.OutputPre(os, flags);
            }

            OutputSpaceIfNecessary(os);

            if (Quals.HasFlag(Qualifiers.Unaligned))
            {
                os.Append("__unaligned ");
            }

            if (Pointee.Kind == NodeKind.ArrayType)
            {
                os.Append('(');
            }
            else if (Pointee.Kind == NodeKind.FunctionSignature)
            {
                os.Append('(');
                FunctionSignatureNode sig = (FunctionSignatureNode)Pointee;
                OutputCallingConvention(os, sig.CallConvention);
                os.Append(' ');
            }

            if (ClassParent != null)
            {
                ClassParent.Output(os, flags);
                os.Append("::");
            }

            switch (Affinity)
            {
            case PointerAffinity.Pointer:
                os.Append('*');
                break;

            case PointerAffinity.Reference:
                os.Append('&');
                break;

            case PointerAffinity.RValueReference:
                os.Append("&&");
                break;

            default:
                Assert.True(false);
                break;
            }

            OutputQualifiers(os, Quals, false, false);
        }
        public override void OutputPost(OutputStream os, OutputFlags flags)
        {
            if (!FunctionClass.HasFlag(FuncClass.NoParameterList))
            {
                os.Append('(');
                if (Params != null)
                {
                    Params.Output(os, flags);
                }
                else
                {
                    os.Append("void");
                }
                os.Append(')');
            }

            if (Quals.HasFlag(Qualifiers.Const))
            {
                os.Append(" const");
            }
            if (Quals.HasFlag(Qualifiers.Volatile))
            {
                os.Append(" volatile");
            }
            if (Quals.HasFlag(Qualifiers.Restrict))
            {
                os.Append(" __restrict");
            }
            if (Quals.HasFlag(Qualifiers.Unaligned))
            {
                os.Append(" __unaligned");
            }

            if (RefQualifier == FunctionRefQualifier.Reference)
            {
                os.Append(" &");
            }
            else if (RefQualifier == FunctionRefQualifier.RValueReference)
            {
                os.Append(" &&");
            }

            if (ReturnType != null)
            {
                ReturnType.OutputPost(os, flags);
            }
        }