protected LanguageProvider(TIdentityManager identityManager)
        {
            var defaultServices = new Dictionary <Guid, ILanguageService>();
            var cachedServices  = new MultikeyedDictionary <Guid, Type, ILanguageService>();

            cachedServices[LanguageGuids.Services.ClassServices.ClassCreatorService, typeof(IIntermediateTypeCtorLanguageService <IIntermediateClassType>)]             = defaultServices[LanguageGuids.Services.ClassServices.ClassCreatorService] = DefaultLanguageServices.GetBoundIntermediateClassCreatorService(this.Language, this);
            cachedServices[LanguageGuids.Services.IntermediateDelegateCreatorService, typeof(IIntermediateTypeCtorLanguageService <IIntermediateDelegateType>)]         = defaultServices[LanguageGuids.Services.IntermediateDelegateCreatorService] = DefaultLanguageServices.GetBoundIntermediateDelegateCreatorService(this.Language, this);
            cachedServices[LanguageGuids.Services.IntermediateEnumCreatorService, typeof(IIntermediateTypeCtorLanguageService <IIntermediateEnumType>)]                 = defaultServices[LanguageGuids.Services.IntermediateEnumCreatorService] = DefaultLanguageServices.GetBoundIntermediateEnumCreatorService(this.Language, this);
            cachedServices[LanguageGuids.Services.InterfaceServices.InterfaceCreatorService, typeof(IIntermediateTypeCtorLanguageService <IIntermediateInterfaceType>)] = defaultServices[LanguageGuids.Services.InterfaceServices.InterfaceCreatorService] = DefaultLanguageServices.GetBoundIntermediateInterfaceCreatorService(this.Language, this);
            cachedServices[LanguageGuids.Services.StructServices.StructCreatorService, typeof(IIntermediateTypeCtorLanguageService <IIntermediateStructType>)]          = defaultServices[LanguageGuids.Services.StructServices.StructCreatorService] = DefaultLanguageServices.GetBoundIntermediateStructCreatorService(this.Language, this);
            cachedServices[LanguageGuids.Services.IntermediateAssemblyCreatorService, typeof(IIntermediateAssemblyCtorLanguageService)] = defaultServices[LanguageGuids.Services.IntermediateAssemblyCreatorService] = DefaultLanguageServices.GetBoundIntermediateAssemblyCreatorService <TLanguage, TProvider, TIdentityManager, TTypeIdentity, TAssemblyIdentity>(this.Language, (TProvider)(object)this);
            this.defaultServices = defaultServices;
            this.cachedServices  = cachedServices;
            supportedServices    = new Dictionary <Guid, ILanguageService>();
            this.identityManager = identityManager;
        }
