protected void GetJaggedArrayIndicesAndSizes(IVariableArray array, out IList <IVariableDeclaration[]> jaggedIndexVars, out IList <IExpression[]> jaggedSizes) { Set <IVariableDeclaration> allVars = new Set <IVariableDeclaration>(ReferenceEqualityComparer <IVariableDeclaration> .Instance); jaggedIndexVars = new List <IVariableDeclaration[]>(); jaggedSizes = new List <IExpression[]>(); while (true) { Type arrayType = array.GetExpression().GetExpressionType(); Type elementType = Util.GetElementType(arrayType, out int rank); if (!arrayType.IsAssignableFrom(Util.MakeArrayType(elementType, rank))) { break; } GetArrayIndicesAndSizes(array, out IVariableDeclaration[] indexVars, out IExpression[] sizes);
protected void GetJaggedArrayIndicesAndSizes(IVariableArray array, out IList <IVariableDeclaration[]> jaggedIndexVars, out IList <IExpression[]> jaggedSizes) { Set <IVariableDeclaration> allVars = new Set <IVariableDeclaration>(new IdentityComparer <IVariableDeclaration>()); jaggedIndexVars = new List <IVariableDeclaration[]>(); jaggedSizes = new List <IExpression[]>(); while (true) { Type arrayType = array.GetExpression().GetExpressionType(); Type elementType = Util.GetElementType(arrayType, out int rank); if (!arrayType.IsAssignableFrom(Util.MakeArrayType(elementType, rank))) { break; } IVariableDeclaration[] indexVars; IExpression[] sizes; GetArrayIndicesAndSizes(array, out indexVars, out sizes); foreach (IVariableDeclaration ivd in indexVars) { if (allVars.Contains(ivd)) { throw new CompilationFailedException("Array '" + array.Name + "' is indexed by range '" + ivd.Name + "' on multiple dimensions, which is not allowed. Use range cloning instead."); } allVars.Add(ivd); } jaggedIndexVars.Add(indexVars); jaggedSizes.Add(sizes); if (array is IVariableJaggedArray variableJaggedArray) { IVariable itemPrototype = variableJaggedArray.ItemPrototype; if (itemPrototype is IVariableArray variableArray) { array = variableArray; } else { break; } } else { break; } } }