示例#1
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (InParallelizedBody)
            {
                sourceCode.AppendFrontFormat("{0}.{1} match = parallelTaskMatches[threadId].GetNextUnfilledPosition();\n",
                                             RulePatternClassName, NamesOfEntities.MatchClassName(PatternName));
            }
            else
            {
                sourceCode.AppendFrontFormat("{0}.{1} match = matches.GetNextUnfilledPosition();\n",
                                             RulePatternClassName, NamesOfEntities.MatchClassName(PatternName));
            }

            // emit match building operations
            MatchBuildingOperations.Emit(sourceCode);

            if (InParallelizedBody)
            {
                sourceCode.AppendFront("match.IterationNumber = currentIterationNumber;\n");
                sourceCode.AppendFront("parallelTaskMatches[threadId].PositionWasFilledFixIt();\n");
            }
            else
            {
                sourceCode.AppendFront("matches.PositionWasFilledFixIt();\n");
            }
        }
        public override void Emit(SourceBuilder sourceCode)
        {
            if (sourceCode.CommentSourceCode)
            {
                sourceCode.AppendFrontFormat("// Lookup {0} \n", PatternElementName);
            }

            string variableContainingTypeIDForCandidate =
                NamesOfEntities.TypeIdForCandidateVariable(PatternElementName);

            sourceCode.AppendFrontFormat("int {0} = {1};\n",
                                         variableContainingTypeIDForCandidate, TypeID);
        }
        public override void Emit(SourceBuilder sourceCode)
        {
            string variableContainingCandidate = NamesOfEntities.CandidateVariable(PatternElementName);
            string variableContainingBackupOfMappedMemberGlobalSome =
                NamesOfEntities.VariableWithBackupOfIsMatchedGlobalInSomePatternBit(PatternElementName, NegativeIndependentNamePrefix);

            sourceCode.AppendFrontFormat("uint {0};\n", variableContainingBackupOfMappedMemberGlobalSome);
            string isMatchedInSomePatternBit = "(uint)GRGEN_LGSP.LGSPElemFlags.IS_MATCHED_BY_SOME_ENCLOSING_PATTERN";

            sourceCode.AppendFrontFormat("{0} = {1}.lgspFlags & {2};\n",
                                         variableContainingBackupOfMappedMemberGlobalSome, variableContainingCandidate, isMatchedInSomePatternBit);
            sourceCode.AppendFrontFormat("{0}.lgspFlags |= {1};\n",
                                         variableContainingCandidate, isMatchedInSomePatternBit);
        }
        public override void Emit(SourceBuilder sourceCode)
        {
            if (sourceCode.CommentSourceCode)
            {
                sourceCode.AppendFrontFormat("// Lookup {0} \n", PatternElementName);
            }

            // todo: randomisierte auswahl des typen wenn RANDOM_LOOKUP_LIST_START ?

            // emit type iteration loop header
            string typeOfVariableContainingType       = NamesOfEntities.TypeOfVariableContainingType(IsNode);
            string variableContainingTypeForCandidate =
                NamesOfEntities.TypeForCandidateVariable(PatternElementName);
            string containerWithAvailableTypes;

            if (Type == GetTypeByIterationType.ExplicitelyGiven)
            {
                containerWithAvailableTypes = TypeName
                                              + "." + PatternElementName + "_AllowedTypes";
            }
            else //(Type == GetTypeByIterationType.AllCompatible)
            {
                containerWithAvailableTypes = RulePatternTypeName
                                              + ".typeVar.SubOrSameTypes";
            }

            sourceCode.AppendFrontFormat("foreach({0} {1} in {2})\n",
                                         typeOfVariableContainingType, variableContainingTypeForCandidate,
                                         containerWithAvailableTypes);

            // open loop
            sourceCode.AppendFront("{\n");
            sourceCode.Indent();

            // emit type id setting and loop body
            string variableContainingTypeIDForCandidate =
                NamesOfEntities.TypeIdForCandidateVariable(PatternElementName);

            sourceCode.AppendFrontFormat("int {0} = {1}.TypeID;\n",
                                         variableContainingTypeIDForCandidate, variableContainingTypeForCandidate);

            NestedOperationsList.Emit(sourceCode);

            // close loop
            sourceCode.Unindent();
            sourceCode.AppendFront("}\n");
        }
