public override void Emit(SourceBuilder sourceCode) { sourceCode.AppendFront("{ // " + Name + "\n"); sourceCode.Indent(); NestedOperationsList.Emit(sourceCode); sourceCode.Unindent(); sourceCode.AppendFront("}\n"); }
public override void Emit(SourceBuilder sourceCode) { sourceCode.AppendFrontFormat("if({0}.Count>0) {{\n", NestedMatchObjectName); sourceCode.Indent(); NestedOperationsList.Emit(sourceCode); sourceCode.Unindent(); sourceCode.AppendFront("}\n"); }
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"); }
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"); }
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"); }
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"); }
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"); }