internal static List <Statement> ParseConditionStatements(List <Statement> condStatements, Label TargetLabel) { var newStatements = new List <Statement>(); GotoCondition cond = GotoCondition.None; Declaration lastMoveDecl = null; foreach (var statement in condStatements) { if (statement is Goto) { var gotoStatement = statement as Goto; } else if (statement is Move) { var move = statement as Move; lastMoveDecl = move.LValue; } else if (statement is Math.Not) { switch (cond) { case GotoCondition.NZ: cond = GotoCondition.Z; break; case GotoCondition.Z: cond = GotoCondition.NZ; break; case GotoCondition.C: cond = GotoCondition.NC; break; case GotoCondition.NC: cond = GotoCondition.C; break; } } else if (statement is Equals) { cond = GotoCondition.Z; } else if (statement is NotEquals) { cond = GotoCondition.NZ; } newStatements.Add(statement); } newStatements.Add(new Goto(TargetLabel, lastMoveDecl, cond)); return(newStatements); }
public Goto(Label lbl, Declaration condDecl, GotoCondition cond) { TargetLabel = lbl; CondDecl = condDecl; GotoCond = cond; }
public Goto(Label lbl) { TargetLabel = lbl; GotoCond = Goto.GotoCondition.None; }