Exemplo n.º 1
0
        /// <summary>
        /// Execute padding on all items and make the result character array.
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="arguments">Instead of class variables.</param>
        /// <returns></returns>
        private AType FormatArray(List <int> shape, FormatInformation arguments)
        {
            AType result = AArray.Create(ATypes.AChar);
            int   rank   = shape.Count;

            if (rank > 0)
            {
                for (int i = 0; i < shape[0]; i++)
                {
                    if (rank > 1)
                    {
                        result.AddWithNoUpdate(FormatArray(shape.GetRange(1, rank - 1), arguments));
                    }
                    else
                    {
                        result.AddRangeWithNoUpdate(FormatScalar(arguments));
                    }
                }

                result.UpdateInfo();
            }
            else
            {
                result.AddRange(FormatScalar(arguments));
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="formaters"></param>
        /// <returns></returns>
        private static AType FormatArray(AType argument, List <FormatInfo> formaters)
        {
            AType result = AArray.Create(ATypes.AChar);

            AType[] formatted;

            if (argument.IsArray)
            {
                for (int i = 0; i < argument.Length; i++)
                {
                    if (argument.Rank > 1)
                    {
                        result.AddWithNoUpdate(FormatArray(argument[i], formaters));
                    }
                    else
                    {
                        FormatInfo format = formaters[formaters.Count > 1 ? i : 0];
                        formatted = argument.IsNumber
                            ? FormatNumber(argument[i], format)
                            : FormatSymbol(argument[i], format);

                        if (formatted != null)
                        {
                            result.AddRangeWithNoUpdate(formatted);
                        }
                    }
                }

                result.UpdateInfo();
            }
            else
            {
                FormatInfo format = formaters[0];
                formatted = argument.IsNumber
                    ? FormatNumber(argument, format)
                    : FormatSymbol(argument, format);

                if (formatted != null)
                {
                    result.AddRange(formatted);
                }
            }

            return(result);
        }