public override void Emit(SourceBuilder sourceCode)
        {
            string variableContainingCandidate = NamesOfEntities.CandidateVariable(PatternElementName);
            string variableContainingBackupOfMappedMemberGlobalSome =
                NamesOfEntities.VariableWithBackupOfIsMatchedGlobalInSomePatternBit(PatternElementName, NegativeIndependentNamePrefix);
            string isMatchedInSomePatternBit = "(uint)GRGEN_LGSP.LGSPElemFlags.IS_MATCHED_BY_SOME_ENCLOSING_PATTERN";

            sourceCode.AppendFrontFormat("{0}.lgspFlags = {0}.lgspFlags & ~({1}) | {2};\n",
                                         variableContainingCandidate, isMatchedInSomePatternBit, variableContainingBackupOfMappedMemberGlobalSome);
        }
        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");
                }
            }
        }