(***************************************************************************** Object Extraction Specification Written by; Dan Stearns, Summer 1994 Reference: Class and object extraction from imperative code JOOP, March-April 1993 Modification Record: 7/18/94 First Crack Overview: *****************************************************************************) (**** OBJECTS ****) object CProgram components: (HeaderFile and Module)* and Makefile; operations: CompileProgram (CProgram) -> (boolean), ProcessProgram; description: (* A compilable C program is the input to the object extractor *); end CProgram; object Makefile; operation CompileProgram inputs: cp: CProgram; outputs: boolean; postcondition: (* Either the program compiles or it doesn't *) true or false; end CompileProgram; operation ProcessProgram components: DoDataFlowAnalysis, FindClass, FindInstanceVariable*; inputs: cp: CProgram; outputs: cp': CProgram; precondition: (* The program must compile or we don't process it *) CompileProgram() = true; postcondition: cp = cp'; description: (* The object extractor processes the C program and creates a set of C++ classes that can be used to port the program to C++ *); end ProcessProgram; object Module components: SubProgram* and AggregatedDataStructure*; operations: (* Analysis of multiple subprograms in a module can lead to discovery of many classes, some of which may be contained in others. If all the instance variables of a class A also appear in another class B, B should contain an object of class A as one of its instance variables. *) ExtractClass, ExtractInstanceVariable; description: (* A module is a separate file that can conain data structures and subprograms. The object extractor expects modules to contain related subprograms. *); end Module; object HeaderFile components: (AggregatedDataStructure and SubProgramDeclaration)*; operations: ; description: ; end HeaderFile; object AggregatedDataStructure components: ; operations: ; description: (* A group of related variables stored together. In the C language, a struct is used. *); end AggregatedDataStructure; object SubProgram components: SubProgramParameter* and SubProgramBody; operations: ExtractInstanceVariables, ExtractRead_StateMethod, ExtractConstructor, ExtractModify_StateMethod; description: (* The parameters in the largest category are the instance variables of some class. Each operation is used according to the type of SubProgramParameter as follows: use-only ExtractRead_StateMethod define-only ExtractConstructor otherwise ExtractModify_StateMethod *); end SubProgram; object SubProgramBody = string; object SubProgramParameter components: Use_onlyParameter or Use_and_setParameter or Define_onlyParameter; operations: ; description: ; end SubProgramParameter; operation ExtractInstanceVariables inputs: ; outputs: ; end ExtractInstanceVariables; object Class components: InstanceVariable* and InstanceMethod*; operations: ; description: (* A Class is a C++ Class created by the application *); end Class;