Ejemplo n.º 2
0
        internal MultikeyedDictionary <GrammarVocabulary, int, List <Tuple <Tuple <int[], PredictionTree>[], int[]> > > ObtainTerminalAmbiguities(
            Dictionary <SyntacticalDFAState, PredictionTreeLeaf> fullSeries,
            ControlledDictionary <IOilexerGrammarProductionRuleEntry, SyntacticalDFARootState> ruleDFAs,
            Dictionary <IOilexerGrammarProductionRuleEntry, GrammarVocabulary> ruleLookup,
            GrammarSymbolSet grammarSymbols)
        {
            if (!this.Veins.DFAOriginState.IsEdge)
            {
                return(new MultikeyedDictionary <GrammarVocabulary, int, List <Tuple <Tuple <int[], PredictionTree>[], int[]> > >());
            }
            var tempDictionary  = new MultikeyedDictionary <PredictionTreeBranch, GrammarVocabulary, Tuple <int[], PredictionTree> >();
            var rootNode        = fullSeries[ruleDFAs[this.Rule]];
            var currentIncoming = new List <PredictionTreeBranch>(rootNode.incoming);
            var reductions      = rootNode.PointsOfReduction.ToArray();

            if (reductions.Length > 0)
            {
            }
            var totalIncoming = new HashSet <PredictionTreeBranch>();
            Dictionary <PredictionTree, PredictionTree> uniqueSet = new Dictionary <PredictionTree, PredictionTree>();

            foreach (var path in currentIncoming)
            {
                var transitionTableResult = new FiniteAutomataMultiTargetTransitionTable <GrammarVocabulary, Tuple <int, PredictionTreeBranch> >();
                var masterPathChop        = new PredictionTreeBranch(path.Take(path.Depth).Concat(new[] { this }).ToArray(), path.Depth, false, false);

                masterPathChop.SetDeviations(path.GetDeviationsUpTo(path.Depth));
                ObtainTerminalAmbiguitiesOnPath(masterPathChop, fullSeries, ruleDFAs, ruleLookup, transitionTableResult, grammarSymbols);

                /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \
                 * Construct the sequence of Path->Grammar->PathSets based           *
                 * off of the table provided by the ObtainTerminalAmbiguitiesOnPath. *
                 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
                foreach (var transition in transitionTableResult.Keys)
                {
                    var epDepthLookup =
                        (from entry in transitionTableResult[transition]
                         group entry.Item1 by entry.Item2).ToDictionary(k => k.Key, v => v.ToArray());
                    //int minDepth;
                    //var uniqueCurrent = GetUniqueDPathSet(uniqueSet, transitionTableResult, transition, epDepthLookup);
                    //var subPath = new PredictionTreeBranch(path.Skip(minDepth).ToList(), path.Depth - minDepth, minDepth: path.MinDepth);
                    tempDictionary.TryAdd(path, transition, Tuple.Create((from epDepth in transitionTableResult[transition]
                                                                          select epDepth.Item1).ToArray(), GetFollowDPathSet(transitionTableResult, transition, epDepthLookup)));
                }
            }



            var regrouping = (from ksvp in tempDictionary
                              group new { Path = ksvp.Keys.Key1, Set = ksvp.Value } by ksvp.Keys.Key2).ToDictionary(k => k.Key, v => v.ToArray());

            /*
             * foreach (var pathSet in from key in regrouping.Keys
             *                      let value = regrouping[key]
             *                      from r in value
             *                      select r.Set)
             *  pathSet.Item2.FixAllPaths();//*/

            var comparisons = (from key in regrouping.Keys
                               let value = regrouping[key]
                                           let kRewrite = from r in value
                                                          select r.Set
                                                          let commonalities = PredictionTree.GetCompoundRightSideSimilarities(kRewrite)
                                                                              select new { Commonalities = commonalities, Transition = key }).ToDictionary(k => k.Transition, v => v.Commonalities);
            var resultDictionary = new MultikeyedDictionary <GrammarVocabulary, int, List <Tuple <Tuple <int[], PredictionTree>[], int[]> > >();

            /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \
             * Once we're done, we need to rebuild the paths with the MinDepth set to  *
             * their current Depth.  This is to ensure that it the PathSets don't try  *
             * to reduce more than necessary.                                          *
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
             * Then we take that set and perform a right-hand-side comparison between  *
             * the elements.                                                           *
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
             * This will be used later to reduce the walking necessary to isolate the  *
             * proper machine to use to disambiguate the look-ahead.                   *
             \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
            foreach (var comparison in comparisons.Keys)
            {
                var comparisonElements = comparisons[comparison];
                foreach (var memberCount in comparisonElements.Keys)
                {
                    var comparisonElement = comparisonElements[memberCount];
                    resultDictionary.Add(comparison, memberCount, comparisonElement);
                }
            }
            return(resultDictionary);
        }
