Esempio n. 1
0
        public override void Emit(SourceBuilder sourceCode)
        {
            sourceCode.AppendFrontFormat("if({0}.Count>0) {{\n", NestedMatchObjectName);
            sourceCode.Indent();

            NestedOperationsList.Emit(sourceCode);

            sourceCode.Unindent();
            sourceCode.AppendFront("}\n");
        }
Esempio n. 2
0
        public override void Emit(SourceBuilder sourceCode)
        {
            sourceCode.AppendFront("{ // " + Name + "\n");

            sourceCode.Indent();
            NestedOperationsList.Emit(sourceCode);
            sourceCode.Unindent();

            sourceCode.AppendFront("}\n");
        }
Esempio n. 3
0
        public override void Emit(SourceBuilder sourceCode)
        {
            sourceCode.AppendFrontFormat("foreach({0} {1} in {2}) {{\n",
                                         IteratedMatchTypeName, HelperMatchName, NestedMatchObjectName);
            sourceCode.Indent();

            NestedOperationsList.Emit(sourceCode);

            sourceCode.Unindent();
            sourceCode.AppendFront("}\n");
        }
Esempio n. 4
0
        public override void Dump(SourceBuilder builder)
        {
            // first dump local content
            builder.AppendFrontFormat("YieldingBlock {0}\n", Name);

            // then nested content
            if (NestedOperationsList != null)
            {
                builder.Indent();
                NestedOperationsList.Dump(builder);
                builder.Unindent();
            }
        }
Esempio n. 5
0
        public override void Emit(SourceBuilder sourceCode)
        {
            sourceCode.AppendFrontFormat("{0}if({1}.{2} is {3}) {{\n",
                                         First ? "" : "else ", MatchObjectName, NestedMatchObjectName, AlternativeCaseMatchTypeName);
            sourceCode.Indent();
            sourceCode.AppendFrontFormat("{0} {1} = ({0}){2}.{3};\n",
                                         AlternativeCaseMatchTypeName, HelperMatchName, MatchObjectName, NestedMatchObjectName);

            NestedOperationsList.Emit(sourceCode);

            sourceCode.Unindent();
            sourceCode.AppendFront("}\n");
        }
Esempio n. 6
0
        public override void Dump(SourceBuilder builder)
        {
            // first dump local content
            builder.AppendFrontFormat("BubbleUpYieldIterated on {0}\n", NestedMatchObjectName);

            // then nested content
            if (NestedOperationsList != null)
            {
                builder.Indent();
                NestedOperationsList.Dump(builder);
                builder.Unindent();
            }
        }
Esempio n. 7
0
        public override void Dump(SourceBuilder builder)
        {
            // first dump local content
            builder.AppendFront("IteratedMatchingDummyLoopPreventingReturn \n");

            // then nested content
            if (NestedOperationsList != null)
            {
                builder.Indent();
                NestedOperationsList.Dump(builder);
                builder.Unindent();
            }
        }
Esempio n. 8
0
        public override void Dump(SourceBuilder builder)
        {
            // first dump local content
            builder.AppendFrontFormat("BubbleUpYieldAlternativeCase on {0}.{1} case match type {2} {3}\n",
                                      MatchObjectName, NestedMatchObjectName, AlternativeCaseMatchTypeName, First ? "first" : "");

            // then nested content
            if (NestedOperationsList != null)
            {
                builder.Indent();
                NestedOperationsList.Dump(builder);
                builder.Unindent();
            }
        }
        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");
        }
Esempio n. 10
0
 public override void Dump(SourceBuilder builder)
 {
     Debug.Assert(CheckFailedOperations == null, "check negative without direct check failed code");
     // first dump local content
     builder.AppendFront("CheckPartialMatch ByNegative with ");
     foreach (string neededElement in NeededElements)
     {
         builder.AppendFormat("{0} ", neededElement);
     }
     builder.Append("\n");
     // then nested content
     if (NestedOperationsList != null)
     {
         builder.Indent();
         NestedOperationsList.Dump(builder);
         builder.Unindent();
     }
 }
Esempio n. 11
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (sourceCode.CommentSourceCode)
            {
                sourceCode.AppendFront("// dummy loop for iterated matching return prevention\n");
            }

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

            // emit loop body
            NestedOperationsList.Emit(sourceCode);

            // close loop
            sourceCode.Unindent();
            sourceCode.AppendFront("} while(false);\n");
        }
Esempio n. 12
0
        public override void Emit(SourceBuilder sourceCode)
        {
            if (sourceCode.CommentSourceCode)
            {
                sourceCode.AppendFront("// NegativePattern \n");
            }
            // currently needed because of multiple negMapped backup variables with same name
            // todo: assign names to negatives, mangle that name in, then remove block again
            // todo: remove (neg)mapped backup variables altogether, then remove block again
            sourceCode.AppendFront("{\n");
            sourceCode.Indent();

            NestedOperationsList.Emit(sourceCode);

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

            //if(sourceCode.CommentSourceCode) reinsert when block is removed
            //    sourceCode.AppendFront("// NegativePattern end\n");
        }
 public override void Dump(SourceBuilder builder)
 {
     // first dump local content
     builder.AppendFront("GetType ByIteration ");
     if (Type == GetTypeByIterationType.ExplicitelyGiven)
     {
         builder.Append("ExplicitelyGiven ");
         builder.AppendFormat("on {0} in {1} node:{2}\n",
                              PatternElementName, TypeName, IsNode);
     }
     else // Type==GetTypeByIterationType.AllCompatible
     {
         builder.Append("AllCompatible ");
         builder.AppendFormat("on {0} in {1} node:{2}\n",
                              PatternElementName, RulePatternTypeName, IsNode);
     }
     // then nested content
     if (NestedOperationsList != null)
     {
         builder.Indent();
         NestedOperationsList.Dump(builder);
         builder.Unindent();
     }
 }