Recursion

This section demonstrates how recursion is used to process a much simpler structure than that given in Figure 1. The example shown in Figure 1 is for the DFHTBSP program, which has the following parameters:
Input:
PATTERN, HIGHERNODE, and BUILDER
Inout:
AUDITTRAIL
Output:
NODE and RESPONSE.
The following list outlines the flow in DFHTBSBP. The step references refer to steps in this list.
  1. Add and initialize an action to the AUDITTRAIL (this is used later in steps 5 and 11).
  2. Using parameter PATTERN, find the address of the associated builder.
  3. Call the builder stub with function number 1 (for BUILD) with the following parameters:
    Input:
    HIGHERNODE and BUILDER
    Output:
    NODE.

    The builder uses the BUILDER parameters to create its specific object. Storage is obtained and the parameters are copied into it.

  4. Check that the response from the build is ‘OK’.
  5. Copy the address of the output parameter NODE into the AUDITTRAIL action.
  6. Process all the subpatterns that may be attached to your pattern
  7. Get the next subpattern Pn.
  8. Call DFHTBSBP with the following parameters:
    Input:
    Pn, NODE, and BUILDER
    Inout:
    AUDITTRAIL
    Output:
    SUBNODE and SUBRESPONSE
    Note: In this step, you call yourself again, passing NODE. At the next level of recursion, this appears as HIGHERNODE.
  9. Stop when the last pattern is processed.
  10. Call the builder stub with function number 5 (for CONNECT) with the following parameters:
    Input parameters:
    NODE
    Inout parameters:
    HIGHERNODE

    The builder’s CONNECT entry point now places the address as given by NODE into an offset of HIGHERNODE.

  11. Finally, place the address of the pattern into the AUDITTRAIL action.


dfhs30o.html | Timestamp icon Last updated: Monday, 5 June 2017