Exemplo n.º 1
0
        /// <summary>
        /// Builds search program from scheduled search plan in pattern graph of the subpattern rule pattern
        /// </summary>
        public static SearchProgram BuildSearchProgram(
            IGraphModel model,
            LGSPMatchingPattern matchingPattern,
            bool parallelized,
            bool emitProfiling)
        {
            Debug.Assert(!(matchingPattern is LGSPRulePattern));

            PatternGraph patternGraph         = matchingPattern.patternGraph;
            String       rulePatternClassName = NamesOfEntities.RulePatternClassName(matchingPattern.name, matchingPattern.PatternGraph.Package, true);

            SearchProgramBodyBuilder builder = new SearchProgramBodyBuilder(
                SearchProgramType.Subpattern,
                model,
                rulePatternClassName,
                null,
                null,
                null,
                patternGraph,
                emitProfiling,
                parallelized,
                0
                );

            List <String> matchingPatternClassTypeNames = new List <String>();
            List <Dictionary <PatternGraph, bool> > nestedIndependents = new List <Dictionary <PatternGraph, bool> >();

            ExtractNestedIndependents(matchingPatternClassTypeNames, nestedIndependents, matchingPattern, patternGraph);

            // build outermost search program operation, create the list anchor starting its program
            SearchProgram searchProgram = new SearchProgramOfSubpattern(
                rulePatternClassName,
                patternGraph.Name,
                matchingPattern.patternGraph.patternGraphsOnPathToEnclosedPatternpath,
                "myMatch",
                builder.wasIndependentInlined(patternGraph, 0),
                matchingPatternClassTypeNames, nestedIndependents,
                parallelized);

            searchProgram.OperationsList = new SearchProgramList(searchProgram);
            SearchProgramOperation insertionPoint = searchProgram.OperationsList;

            insertionPoint = insertVariableDeclarations(insertionPoint, patternGraph);

            // initialize task/result-pushdown handling in subpattern matcher
            InitializeSubpatternMatching initialize =
                new InitializeSubpatternMatching(InitializeFinalizeSubpatternMatchingType.Normal);

            insertionPoint = insertionPoint.Append(initialize);

            // start building with first operation in scheduled search plan
            insertionPoint = builder.BuildScheduledSearchPlanOperationIntoSearchProgram(
                0,
                insertionPoint);

            // finalize task/result-pushdown handling in subpattern matcher
            FinalizeSubpatternMatching finalize =
                new FinalizeSubpatternMatching(InitializeFinalizeSubpatternMatchingType.Normal);

            insertionPoint = insertionPoint.Append(finalize);

            return(searchProgram);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds search program from scheduled search plan in pattern graph of the subpattern rule pattern
        /// </summary>
        public SearchProgram BuildSearchProgram(
            IGraphModel model,
            LGSPMatchingPattern matchingPattern,
            bool parallelized,
            bool emitProfiling)
        {
            Debug.Assert(!(matchingPattern is LGSPRulePattern));

            PatternGraph patternGraph = matchingPattern.patternGraph;
            programType = SearchProgramType.Subpattern;
            this.model = model;
            patternGraphWithNestingPatterns = new Stack<PatternGraph>();
            patternGraphWithNestingPatterns.Push(patternGraph);
            this.parallelized = parallelized;
            isoSpaceNeverAboveMaxIsoSpace = patternGraphWithNestingPatterns.Peek().maxIsoSpace < (int)LGSPElemFlags.MAX_ISO_SPACE;
            isNegative = false;
            isNestedInNegative = false;
            rulePatternClassName = NamesOfEntities.RulePatternClassName(matchingPattern.name, matchingPattern.PatternGraph.Package, true);
            this.emitProfiling = emitProfiling;
            packagePrefixedActionName = null;
            firstLoopPassed = false;

            // build outermost search program operation, create the list anchor starting its program
            SearchProgram searchProgram = new SearchProgramOfSubpattern(
                rulePatternClassName,
                patternGraph.Name,
                matchingPattern.patternGraph.patternGraphsOnPathToEnclosedPatternpath,
                "myMatch",
                wasIndependentInlined(patternGraph, indexOfSchedule), parallelized);
            searchProgram.OperationsList = new SearchProgramList(searchProgram);
            SearchProgramOperation insertionPoint = searchProgram.OperationsList;

            insertionPoint = insertVariableDeclarations(insertionPoint, patternGraph);

            // initialize task/result-pushdown handling in subpattern matcher
            InitializeSubpatternMatching initialize = 
                new InitializeSubpatternMatching(InitializeFinalizeSubpatternMatchingType.Normal);
            insertionPoint = insertionPoint.Append(initialize);

            // start building with first operation in scheduled search plan
            indexOfSchedule = 0;
            insertionPoint = BuildScheduledSearchPlanOperationIntoSearchProgram(
                0,
                insertionPoint);

            // finalize task/result-pushdown handling in subpattern matcher
            FinalizeSubpatternMatching finalize =
                new FinalizeSubpatternMatching(InitializeFinalizeSubpatternMatchingType.Normal);
            insertionPoint = insertionPoint.Append(finalize);

            patternGraphWithNestingPatterns.Pop();

            return searchProgram;
        }