The my.cpp file, shown in Figure 9, contains the implementation of the module. The module is implemented as a subclass of the Module class. The initialize method, which is called when the module is registered, creates an instance of the object factory for this module and adds it to the list in the Suif environment.
Next are two extern declarations for the basicnodes and suifnodes modules. These are generated from the Hoof files basic.hoof and suif.hoof and contain the base classes for the SUIF Intermediate Representation. The init_mynodes routine initializes these modules before creating and instance of MyModule and registering it. This occurs because of the import lines in the Hoof file.
Next in the my.cpp file you will see various bodies for methods from the Example class, shown in Figure 9. These are straightforward. The print routine produces a simple print of the class and is primarily for use in debugging. FormattedText is a class that pretty prints the output with suitable indentation of fields.
The final portion of the file is the factory methods for MyObjectFactory. It is not necessary to understand the details of how the factory is defined. Of interest are the two create routines for the Example class, which is shown in Figure 10. The first one is the method in the object factory while the second is the global function. Notice that the global function simply finds the object factory and then calls the method. This lookup is quite fast because it is being performed using LStrings so only a pointer comparison is needed.