public static void SolveDoubleJumps(SchemeFunction function) { bool changed = true; var commands = function.Commands; while (changed) { changed = false; for (int i = 0; i < commands.Count; ++i) { ISchemeCommand cmd = commands[i]; if (cmd is CommandJumpBase) { CommandJumpBase jumpCmd = (cmd as CommandJumpBase); int line = jumpCmd.Line; if (line < commands.Count && commands[line] is CommandJump) { CommandJump jumpCmd2 = commands[line] as CommandJump; if (jumpCmd.Line != jumpCmd2.Line) { jumpCmd.SetLine(jumpCmd2.Line); changed = true; } } } } } }
private static void DecreaseJumpLocations(List <ISchemeCommand> commands, int loc) { foreach (var cmd in commands) { if (cmd is CommandJumpBase) { CommandJumpBase cmdJumpBase = (CommandJumpBase)cmd; if (cmdJumpBase.Line > loc) { cmdJumpBase.SetLine(cmdJumpBase.Line - 1); } } } }