public override void GenerateAbstractCode(List <C.CsStmt> code) { HandleAction tmp; if (!String.IsNullOrEmpty(Flag)) { tmp = new LiftFlag() { Flag = Flag }; tmp.GenerateAbstractCode(code); } var lambda = new C.ScheduleStmt(Name, "_" + Target); lambda.AddCode($"var {Target} = {$"_{Target}".CastAs(Name)};"); if (!String.IsNullOrEmpty(Flag)) { tmp = new DropFlag() { Flag = Flag }; tmp.GenerateAbstractCode(lambda.Code); } if (!String.IsNullOrEmpty(ExtraFlag)) { lambda.AddCode(new C.IfThenElse($"!{ExtraFlag}", "return Message.Misfire")); } if (BaseAction != null) { BaseAction.GenerateAbstractCode(lambda.Code); } lambda.AddCode("return Message.Perfect"); code.Add(lambda); }
public override void GenerateAbstractCode(List <C.CsStmt> code) { HandleAction tmp; if (!String.IsNullOrEmpty(Flag)) { tmp = new LiftFlag { Flag = Flag }; tmp.GenerateAbstractCode(code); } code.Add(new C.SimpleStmt($"List<{Name}> {Target} = new List<{Name}>()")); var lambda = new C.ScheduleStmt(Name, "_" + Target); var ite = new C.IfThenElse(); var cond = $"_{Target} == null"; ite.AddBranch(cond); BaseAction?.GenerateAbstractCode(ite.GetThenBranch(cond)); if (!String.IsNullOrEmpty(Flag)) { tmp = new DropFlag { Flag = Flag }; tmp.GenerateAbstractCode(lambda.Code); } ite.AddToBranch(cond, "return Message.Perfect"); lambda.AddCode(ite); lambda.AddCode($"var {Target}1 = _{Target} as {Name};"); lambda.AddCode($"{Target}.Add({Target}1)"); lambda.AddCode("return Message.Consume"); code.Add(lambda); }