next up previous
Next: A Small Example Up: Phases Previous: vcgCCG

User Defined Phases

You can define your own phases in C-Breeze, and give them names by which they may be invoked from the cbz command line. To do this, define a class to be a subclass of Phase. The run() method in this class should contain the code you want to run when the phase is invoked. Typically, you will have your phase run some Walkers or Changers on the C code and maybe print something.

To have your phase run by cbz, you must register it by declaring a global variable of type Phases (note the plural) constructed from the name of the phase as a character string and an instance of your subclass of Phase. For instance, if your phase class is called Foo and you want it to be invoked as cbz -foo, put the following statement in a global scope in one of your C++ files:

 Phases
foo_phase ("foo", new LivePhase());

The identifier foo_phase is just a dummy variable you never need to refer to; calling the constructor is what registers the phase. If you have more than one phase you want to define in a file, obviously give them different names.



 
next up previous
Next: A Small Example Up: Phases Previous: vcgCCG
Calvin Lin
2002-01-31