/// <summary> /// Inserts code to handle case negative/independent pattern was found /// at the given position, returns position after inserted operations /// </summary> private SearchProgramOperation insertPatternFoundNegativeIndependent(SearchProgramOperation insertionPoint) { PatternGraph patternGraph = patternGraphWithNestingPatterns.Peek(); string negativeIndependentNamePrefix = NegativeIndependentNamePrefix(patternGraph); if (isNegative) { // build the negative pattern was matched operation NegativePatternMatched patternMatched = new NegativePatternMatched( NegativeIndependentPatternMatchedType.WithoutSubpatterns, negativeIndependentNamePrefix); insertionPoint = insertionPoint.Append(patternMatched); // abort the matching process CheckContinueMatchingOfNegativeFailed abortMatching = new CheckContinueMatchingOfNegativeFailed(patternGraph.isIterationBreaking); insertionPoint = insertionPoint.Append(abortMatching); } else { // build the independent pattern was matched operation IndependentPatternMatched patternMatched = new IndependentPatternMatched( NegativeIndependentPatternMatchedType.WithoutSubpatterns, negativeIndependentNamePrefix); insertionPoint = insertionPoint.Append(patternMatched); if (!isNestedInNegative) // no match object needed(/available) if independent is part of negative { // fill the match object with the candidates // which have passed all the checks for being a match insertionPoint = insertInlinedMatchObjectCreation(insertionPoint, patternGraph, MatchObjectType.Independent); insertionPoint = insertMatchObjectBuilding(insertionPoint, patternGraph, MatchObjectType.Independent, false); insertionPoint = insertMatchObjectBuilding(insertionPoint, patternGraph, MatchObjectType.Independent, true); // if an independent was inlined, we have to insert the local match into a set used for duplicate checking if(wasIndependentInlined(patternGraph, indexOfSchedule)) insertionPoint = insertFillForDuplicateMatchChecking(insertionPoint); } // continue the matching process outside CheckContinueMatchingOfIndependentSucceeded continueMatching = new CheckContinueMatchingOfIndependentSucceeded(); insertionPoint = insertionPoint.Append(continueMatching); } return insertionPoint; }
/// <summary> /// Inserts code to check whether the subpatterns were found and code for case there were some /// at the given position, returns position after inserted operations /// </summary> private SearchProgramOperation insertCheckForSubpatternsFoundNegativeIndependent(SearchProgramOperation insertionPoint) { PatternGraph patternGraph = patternGraphWithNestingPatterns.Peek(); string negativeIndependentNamePrefix = NegativeIndependentNamePrefix(patternGraph); // check whether there were no subpattern matches found CheckPartialMatchForSubpatternsFound checkSubpatternsFound = new CheckPartialMatchForSubpatternsFound(negativeIndependentNamePrefix); SearchProgramOperation continuationPointAfterSubpatternsFound = insertionPoint.Append(checkSubpatternsFound); checkSubpatternsFound.CheckFailedOperations = new SearchProgramList(checkSubpatternsFound); insertionPoint = checkSubpatternsFound.CheckFailedOperations; if (isNegative) { // ---- check failed, some subpattern matches found, negative pattern and subpatterns were matched // build the negative pattern was matched operation NegativePatternMatched patternMatched = new NegativePatternMatched( NegativeIndependentPatternMatchedType.ContainingSubpatterns, negativeIndependentNamePrefix); insertionPoint = insertionPoint.Append(patternMatched); // ---- abort the matching process CheckContinueMatchingOfNegativeFailed abortMatching = new CheckContinueMatchingOfNegativeFailed(patternGraph.isIterationBreaking); insertionPoint = insertionPoint.Append(abortMatching); } else { // ---- check failed, some subpattern matches found, independent pattern and subpatterns were matched // build the independent pattern was matched operation IndependentPatternMatched patternMatched = new IndependentPatternMatched( NegativeIndependentPatternMatchedType.ContainingSubpatterns, negativeIndependentNamePrefix); insertionPoint = insertionPoint.Append(patternMatched); if (!isNestedInNegative) // no match object needed(/available) if independent is part of negative { // ---- fill the match object with the candidates // ---- which have passed all the checks for being a match insertionPoint = insertInlinedMatchObjectCreation(insertionPoint, patternGraph, MatchObjectType.Independent); insertionPoint = insertMatchObjectBuilding(insertionPoint, patternGraph, MatchObjectType.Independent, false); insertionPoint = insertMatchObjectBuilding(insertionPoint, patternGraph, MatchObjectType.Independent, true); // if an independent was inlined, we have to insert the local match into a set used for duplicate checking if(wasIndependentInlined(patternGraph, indexOfSchedule)) insertionPoint = insertFillForDuplicateMatchChecking(insertionPoint); } // ---- continue the matching process outside CheckContinueMatchingOfIndependentSucceeded continueMatching = new CheckContinueMatchingOfIndependentSucceeded(); insertionPoint = insertionPoint.Append(continueMatching); } // nesting level up insertionPoint = continuationPointAfterSubpatternsFound; return insertionPoint; }