示例#1
0
        internal override void WriteTo(CCodeWriterBase c)
        {
            var arrayTypeSymbol     = (ArrayTypeSymbol)Type;
            var arrayInitialization = this.InitializerOpt as ArrayInitialization;

            var initItems = IterateInitializers(arrayInitialization).ToList();

            c.WriteCArrayTemplate(arrayTypeSymbol, false);
            c.TextSpan("::__new_array");
            var arrayInit = arrayInitialization != null && initItems.Count > 0;

            if (arrayInit)
            {
                c.TextSpan("_init");
            }

            if (Cs2CGenerator.DebugOutput)
            {
                c.TextSpan("_debug");
            }

            c.TextSpan("(");

            var any = false;

            if (Cs2CGenerator.DebugOutput)
            {
                c.TextSpan("__FILE__, __LINE__, ");
            }

            if (!arrayInit || arrayTypeSymbol.Rank > 1)
            {
                if (arrayTypeSymbol.Rank > 1)
                {
                    c.TextSpan("{");
                }

                foreach (var bound in this.bounds.Reverse())
                {
                    if (any)
                    {
                        c.TextSpan(",");
                        c.WhiteSpace();
                    }

                    var isStaticWrapperCall = bound.IsStaticOrSupportedVolatileWrapperCall();
                    if (isStaticWrapperCall)
                    {
                        c.TextSpan("(int32_t)(");
                    }

                    bound.WriteTo(c);
                    if (isStaticWrapperCall)
                    {
                        c.TextSpan(")");
                    }

                    any = true;
                }

                if (arrayTypeSymbol.Rank > 1)
                {
                    c.TextSpan("}");
                }
            }

            if (this.InitializerOpt != null)
            {
                foreach (var bound in initItems)
                {
                    if (any)
                    {
                        c.TextSpan(",");
                        c.WhiteSpace();
                    }

                    c.WriteWrappedExpressionIfNeeded(bound);
                    any = true;
                }
            }

            c.TextSpan(")");
        }
示例#2
0
        internal override void WriteTo(CCodeWriterBase c)
        {
            var arrayTypeSymbol     = (ArrayTypeSymbol)Type;
            var arrayInitialization = this.InitializerOpt as ArrayInitialization;

            var initItems = IterateInitializers(arrayInitialization).ToList();

            c.WriteCArrayTemplate(arrayTypeSymbol, false);
            c.TextSpan("::__new_array");
            var arrayInit = arrayInitialization != null && initItems.Count > 0;

            if (arrayInit)
            {
                c.TextSpan("_init");
            }

            c.TextSpan("(");

            var any = false;

            if (!arrayInit || arrayTypeSymbol.Rank > 1)
            {
                if (arrayTypeSymbol.Rank > 1)
                {
                    c.TextSpan("{");
                }

                foreach (var bound in this.bounds)
                {
                    if (any)
                    {
                        c.TextSpan(",");
                        c.WhiteSpace();
                    }

                    var isStaticWrapperCall = bound.IsStaticWrapperCall();
                    if (isStaticWrapperCall)
                    {
                        c.TextSpan("(int32_t)(");
                    }

                    bound.WriteTo(c);
                    if (isStaticWrapperCall)
                    {
                        c.TextSpan(")");
                    }

                    any = true;
                }

                if (arrayTypeSymbol.Rank > 1)
                {
                    c.TextSpan("}");
                }
            }

            if (this.InitializerOpt != null)
            {
                foreach (var bound in initItems)
                {
                    if (any)
                    {
                        c.TextSpan(",");
                        c.WhiteSpace();
                    }

                    bound.WriteTo(c);

                    any = true;
                }
            }

            c.TextSpan(")");
        }