Changes between Version 64 and Version 65 of Orio
- Timestamp:
- 06/13/08 21:59:29 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Orio
v64 v65 237 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. Such ''name-based dynamic loading'' provides flexibility and easy extensibility without requiring detailed knowledge or modification of the existing Orio system. 238 238 239 Since 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 provides a partial implementation of the source-to-source transformation process, leaving it to subclasses to complete the implementation. The program below displays the abstract class code that inherits a class constructor and an abstract transformation function to its subclasses. 240 239 Since 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 available. This abstract class provides a partial implementation of the source-to-source transformation process, leaving it to subclasses to complete the implementation. The program below displays the abstract class code that inherits a class constructor and an abstract transformation function to its subclasses. Information about the class attributes is included in the code below as well. 241 240 242 241 {{{ … … 244 243 # File: src/module/module.py 245 244 # 246 # The abstract class of the Orio's code transformation module 247 # 248 245 249 246 class Module: 250 247 '''The abstract class of the Orio's code transformation module''' 251 248 252 249 def __init__(self, cmd_line_opts, perf_params, module_code, line_no, indent_size, annot_body_code): 253 250 ''' 254 T o instantiate a program transformation module used to transform the annotated code.255 256 The class variables consist of the following:251 The class constructor used to instantiate a program transformation module. 252 253 The following are the class attributes: 257 254 cmd_line_opts an object representing the command line options 258 (see src/ cmd_line_opts.py for more details)259 perf_params a table /mappingthat maps each performance parameter to its value255 (see src/main/cmd_line_opts.py for more details) 256 perf_params a table that maps each performance parameter to its value 260 257 module_code the code of annotation module body 261 258 line_no the starting line position of the module code in the source code … … 263 260 indentation of the leader annotation 264 261 annot_body_code the text located in the annotation body block 265 verbose to show details of the results of the running transformation modules 266 ''' 267 262 ''' 268 263 self.cmd_line_opts = cmd_line_opts 269 264 self.perf_params = perf_params … … 273 268 self.annot_body_code = annot_body_code 274 269 275 # a boolean value276 self.verbose = self.cmd_line_opts.verbose277 278 #--------------------------------------------------------------------279 280 270 def transform(self): 281 271 ''' 282 The main code transformation procedure. 283 The returned value is a string value that represents the transformed/optimized code. 284 ''' 285 272 The main code transformation procedure. The returned value is a string value that 273 represents the transformed/optimized code. 274 ''' 286 275 raise NotImplementedError('%s: unimplemented abstract function "transform"' % 287 276 (self.__class__.__name__))