public SequenceSomeRuleCallRewritingGeneratorHelper(SequenceSomeRuleCallRewritingGenerator ruleCallGen, String totalMatchToApply, String curTotalMatch) { this.ruleCallRewritingGenerator = ruleCallGen; this.totalMatchToApply = totalMatchToApply; this.curTotalMatch = curTotalMatch; ruleCallGen.seqHelper.BuildReturnParameters(ruleCallGen.seqRule, ruleCallGen.seqRule.ReturnVars, out returnParameterDeclarations, out returnArguments, out returnAssignments, out returnParameterDeclarationsAllCall, out intermediateReturnAssignmentsAllCall, out returnAssignmentsAllCall); }
public void EmitRewriting(SourceBuilder source, SequenceGenerator seqGen, String totalMatchToApply, String curTotalMatch, String firstRewrite, bool fireDebugEvents) { if (seqSome.Random) { source.AppendFront("if(" + matchesName + ".Count != 0 && " + curTotalMatch + " <= " + totalMatchToApply + ") {\n"); } else { source.AppendFront("if(" + matchesName + ".Count != 0) {\n"); } source.Indent(); SequenceSomeRuleCallRewritingGenerator rewritingGen = new SequenceSomeRuleCallRewritingGenerator(this, totalMatchToApply, curTotalMatch); if (seqRule.SequenceType == SequenceType.RuleCall) { if (seqSome.Random) { source.AppendFront("if(" + curTotalMatch + " == " + totalMatchToApply + ") {\n"); source.Indent(); } rewritingGen.EmitRewritingRuleCall(source, firstRewrite, fireDebugEvents); if (seqSome.Random) { source.Unindent(); source.AppendFront("}\n"); source.AppendFront("++" + curTotalMatch + ";\n"); } } else if (seqRule.SequenceType == SequenceType.RuleCountAllCall || !((SequenceRuleAllCall)seqRule).ChooseRandom) // seq.SequenceType == SequenceType.RuleAll { if (seqSome.Random) { source.AppendFront("if(" + curTotalMatch + " == " + totalMatchToApply + ") {\n"); source.Indent(); } rewritingGen.EmitRewritingRuleCountAllCallOrRuleAllCallNonRandom(source, firstRewrite, fireDebugEvents); if (seqSome.Random) { source.Unindent(); source.AppendFront("}\n"); source.AppendFront("++" + curTotalMatch + ";\n"); } } else // seq.SequenceType == SequenceType.RuleAll && ((SequenceRuleAll)seqRule).ChooseRandom { if (seqSome.Random) { rewritingGen.EmitRewritingRuleAllCallRandomSequenceRandom(source, firstRewrite, fireDebugEvents); } else { rewritingGen.EmitRewritingRuleAllCallRandomSequenceNonRandom(source, firstRewrite, fireDebugEvents); } } source.Unindent(); source.AppendFront("}\n"); }