示例#5
0
        public override void Dump(SourceBuilder builder)
        {
            builder.AppendFrontFormat("LeafSubpatternMatched {0}\n", IsIteratedNullMatch ? "IteratedNullMatch " : "");

            if (MatchBuildingOperations != null)
            {
                builder.Indent();
                MatchBuildingOperations.Dump(builder);
                builder.Unindent();
            }
        }
示例#6
0
 public override void Emit(SourceBuilder sourceCode)
 {
     if (Type == NegativeIndependentPatternMatchedType.WithoutSubpatterns)
     {
         if (sourceCode.CommentSourceCode)
         {
             sourceCode.AppendFront("// independent pattern found\n");
         }
     }
     else
     {
         if (sourceCode.CommentSourceCode)
         {
             sourceCode.AppendFront("// independent pattern with contained subpatterns found\n");
         }
         sourceCode.AppendFrontFormat("Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch = {0}matchesList[0];\n",
                                      NegativeIndependentNamePrefix);
         sourceCode.AppendFrontFormat("{0}matchesList.Clear();\n", NegativeIndependentNamePrefix);
     }
 }
示例#7
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (sourceCode.CommentSourceCode)
            {
                sourceCode.AppendFrontFormat("// Alternative case {0}{1} \n", PathPrefix, CaseName);
            }

            sourceCode.AppendFront("do {\n");
            sourceCode.Indent();
            string whichCase = RulePatternClassName + "." + PathPrefix + "CaseNums.@" + CaseName;

            sourceCode.AppendFrontFormat("patternGraph = patternGraphs[(int){0}];\n", whichCase);

            if (WasIndependentInlined)
            {
                sourceCode.AppendFrontFormat("Dictionary<int, {0}> {1} = null;\n",
                                             RulePatternClassName + "." + NamesOfEntities.MatchClassName(PathPrefix + CaseName),
                                             NamesOfEntities.FoundMatchesForFilteringVariable());
            }

            OperationsList.Emit(sourceCode);

            if (WasIndependentInlined)
            {
                sourceCode.AppendFrontFormat("if({0} != null)\n",
                                             NamesOfEntities.FoundMatchesForFilteringVariable());
                sourceCode.AppendFront("{\n");
                sourceCode.Indent();

                sourceCode.AppendFrontFormat("foreach({0} toClean in {1}.Values) toClean.CleanNextWithSameHash();\n",
                                             RulePatternClassName + "." + NamesOfEntities.MatchClassName(PathPrefix + CaseName),
                                             NamesOfEntities.FoundMatchesForFilteringVariable());

                sourceCode.Unindent();
                sourceCode.AppendFront("}\n");
            }

            sourceCode.Unindent();
            sourceCode.AppendFront("} while(false);\n");
        }
示例#8
0
 public override void Dump(SourceBuilder builder)
 {
     // first dump check
     builder.AppendFrontFormat("CheckContinueMatching IteratedPatternFound {0}\n",
                               IsIterationBreaking ? "IterationBreaking" : "");
     // then operations for case check failed
     if (CheckFailedOperations != null)
     {
         builder.Indent();
         CheckFailedOperations.Dump(builder);
         builder.Unindent();
     }
 }
示例#9
0
        public override void Dump(SourceBuilder builder)
        {
            // first dump local content
            builder.AppendFrontFormat("AlternativeCaseMatching {0}{1}\n", PathPrefix, CaseName);

            // then nested content
            if (OperationsList != null)
            {
                builder.Indent();
                OperationsList.Dump(builder);
                builder.Unindent();
            }
        }
