?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Object Code Management : Binary Correction Generator' ??
MODULE ocm$apply_module_predictors;

{ PURPOSE:
{   This module calls the necessary procedures to update offsets in modules using
{   offset change information that has been generated from comparing two versions
{   of the module.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc llt$message_module_dictionary
*copyc llt$module_dictionary
*copyc llt$object_library_header
*copyc oct$code_section_directory
*copyc oct$predictor_header
*copyc oct$single_module_predictor_hdr
?? POP ??
*copyc ocp$apply_message_predictor
*copyc ocp$build_code_sec_directory
*copyc ocp$process_b0_instructions
*copyc ocp$process_info_element
*copyc ocp$process_interp_element
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] ocp$apply_module_predictors', EJECT ??
*copyc och$apply_module_predictors

  PROCEDURE [XDCL] ocp$apply_module_predictors
    (    p_predictor: ^SEQ ( * );
         p_first_intermediate_ol: ^SEQ ( * );
     VAR status: ost$status);

    VAR
      code_section_directory: ^oct$code_section_directory,
      first_intermediate_ol: ^SEQ ( * ),
      i: 0 .. llc$max_dictionaries_on_library,
      mod_dictionary_ocv: ^oct$offset_change_list,
      module_code_section_directory: ^oct$module_code_sections,
      module_dictionary: ^llt$module_dictionary,
      module_predictor: ^SEQ ( * ),
      module_predictor_hdr: ^oct$single_module_predictor_hdr,
      object_library_dictionaries: ^llt$object_library_dictionaries,
      object_library_header: ^llt$object_library_header,
      predictor: ^SEQ ( * ),
      predictor_header: ^oct$predictor_header;

    first_intermediate_ol := p_first_intermediate_ol;
    predictor := p_predictor;

    ocp$build_code_sec_directory (first_intermediate_ol, code_section_directory,
          module_code_section_directory);
    RESET first_intermediate_ol;
    NEXT object_library_header IN first_intermediate_ol;
    NEXT object_library_dictionaries: [1 .. object_library_header^.number_of_dictionaries] IN
          first_intermediate_ol;
    module_dictionary := NIL;
    i := 1;
    WHILE (module_dictionary = NIL) AND (i <= UPPERBOUND (object_library_dictionaries^)) DO
      IF object_library_dictionaries^ [i].kind = llc$module_dictionary THEN
        module_dictionary := #PTR (object_library_dictionaries^ [i].module_dictionary,
              first_intermediate_ol^);
      ELSE
        i := i + 1;
      IFEND;
    WHILEND;

    RESET predictor;
    NEXT predictor_header IN predictor;
    IF predictor_header^.number_of_mod_ocv_elements > 0 THEN
      mod_dictionary_ocv := #PTR (predictor_header^.mod_dictionary_ocv, predictor^);
    ELSE
      mod_dictionary_ocv := NIL;
    IFEND;
    FOR i := 1 TO predictor_header^.number_module_predictors DO
      NEXT module_predictor_hdr IN predictor;
      RESET predictor TO module_predictor_hdr;
      NEXT module_predictor: [[REP module_predictor_hdr^.predictor_size OF cell]] IN predictor;
      CASE module_predictor_hdr^.kind OF
      = llc$message_module =
        ocp$apply_message_predictor (module_predictor, module_dictionary, first_intermediate_ol);
      = llc$load_module =
        ocp$process_b0_instructions (module_predictor, module_dictionary, first_intermediate_ol, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE
        ;
      CASEND;
    FOREND;
    ocp$process_interp_element (predictor, first_intermediate_ol);
    ocp$process_info_element (predictor, first_intermediate_ol, code_section_directory,
          module_code_section_directory, status);
  PROCEND ocp$apply_module_predictors;
?? OLDTITLE ??
MODEND ocm$apply_module_predictors;