Ejemplo n.º 3
0
        private static Dictionary <Tuple <string, bool, bool>, VisitorBuilder> BuildInheritedVisitors(Dictionary <VisitorTargetDetail, List <IType> > visitorContextualDetail, Dictionary <VisitorTargetDetail, VisitorBuilder> builders, ICSharpAssembly assembly)
        {
            var derivedContextDetail = new MultikeyedDictionary <string, VisitorTargetDetail, List <IType> >();
            var derivedDetail        = visitorContextualDetail.Keys.Where(k => !string.IsNullOrEmpty(k.DerivedThroughInheriting)).ToArray();

            foreach (var contextKey in derivedDetail)
            {
                derivedContextDetail.Add(contextKey.TargetContext, contextKey, visitorContextualDetail[contextKey]);
            }
            var inheritanceTree = (from ksvp in derivedContextDetail
                                   orderby ksvp.Keys.Key1, ksvp.Keys.Key2.DerivedThroughInheriting
                                   group ksvp.Keys.Key2.DerivedThroughInheriting by Tuple.Create(ksvp.Keys.Key1, ksvp.Keys.Key2.ContextualVisitor, ksvp.Keys.Key2.YieldingVisitor))
                                  .ToDictionary(
                k => k.Key,
                v => v.Distinct()
                .ToArray());
            var typelessVisitors = new Dictionary <Tuple <string, bool, bool>, VisitorBuilder>();

            foreach (var hierarchyKey in inheritanceTree.Keys)
            {
                bool addedBuilder      = false;
                var  inheritanceDetail = inheritanceTree[hierarchyKey];
                var  firstContext      = visitorContextualDetail.Keys.FirstOrDefault(k => k.ContextualVisitor == hierarchyKey.Item2 && k.YieldingVisitor == hierarchyKey.Item3 && k.TargetContext == hierarchyKey.Item1 && string.IsNullOrEmpty(k.DerivedThroughInheriting));
                if (firstContext == null)
                {
                    var builder = GetVisitorBuilderWith(hierarchyKey);
                    firstContext = builder.Detail;
                    typelessVisitors.Add(hierarchyKey, builder);
                    addedBuilder = true;
                }
                var children =
                    (from child in inheritanceDetail.Select(k => Tuple.Create(k, hierarchyKey.Item2, hierarchyKey.Item3))
                     let childContext = visitorContextualDetail.Keys.FirstOrDefault(k => k.ContextualVisitor == child.Item2 && k.YieldingVisitor == child.Item3 && k.TargetContext == child.Item1)
                                        let actualChildContext =
                         childContext == null
                         ? GetVisitorBuilderWith(child)
                         : builders.ContainsKey(childContext)
                           ? builders[childContext]
                           : typelessVisitors[new Tuple <string, bool, bool>(childContext.TargetContext, childContext.ContextualVisitor, childContext.YieldingVisitor)]
                         select actualChildContext).ToArray();
                foreach (var childBuilder in children.Where(actualChildContext => actualChildContext.VisitorInterface == null).Select(childBuilder => new { Builder = childBuilder, Key = Tuple.Create(childBuilder.Detail.TargetContext, childBuilder.Detail.ContextualVisitor, childBuilder.Detail.YieldingVisitor) }).Where(x => !typelessVisitors.ContainsKey(x.Key)))
                {
                    typelessVisitors.Add(childBuilder.Key, childBuilder.Builder);
                    childBuilder.Builder.ScaffoldInterface(assembly);
                }

                if (addedBuilder)
                {
                    var currentBuilder = typelessVisitors[hierarchyKey];
                    if (currentBuilder.VisitorInterface == null)
                    {
                        currentBuilder.SkippedTypes      =
                            currentBuilder.RelevantTypes =
                                children
                                .Select(k => k.RelevantTypes)
                                .SelectMany(k => k)
                                .Distinct()
                                .ToList();
                        currentBuilder.ScaffoldInterface(assembly);
                        foreach (var childBuilder in children)
                        {
                            currentBuilder.VisitorInterface.ImplementedInterfaces.Add(childBuilder.VisitorInterface);
                        }
                        currentBuilder.ChildBuilders = children;
                    }
                }
                else
                {
                    var currentBuilder = builders[firstContext];
                    currentBuilder.ChildBuilders = children;
                    foreach (var childBuilder in children)
                    {
                        currentBuilder.VisitorInterface.ImplementedInterfaces.Add(childBuilder.VisitorInterface);
                    }
                }
            }
            return(typelessVisitors);
        }