示例#10
0
        public override void Emit(SourceBuilder sourceCode)
        {
            sourceCode.AppendFront("++isoSpace;\n");
            if (Parallel)
            {
                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.AppendFront("if(isoSpace >= (int) GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE && " +
                                           "isoSpace - (int) GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE + 1 > graph.perThreadInIsoSpaceMatchedElements[threadId].Count) {\n");
                    sourceCode.Indent();
                    sourceCode.AppendFront("graph.AllocateFurtherIsomorphySpaceNestingLevelForParallelizedMatching(threadId);\n");
                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");
                }
            }
            else
            {
                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.AppendFront("if(isoSpace >= (int) GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE && "
                                           + "isoSpace - (int) GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE + 1 > graph.inIsoSpaceMatchedElements.Count) {\n");
                    sourceCode.Indent();
                    sourceCode.AppendFront("graph.inIsoSpaceMatchedElements.Add(new Dictionary<GRGEN_LIBGR.IGraphElement, GRGEN_LIBGR.IGraphElement>());\n");
                    sourceCode.AppendFront("graph.inIsoSpaceMatchedElementsGlobal.Add(new Dictionary<GRGEN_LIBGR.IGraphElement, GRGEN_LIBGR.IGraphElement>());\n");
                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");
                }
            }

            if (SetupSubpatternMatching)
            {
                sourceCode.AppendFrontFormat("Stack<GRGEN_LGSP.LGSPSubpatternAction> {0}openTasks ="
                                             + " new Stack<GRGEN_LGSP.LGSPSubpatternAction>();\n", NegativeIndependentNamePrefix);
                sourceCode.AppendFrontFormat("List<Stack<GRGEN_LIBGR.IMatch>> {0}foundPartialMatches ="
                                             + " new List<Stack<GRGEN_LIBGR.IMatch>>();\n", NegativeIndependentNamePrefix);
                sourceCode.AppendFrontFormat("List<Stack<GRGEN_LIBGR.IMatch>> {0}matchesList ="
                                             + " {0}foundPartialMatches;\n", NegativeIndependentNamePrefix);
            }
        }
示例#11
0
        public override void Emit(SourceBuilder sourceCode)
        {
            sourceCode.AppendFront("Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch = new Stack<GRGEN_LIBGR.IMatch>();\n");
            sourceCode.AppendFront("foundPartialMatches.Add(currentFoundPartialMatch);\n");

            sourceCode.AppendFrontFormat("{0}.{1} match = new {0}.{1}();\n",
                                         RulePatternClassName, NamesOfEntities.MatchClassName(PatternName));
            if (IsIteratedNullMatch)
            {
                sourceCode.AppendFront("match._isNullMatch = true; // null match of iterated pattern\n");
            }
            else
            {
                MatchBuildingOperations.Emit(sourceCode); // emit match building operations
            }
            sourceCode.AppendFront("currentFoundPartialMatch.Push(match);\n");
        }
示例#12
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (Type == NegativeIndependentPatternMatchedType.WithoutSubpatterns)
            {
                if (sourceCode.CommentSourceCode)
                {
                    sourceCode.AppendFront("// negative pattern found\n");
                }
            }
            else
            {
                if (sourceCode.CommentSourceCode)
                {
                    sourceCode.AppendFront("// negative pattern with contained subpatterns found\n");
                }

                sourceCode.AppendFrontFormat("{0}matchesList.Clear();\n", NegativeIndependentNamePrefix);
            }
        }
