On Fri, May 06, 2011 at 12:00:17PM -0700, Christian Collberg wrote:
> I actually need to be able to manipulate labels-as-values directly, compiling
> them away into a switch is not an option. Is there some way to hack CIL
> to do this?

What you would need to do:
- design an extension of the CIL AST to encode labels-as-values : this is the
  creative part, where you have to think hard in order to get something easy to
  use yet expressive enough. This involves modifying cil.mli and cil.ml.
- change frontc/cabs2cil.ml in order to use those new constructs : this is the
  hard part, you have to find out where CIL currently transforms the
  labels-as-values into switch statements, and change the code accordingly.
- fix every pattern-matching in CIL's source code to handle your new constructs 
:
  this is the tedious part.  If you manage to only need to add new constructors
  to sum types (like statement kind) this is straightfoward, just look at "not
  exhaustive pattern matching" warnings and fix them ; you shouldn't need to 
change
  anything else. If you happen to need new fields to product types (like stmt), 
it
  might a bit more involved, but compiler warnings and errors should still 
provide
  a lot of help.  This involves fixing a dozen of files (roughly).

I did something similar when I extended CIL to handle my own superset of C.  
This is
definitely possible, and not as hard as it might seem.  Do not hesistate to ask 
if
you need more help (and share the patch if you get some result :-).

Best,
-- 
Gabriel

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to