コード例 #1
0
        internal IExpression GetMarginalPrototypeExpression(BasicTransformContext context, IExpression prototypeExpression,
                                                            IList <IList <IExpression> > indices, IList <IList <IExpression> > wildcardVars = null)
        {
            IExpression original     = prototypeExpression;
            int         replaceCount = 0;

            prototypeExpression = ReplaceIndexVars(context, prototypeExpression, indices, wildcardVars, ref replaceCount);
            int mpDepth         = Util.GetArrayDepth(varType, Distribution.GetDomainType(prototypeExpression.GetExpressionType()));
            int indexingDepth   = indices.Count;
            int wildcardBracket = 0;

            for (int depth = mpDepth; depth < indexingDepth; depth++)
            {
                IList <IExpression> indexCollection = Builder.ExprCollection();
                int wildcardCount = 0;
                for (int i = 0; i < indices[depth].Count; i++)
                {
                    if (Recognizer.IsStaticMethod(indices[depth][i], new Func <int>(GateAnalysisTransform.AnyIndex)))
                    {
                        indexCollection.Add(wildcardVars[wildcardBracket][wildcardCount]);
                        wildcardCount++;
                    }
                    else
                    {
                        indexCollection.Add(indices[depth][i]);
                    }
                }
                if (indexCollection.Count > 0)
                {
                    if (wildcardCount > 0)
                    {
                        wildcardBracket++;
                    }
                    prototypeExpression = Builder.ArrayIndex(prototypeExpression, indexCollection);
                    replaceCount++;
                }
            }
            if (replaceCount > 0)
            {
                return(prototypeExpression);
            }
            else
            {
                return(original);
            }
        }