示例#13
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (sourceCode.CommentSourceCode)
            {
                sourceCode.AppendFront("// if enough matches were found, we leave\n");
            }

            if (Type == CheckMaximumMatchesType.Action)
            {
                if (InParallelizedBody)
                {
                    sourceCode.AppendFront("if(maxMatches > 0 && parallelTaskMatches[threadId].Count >= maxMatches)\n");
                }
                else
                {
                    sourceCode.AppendFront("if(maxMatches > 0 && matches.Count >= maxMatches)\n");
                }
            }
            else if (Type == CheckMaximumMatchesType.Subpattern)
            {
                sourceCode.AppendFront("if(maxMatches > 0 && foundPartialMatches.Count >= maxMatches)\n");
            }
            else if (Type == CheckMaximumMatchesType.Iterated)
            {
                sourceCode.AppendFront("if(true) // as soon as there's a match, it's enough for iterated\n");
            }

            sourceCode.AppendFront("{\n");
            sourceCode.Indent();

            if (Type == CheckMaximumMatchesType.Action && InParallelizedBody)
            {
                sourceCode.AppendFront("maxMatchesFound = true;\n");
            }

            if (EmitProfiling)
            {
                if (InParallelizedBody)
                {
                    sourceCode.AppendFrontFormat("if(maxMatches==1) actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[threadId].searchStepsSingle.Add(actionEnv.PerformanceInfo.SearchStepsPerThread[threadId]);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("else actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[threadId].searchStepsMultiple.Add(actionEnv.PerformanceInfo.SearchStepsPerThread[threadId]);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("if(maxMatches==1) actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[threadId].loopStepsSingle.Add(actionEnv.PerformanceInfo.LoopStepsPerThread[threadId]);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("else actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[threadId].loopStepsMultiple.Add(actionEnv.PerformanceInfo.LoopStepsPerThread[threadId]);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("if(maxMatches==1) actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[threadId].searchStepsPerLoopStepSingle.Add(actionEnv.PerformanceInfo.SearchStepsPerThread[threadId] - searchStepsAtLoopStepBegin);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("else actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[threadId].searchStepsPerLoopStepMultiple.Add(actionEnv.PerformanceInfo.SearchStepsPerThread[threadId] - searchStepsAtLoopStepBegin);\n", PackagePrefixedActionName);
                }
                else
                {
                    sourceCode.AppendFrontFormat("++actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].callsTotal;\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].searchStepsTotal += actionEnv.PerformanceInfo.SearchSteps - searchStepsAtBegin;\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].loopStepsTotal += loopSteps;\n", PackagePrefixedActionName);

                    sourceCode.AppendFrontFormat("actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].searchStepsTotal += actionEnv.PerformanceInfo.SearchSteps - searchStepsAtBegin;\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].loopStepsTotal += loopSteps;\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("if(maxMatches==1) actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].searchStepsSingle.Add(actionEnv.PerformanceInfo.SearchSteps - searchStepsAtBegin);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("else actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].searchStepsMultiple.Add(actionEnv.PerformanceInfo.SearchSteps - searchStepsAtBegin);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("if(maxMatches==1) actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].loopStepsSingle.Add(loopSteps);\n", PackagePrefixedActionName);
                    sourceCode.AppendFrontFormat("else actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].loopStepsMultiple.Add(loopSteps);\n", PackagePrefixedActionName);

                    if (EmitFirstLoopProfiling)
                    {
                        sourceCode.AppendFrontFormat("if(maxMatches==1) actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].searchStepsPerLoopStepSingle.Add(actionEnv.PerformanceInfo.SearchSteps - searchStepsAtLoopStepBegin);\n", PackagePrefixedActionName);
                        sourceCode.AppendFrontFormat("else actionEnv.PerformanceInfo.ActionProfiles[\"{0}\"].averagesPerThread[0].searchStepsPerLoopStepMultiple.Add(actionEnv.PerformanceInfo.SearchSteps - searchStepsAtLoopStepBegin);\n", PackagePrefixedActionName);
                    }
                }
            }

            CheckFailedOperations.Emit(sourceCode);

            sourceCode.Unindent();
            sourceCode.AppendFront("}\n");
        }
示例#14
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (Type == PatternAndSubpatternsMatchedType.Iterated)
            {
                sourceCode.AppendFront("patternFound = true;\n");
            }

            if (Type != PatternAndSubpatternsMatchedType.Action)
            {
                if (sourceCode.CommentSourceCode)
                {
                    sourceCode.AppendFront("// subpatterns/alternatives were found, extend the partial matches by our local match object\n");
                }
                sourceCode.AppendFront("foreach(Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch in matchesList)\n");
                sourceCode.AppendFront("{\n");
                sourceCode.Indent();

                sourceCode.AppendFrontFormat("{0}.{1} match = new {0}.{1}();\n",
                                             RulePatternClassName, NamesOfEntities.MatchClassName(PatternName));
                if (Type == PatternAndSubpatternsMatchedType.IteratedNullMatch)
                {
                    sourceCode.AppendFront("match._isNullMatch = true; // null match of iterated pattern\n");
                }

                MatchBuildingOperations.Emit(sourceCode); // emit match building operations
                sourceCode.AppendFront("currentFoundPartialMatch.Push(match);\n");

                sourceCode.Unindent();
                sourceCode.AppendFront("}\n");
            }
            else // top-level pattern with subpatterns/alternatives
            {
                if (sourceCode.CommentSourceCode)
                {
                    sourceCode.AppendFront("// subpatterns/alternatives were found, extend the partial matches by our local match object, becoming a complete match object and save it\n");
                }
                sourceCode.AppendFront("foreach(Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch in matchesList)\n");
                sourceCode.AppendFront("{\n");
                sourceCode.Indent();

                if (InParallelizedBody)
                {
                    sourceCode.AppendFrontFormat("{0}.{1} match = parallelTaskMatches[threadId].GetNextUnfilledPosition();\n",
                                                 RulePatternClassName, NamesOfEntities.MatchClassName(PatternName));
                }
                else
                {
                    sourceCode.AppendFrontFormat("{0}.{1} match = matches.GetNextUnfilledPosition();\n",
                                                 RulePatternClassName, NamesOfEntities.MatchClassName(PatternName));
                }
                MatchBuildingOperations.Emit(sourceCode); // emit match building operations
                if (InParallelizedBody)
                {
                    sourceCode.AppendFront("match.IterationNumber = currentIterationNumber;\n");
                    sourceCode.AppendFront("parallelTaskMatches[threadId].PositionWasFilledFixIt();\n");
                }
                else
                {
                    sourceCode.AppendFront("matches.PositionWasFilledFixIt();\n");
                }

                sourceCode.Unindent();
                sourceCode.AppendFront("}\n");
                sourceCode.AppendFront("matchesList.Clear();\n");
            }
        }
        public override void Emit(SourceBuilder sourceCode)
        {
            string variableContainingBackupOfMappedMember = NamesOfEntities.VariableWithBackupOfIsMatchedGlobalBit(
                PatternElementName, NegativeIndependentNamePrefix);
            string variableContainingCandidate = NamesOfEntities.CandidateVariable(PatternElementName);

            if (Parallel)
            {
                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.AppendFront("if(isoSpace < (int) GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE) {\n");
                    sourceCode.Indent();
                }

                string isMatchedBit = "(uint)GRGEN_LGSP.LGSPElemFlagsParallel.IS_MATCHED_BY_ENCLOSING_PATTERN << isoSpace";
                sourceCode.AppendFrontFormat("flagsPerElementGlobal[{0}.uniqueId] &= (ushort)(~({1}) | {2});\n",
                                             variableContainingCandidate,
                                             isMatchedBit,
                                             variableContainingBackupOfMappedMember);

                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.Unindent();
                    sourceCode.AppendFront("} else { \n");
                    sourceCode.Indent();

                    sourceCode.AppendFrontFormat("if({0} == 0) {{\n", variableContainingBackupOfMappedMember);
                    sourceCode.Indent();
                    sourceCode.AppendFrontFormat(
                        "graph.perThreadInIsoSpaceMatchedElementsGlobal[threadId][isoSpace - (int)GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE]"
                        + ".Remove({0});\n", variableContainingCandidate);
                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");

                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");
                }
            }
            else
            {
                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.AppendFront("if(isoSpace < (int) GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE) {\n");
                    sourceCode.Indent();
                }

                string isMatchedBit = "(uint)GRGEN_LGSP.LGSPElemFlags.IS_MATCHED_BY_ENCLOSING_PATTERN << isoSpace";
                sourceCode.AppendFrontFormat("{0}.lgspFlags = {0}.lgspFlags & ~({1}) | {2};\n",
                                             variableContainingCandidate, isMatchedBit, variableContainingBackupOfMappedMember);

                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.Unindent();
                    sourceCode.AppendFront("} else { \n");
                    sourceCode.Indent();

                    sourceCode.AppendFrontFormat("if({0} == 0) {{\n", variableContainingBackupOfMappedMember);
                    sourceCode.Indent();
                    sourceCode.AppendFrontFormat(
                        "graph.inIsoSpaceMatchedElementsGlobal[isoSpace - (int) GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE]"
                        + ".Remove({0});\n", variableContainingCandidate);
                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");

                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");
                }
            }
        }
        public override void Emit(SourceBuilder sourceCode)
        {
            string variableContainingBackupOfMappedMember =
                NamesOfEntities.VariableWithBackupOfIsMatchedBit(PatternElementName, NegativeIndependentNamePrefix);
            string variableContainingCandidate =
                NamesOfEntities.CandidateVariable(PatternElementName);

            sourceCode.AppendFrontFormat("uint {0};\n", variableContainingBackupOfMappedMember);

            if (Parallel)
            {
                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.AppendFront("if(isoSpace < (int) GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE) {\n");
                    sourceCode.Indent();
                }

                string isMatchedBit = "(uint)GRGEN_LGSP.LGSPElemFlagsParallel.IS_MATCHED << isoSpace";
                if (LockForAllThreads)
                {
                    sourceCode.AppendFrontFormat("{0} = flagsPerElement0[{1}.uniqueId] & {2};\n",
                                                 variableContainingBackupOfMappedMember,
                                                 variableContainingCandidate,
                                                 isMatchedBit);
                    sourceCode.AppendFrontFormat("for(int i=0; i<numWorkerThreads; ++i) graph.flagsPerThreadPerElement[i][{0}.uniqueId] |= (ushort)({1});\n",
                                                 variableContainingCandidate,
                                                 isMatchedBit);
                }
                else
                {
                    sourceCode.AppendFrontFormat("{0} = flagsPerElement[{1}.uniqueId] & {2};\n",
                                                 variableContainingBackupOfMappedMember,
                                                 variableContainingCandidate,
                                                 isMatchedBit);
                    sourceCode.AppendFrontFormat("flagsPerElement[{0}.uniqueId] |= (ushort)({1});\n",
                                                 variableContainingCandidate,
                                                 isMatchedBit);
                }

                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.Unindent();
                    sourceCode.AppendFront("} else {\n");
                    sourceCode.Indent();

                    if (LockForAllThreads)
                    {
                        sourceCode.AppendFrontFormat("{0} = graph.perThreadInIsoSpaceMatchedElements[0][isoSpace - (int)"
                                                     + "GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE].ContainsKey({1}) ? 1U : 0U;\n",
                                                     variableContainingBackupOfMappedMember, variableContainingCandidate);
                        sourceCode.AppendFrontFormat("if({0} == 0) for(int i=0; i<numWorkerThreads; ++i) graph.perThreadInIsoSpaceMatchedElements[i][isoSpace - (int)"
                                                     + "GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE].Add({1},{1});\n",
                                                     variableContainingBackupOfMappedMember, variableContainingCandidate);
                    }
                    else
                    {
                        sourceCode.AppendFrontFormat("{0} = graph.perThreadInIsoSpaceMatchedElements[threadId][isoSpace - (int)"
                                                     + "GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE].ContainsKey({1}) ? 1U : 0U;\n",
                                                     variableContainingBackupOfMappedMember, variableContainingCandidate);
                        sourceCode.AppendFrontFormat("if({0} == 0) graph.perThreadInIsoSpaceMatchedElements[threadId][isoSpace - (int)"
                                                     + "GRGEN_LGSP.LGSPElemFlagsParallel.MAX_ISO_SPACE].Add({1},{1});\n",
                                                     variableContainingBackupOfMappedMember, variableContainingCandidate);
                    }

                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");
                }
            }
            else
            {
                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.AppendFront("if(isoSpace < (int) GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE) {\n");
                    sourceCode.Indent();
                }

                string isMatchedBit = "(uint)GRGEN_LGSP.LGSPElemFlags.IS_MATCHED << isoSpace";
                sourceCode.AppendFrontFormat("{0} = {1}.lgspFlags & {2};\n",
                                             variableContainingBackupOfMappedMember, variableContainingCandidate, isMatchedBit);
                sourceCode.AppendFrontFormat("{0}.lgspFlags |= {1};\n",
                                             variableContainingCandidate, isMatchedBit);

                if (!NeverAboveMaxIsoSpace)
                {
                    sourceCode.Unindent();
                    sourceCode.AppendFront("} else {\n");
                    sourceCode.Indent();

                    sourceCode.AppendFrontFormat("{0} = graph.inIsoSpaceMatchedElements[isoSpace - (int) "
                                                 + "GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE].ContainsKey({1}) ? 1U : 0U;\n",
                                                 variableContainingBackupOfMappedMember, variableContainingCandidate);
                    sourceCode.AppendFrontFormat("if({0} == 0) graph.inIsoSpaceMatchedElements[isoSpace - (int) "
                                                 + "GRGEN_LGSP.LGSPElemFlags.MAX_ISO_SPACE].Add({1},{1});\n",
                                                 variableContainingBackupOfMappedMember, variableContainingCandidate);

                    sourceCode.Unindent();
                    sourceCode.AppendFront("}\n");
                }
            }
        }