Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > Ada Code > Reverse engineering legacy Ada code > Mapping information for Reverse engineering Ada > Subprogram mapping for reverse engineering Ada (Ada code)
  
Subprogram mapping for reverse engineering Ada (Ada code)
For each subprogram, the Reverser creates an Operation in the Model:
If the subprogram is a function, the Operation has a Return Type defined.
If the subprogram is a procedure, the Operation does not have a Return Type defined.
If the subprogram is the main procedure, the Operation is stereotyped by the «Ada Main» stereotype.
The Operation is created in the Package or Class that is created for the owning Ada package.
If the subprogram has a declarative part (part that declares types and variables etc.), the Operation is stereotyped by the «Ada Declaration» stereotype. The declarative part text is reverse engineered to the tagged value of the Ada Declaration Text tag definition, which is applied to the Operation by the «Ada Declaration» stereotype.
The body of the subprogram is reverse engineered to the Body property of the Operation.
If the subprogram uses a separate for the body, the Operation is stereotyped by the «Ada Separate» stereotype, and the Ada Parent Subprogram tag definition references the Operation that is generated as the subprogram that owns the separate.
The return type of a function is reverse engineered as the Return Type property of the Operation. If the Reverser can match the name of the Type to a Type in the Model, the matching Type is referenced.
The Visibility property of the reverse engineered Operation is set according to how the Ada subprogram is declared:
If the subprogram is declared in the parent Ada package specification, the Visibility property is set to Public.
If the subprogram is declared in the private region of the parent Ada package specification, the Visibility property is set to protected.
If the subprogram is declared in the parent package body, the Visibility property is set to Private.
If the subprogram is an operator, the name of the reverse engineered Operation is that of the operator prefixed and suffixed with quotation marks. The quotation marks prevent the operator character being mangled on generation.
For each renames declaration that renames a subprogram:
The Reverser creates an Operation for the renames declaration. The name of the new Operation is as specified by the renames declaration, and the Operation is created in the Package or Class created for the parent Ada package.
The new Operation is stereotyped by the «Ada Renames» stereotype:
If the Reverser can find the target Operation in the Model, the Operation that is renamed by the renames declaration is referenced through the tagged value of the Ada Rename Target tag definition (applied by the «Ada Renames» stereotype).
If the Reverser cannot find the target Operation in the Model, the tagged value of the Ada Rename Target Text tag definition (applied by the «Ada Renames» stereotype) is set to the name of the subprogram that is renamed by the renames declaration.
Generic Subprograms
If the subprogram is generic, the reverse engineered Operation is stereotyped by the «Ada Generic» stereotype.
The generic parameters of the subprogram are reverse engineered to the tagged value of the Ada Generic Parameters tag definition, which is applied to the Operation by the «Ada Generic» stereotype.
Generic Instantiations
If the subprogram is a generic instantiation, the reverse engineered Operation is stereotyped by the «Ada Generic Instance» stereotype.
The parameters of the generic instantiation subprogram are reverse engineered to the tagged value of the Ada Generic Parameters tag definition, which is applied to the Operation by the «Ada Generic Instance» stereotype.
If the associated generic subprogram is being reverse engineered, the reverse engineered Operation references its parent generic Operation through the tagged value of the Ada Generic Parent tag definition, which is applied to the Operation by the «Ada Generic Instance» stereotype.
If the associated generic subprogram is not being reverse engineered, the name of the generic subprogram is reverse engineered to the tagged value of the Ada Generic Parent Text tag definition, which is applied to the Operation by the «Ada Generic Instance» stereotype.
Parameters
For each subprogram parameter, the Reverser creates an Operation Parameter in the Model.
The mode of a subprogram parameter is reverse engineered as the Mechanism property of the Parameter, that is, 'In', 'Out' or 'In and Out'. If the mode of the subprogram parameter is not specified, the Mechanism property is set to In.
If the subprogram parameter is an access parameter, the reverse engineered Parameter is stereotyped by the «Ada Access» stereotype. The tagged value of the Ada Access Modifier tag definition (applied by the «Ada Access» stereotype) is set to 'none' and is ignored on generation.
The subprogram parameter type is reverse engineered as the Type property of the Parameter. If the Reverser can match the name of the Type to a Type in the Model, the matching Type is referenced.
If the subprogram parameter has an attribute designator for the data type, the Parameter is stereotyped by the «Ada Attribute Designator» stereotype and the tagged value of the Ada 'Attribute tag definition (applied by the «Ada Attribute Designator») is set to the attribute designator.