Changes between Version 62 and Version 63 of Orio


Ignore:
Timestamp:
06/13/08 16:37:37 (15 years ago)
Author:
hartono
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Orio

    v62 v63  
    231231== Developer Guide == 
    232232 
    233 This section covers topics on how to extend Orio with new components such as program transformation modules. 
     233This section covers topics on how to extend Orio with new features and components such as program transformation modules. 
    234234 
    235235== Writing a New Code Transformation Module == 
    236236 
    237 With the module name provided in the leader annotation, Orio dynamically loads the corresponding code transformation module and uses it to transform and generate the code in the annotation body block. If the pertinent module cannot be found in the Orio module directory, an error message is produced, and the Orio optimization process is terminated. The ''name-based dynamic loading'' provides flexibility and easy extensibility without requiring detailed knowledge or modification of the existing Orio system. 
    238  
     237With the module name provided in the leader annotation, Orio dynamically loads the corresponding code transformation module and uses it to transform and generate the code in the annotation body block. If the pertinent module cannot be found in the Orio module directory, an error message is produced, and the Orio optimization process is terminated. Such ''name-based dynamic loading'' provides flexibility and easy extensibility without requiring detailed knowledge or modification of the existing Orio system. 
     238 
     239Since Orio implementation is all in Python, to construct a new program transformation module therefore requires a Python programming skill. Transformation module writers need to create a new Python module inside `src/module` directory, where the abstract base class of the code transformation modules is located. This abstract class serves as a partial implementation of the source-to-source transformation process that inherits a class constructor and an abstract transformation function, which both need to be implemented in the newly created module subclass. 
     240 
     241{{{ 
     242#  
     243# The abstract class of the Orio's code transformation module  
     244#  
     245  
     246class Module:  
     247    '''The abstract class of the Orio's code transformation module'''  
     248      
     249    def __init__(self, cmd_line_opts, perf_params, module_code, line_no, indent_size, annot_body_code):  
     250        '''  
     251        To instantiate a program transformation module used to transform the annotated code.  
     252  
     253        The class variables consist of the following:  
     254           cmd_line_opts      an object representing the command line options  
     255                              (see src/cmd_line_opts.py for more details)  
     256           perf_params        a table/mapping that maps each performance parameter to its value  
     257           module_code        the code of annotation module body  
     258           line_no            the starting line position of the module code in the source code  
     259           indent_size        an integer representing the number of space characters used in the  
     260                              indentation of the leader annotation  
     261           annot_body_code    the text located in the annotation body block  
     262           verbose            to show details of the results of the running transformation modules  
     263        '''  
     264  
     265        self.cmd_line_opts = cmd_line_opts  
     266        self.perf_params = perf_params  
     267        self.module_code = module_code  
     268        self.line_no = line_no  
     269        self.indent_size = indent_size  
     270        self.annot_body_code = annot_body_code  
     271  
     272        # a boolean value  
     273        self.verbose = self.cmd_line_opts.verbose  
     274  
     275    #--------------------------------------------------------------------  
     276          
     277    def transform(self):  
     278        '''  
     279        The main code transformation procedure.  
     280        The returned value is a string value that represents the transformed/optimized code.  
     281        '''  
     282          
     283        raise NotImplementedError('%s: unimplemented abstract function "transform"' %  
     284                                  (self.__class__.__name__))  
     285}}} 
    239286 
    240287''Currently under construction''