From: Elnatan R. <el...@cs...> - 2011-01-17 16:28:46
|
On Jan 14, 2011, at 11:09 AM, Elnatan Reisner wrote: > On Jan 14, 2011, at 10:18 AM, Gabriel Kerneis wrote: > >> On Fri, Jan 07, 2011 at 12:16:17AM -0500, Elnatan Reisner wrote: >>> Finally, since I was playing around with switch statements anyway, I >>> did one further thing. You may have seen my previous posts about >>> wanting to retain '&&'s and '||'s wherever possible. Well, that is >>> possible for switch statements if there are multiple 'case' labels >>> on a single block. > > I just noticed a problem with this patch: '&&'s and '||'s are > inserted even if useLogicalOperators is false, and they don't later > get converted away. This is probably easy to fix, but it's not > immediately obvious to me how. > >> Maybe you could ... >> just rewrite handle_labels in a non-recursive fashion (probably the >> best). > > I think you're right that there is probably a cleaner nonrecursive > solution. Given that my previous patch was problematic, I decided to try my hand at implementing a nonrecursive solution. Unfortunately, I'm not sure that what I ended up with is cleaner than what was there before. Take a look and consider for yourself. Before I made this change, I was getting fed up with how much indentation was happening, so I also made a patch to not indent else- ifs. Let me know what you think of this. And, finally, I noticed that the labels generated when transforming switch statements could be given simpler names, so here's a patch for that, too. Elnatan |