Man page for rescope.1
Table of Contents


rescope - change global symbol and type scopes


rescope infile outfile { infile outfile }*


The rescope program changes the scopes of global variable or procedure symbols or global types, either from the inter-file global symbol table to a file symbol table or from a file symbol table to the inter-file symbol table.

The reason there is a separate program for these two operations is that they make unusual requirements on the way procedures are read and written. Symbols and types in the inter-file and file symbol tables use disjoint ranges for their id numbers, which is how symbol and type references are read and written. All procedures that might reference a symbol or type must be read in from a file before that object may safely be moved to a different symbol table with a different range of id numbers. But no procedure that references the object may be written out until it gets its new id number. This is not a problem for objects moving to or from a local scope -- the symbol can only be referenced in a single procedure at the time of the move. But for moves between file and inter-file symbol tables, directly moving the object would in general require all procedures from a file to be read before any are written.

This program avoids having more than one procedure in memory by using two copies of the object to be moved. The original is left in the original table while the copy is put in the destination. Then as procedures are read in, the original is used and this program goes over the procedure and changes all references to the original to the copy, then writes the procedure out. It does this simultaneously for all symbols and types that are being moved.

Other passes communicate which objects to move and where to move them through ``globalize'' and ``filize'' annotations on global objects. The ``globalize'' annotation takes no arguments and should only appear on objects in a file symbol table that should be moved to the inter-file table. The ``filize'' annotation should have exactly one integer immed as data; this annotation should appear only on objects in the inter-file symbol table that should be moved to a file symbol table specified by the integer immed. The integer immed refers to the file id number; one of the file_set_entries for the input files given to this program must have a file_id() that matches the immed.


This program was written by Chris Wilson.

Table of Contents