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

Attachment: restructure_switch.patch
Description: Binary data

Attachment: if_then_else_format.patch
Description: Binary data

Attachment: switch_label_names.patch
Description: Binary data

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to