private static string BuildArrayBoundsVariables(StringBuilder stringBuilder, int rank, bool emitArrayBoundsCheck, int indentationLevel)
        {
            stringBuilder.Clear();
            string str = new string('\t', indentationLevel);

            for (int i = 0; i < rank; i++)
            {
                string length = BoundVariableNameFor(i);
                if (i != 0)
                {
                    stringBuilder.Append(str);
                }
                object[] args = new object[] { Naming.ForArrayIndexType(), length, i, Environment.NewLine };
                stringBuilder.AppendFormat("{0} {1} = bounds[{2}].length;{3}", args);
                if (emitArrayBoundsCheck)
                {
                    char ch = (char)(0x69 + i);
                    stringBuilder.AppendFormat("{0}{1}{2}", str, Emit.MultiDimensionalArrayBoundsCheck(length, ch.ToString()), Environment.NewLine);
                }
            }
            return(stringBuilder.ToString());
        }
Example #2
0
 public static string LoadArrayElement(string array, string index, bool useArrayBoundsCheck) =>
 $"({array})->{Naming.ForArrayItemGetter(useArrayBoundsCheck)}(static_cast<{Naming.ForArrayIndexType()}>({index}))";