Ejemplo n.º 4
0
        //internal static RuntimeCoreType GetIntrinsicBinaryOperationResult(IType left, IType right)
        //{

        //    RuntimeCoreType result;
        //    var tcL = left.GetCoreType();
        //    var tcR = right.GetCoreType();
        //    if (IntrinsicOperationResults.TryGetValue(tcL, tcR, out result))
        //        return result;
        //    return RuntimeCoreType.None;
        //}

        private static MultikeyedDictionary <RuntimeCoreType, RuntimeCoreType, RuntimeCoreType> ConstructIntrinsicOperationResultTypes()
        {
            var unorderedIntrinsicResults = new MultikeyedDictionary <RuntimeCoreType, RuntimeCoreType, RuntimeCoreType>();

            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Byte, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.UInt16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.UInt32, RuntimeCoreType.UInt32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.UInt64, RuntimeCoreType.UInt64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Single, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Double, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Char, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.SByte, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Int16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Int32, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Byte, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.UInt16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.UInt32, RuntimeCoreType.UInt32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.UInt64, RuntimeCoreType.UInt64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Single, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Double, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Char, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.SByte, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Int16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Int32, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt16, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.UInt32, RuntimeCoreType.UInt32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.UInt64, RuntimeCoreType.UInt64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Single, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Double, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Char, RuntimeCoreType.UInt32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.SByte, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Int16, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Int32, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt32, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt64, RuntimeCoreType.UInt32, RuntimeCoreType.UInt32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt64, RuntimeCoreType.UInt64, RuntimeCoreType.UInt64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt64, RuntimeCoreType.Single, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt64, RuntimeCoreType.Double, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt64, RuntimeCoreType.Char, RuntimeCoreType.UInt32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.UInt64, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.Single, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.Double, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.Char, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.SByte, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.Int16, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.Int32, RuntimeCoreType.Single);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Single, RuntimeCoreType.Int64, RuntimeCoreType.Single);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Double, RuntimeCoreType.Double, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Double, RuntimeCoreType.Char, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Double, RuntimeCoreType.SByte, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Double, RuntimeCoreType.Int16, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Double, RuntimeCoreType.Int32, RuntimeCoreType.Double);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Double, RuntimeCoreType.Int64, RuntimeCoreType.Double);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Char, RuntimeCoreType.Char, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Char, RuntimeCoreType.SByte, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Char, RuntimeCoreType.Int16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Char, RuntimeCoreType.Int32, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Char, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Char, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.SByte, RuntimeCoreType.SByte, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.SByte, RuntimeCoreType.Int16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.SByte, RuntimeCoreType.Int32, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.SByte, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.SByte, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Int16, RuntimeCoreType.Int16, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Int16, RuntimeCoreType.Int32, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Int16, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Int16, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Int32, RuntimeCoreType.Int32, RuntimeCoreType.Int32);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Int32, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Int32, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Int64, RuntimeCoreType.Int64, RuntimeCoreType.Int64);
            unorderedIntrinsicResults.Add(RuntimeCoreType.Int64, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            unorderedIntrinsicResults.Add(RuntimeCoreType.Decimal, RuntimeCoreType.Decimal, RuntimeCoreType.Decimal);

            foreach (var keysValue in unorderedIntrinsicResults.ToArray())
            {
                RuntimeCoreType dummyType;
                if (!unorderedIntrinsicResults.TryGetValue(keysValue.Keys.Key2, keysValue.Keys.Key1, out dummyType))
                {
                    unorderedIntrinsicResults.Add(keysValue.Keys.Key2, keysValue.Keys.Key1, unorderedIntrinsicResults[keysValue.Keys.Key1, keysValue.Keys.Key2]);
                }
            }
            var ksvsSet =
                from ksv in unorderedIntrinsicResults
                orderby ksv.Keys.Key1, ksv.Keys.Key2
            select ksv;
            var orderedIntrinsicResults = new MultikeyedDictionary <RuntimeCoreType, RuntimeCoreType, RuntimeCoreType>();

            foreach (var element in ksvsSet)
            {
                orderedIntrinsicResults.Add(element.Keys.Key1, element.Keys.Key2, element.Value);
            }
            return(orderedIntrinsicResults);
        }
Ejemplo n.º 5
0
        internal IArrayType CreateArrayInternal(int[] lowerBounds, uint[] lengths, Func <int[], uint[], IArrayType> creator)
        {
            /* *
             * Can't define a non-zero vector array.  The CLI doesn't provide innate support
             * for their declaration, but you can create them, just not pass them to methods
             * expecting vector arrays.
             * */
            bool       found  = false;
            IArrayType result = null;

            if (lengths == null && lowerBounds == null)
            {
                throw new ArgumentNullException("lowerBounds");
            }
            if (this.lengthsAndLowersCache == null)
            {
                this.lengthsAndLowersCache = new MultikeyedDictionary <int[], uint[], IArrayType>();
            }

            if (lengths == null)
            {
                lengths = new uint[0];
            }
            else if (lowerBounds == null)
            {
                lowerBounds = new int[0];
            }
            foreach (var cacheElement in this.lengthsAndLowersCache)
            {
                var currentLowerBounds = cacheElement.Keys.Key1;
                var currentLengths     = cacheElement.Keys.Key2;

                /* *
                 * Search for a series of lower-bounds that is the same.
                 * */
                if (currentLowerBounds.Length != lowerBounds.Length ||
                    currentLengths.Length != lengths.Length)
                {
                    continue;
                }
                else
                {
                    /* *
                     * Only where all the lower bounds are equal...
                     * */
                    found = true;
                    for (int i = 0; i < currentLowerBounds.Length; i++)
                    {
                        if (lowerBounds[i] != currentLowerBounds[i])
                        {
                            found = false;
                            break;
                        }
                    }
                    for (int i = 0; i < currentLengths.Length; i++)
                    {
                        if (lengths[i] != currentLengths[i])
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        result = cacheElement.Value;
                        break;
                    }
                }
            }

            /* *
             * Create the element using the multi-dimensional delegate
             * provided at initialization if the member does not exist.
             * */
            if (!found)
            {
                this.lengthsAndLowersCache.Add(lowerBounds, lengths, result = creator(lowerBounds, lengths));
            }
            //this.noLengthsCache.Add(lowerBounds, result = creator(lowerBounds));
            return(result);
        }