?? RIGHT := 110 ??
MODULE ocm$process_interp_element;
*copyc osd$default_pragmats
?? PUSH (LISTEXT := ON) ??
*copyc amt$segment_pointer
*copyc llt$identification
*copyc llt$object_text_descriptor
*copyc llt$object_library_header
*copyc llt$module_dictionary
*copyc llt$load_module_header
*copyc llt$section_definition
*copyc osp$set_status_abnormal
*copyc occ$generate_predictor
*copyc oct$predictor_header
*copyc oct$single_module_predictor_hdr
*copyc oct$offset_change_list
*copyc oct$section_directory
*copyc oct$module_predictor_size
*copyc oce$metapatch_generator_errors
*copyc ocp$adjust_allotted_sections
*copyc ocp$build_section_directory
*copyc ocp$process_epts
*copyc ocp$process_exts
*copyc ocp$process_sections
?? POP ??

*copyc och$process_interp_element

  PROCEDURE [XDCL] ocp$process_interp_element (p_predictor: ^SEQ ( * );
        p_int_ol: ^SEQ ( * ));

    VAR
      counter: llt$module_index,
      current_module_name: pmt$program_name,
      current_module_used: boolean,
      entry_points: ^llt$object_text_descriptor,
      external_element: ^llt$object_text_descriptor,
      found: boolean,
      i: llt$module_index,
      id_record: ^llt$identification,
      idr: ^llt$object_text_descriptor,
      int_ol: ^SEQ ( * ),
      load_module_found: boolean,
      mod_dictionary_ocv: ^oct$offset_change_list,
      module_dictionary: ^llt$module_dictionary,
      module_header: ^llt$load_module_header,
      module_predictor: ^oct$module_predictor,
      predictor: ^SEQ ( * ),
      section_directory: ^oct$section_directory,
      module_predictor_header: ^oct$single_module_predictor_hdr,
      module_predictor_size: ^oct$module_predictor_size,
      ol_dictionaries: ^llt$object_library_dictionaries,
      ol_header: ^llt$object_library_header,
      predictor_header: ^oct$predictor_header,
      save_ptr: ^cell,
      section_def: ^llt$section_definition,
      section_definitions: ^llt$object_text_descriptor,
      status: ost$status,
      total_module_predictor_size: oct$module_predictor_size,
      valid: boolean;

    int_ol := p_int_ol;
    predictor := p_predictor;

    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;
    current_module_name := osc$null_name;
    current_module_used := TRUE;
    counter := 0;
    RESET int_ol;
    NEXT ol_header IN int_ol;
    NEXT ol_dictionaries: [1 .. ol_header^.number_of_dictionaries] IN int_ol;
    found := FALSE;
    i := 1;
    WHILE NOT found AND (i <= UPPERBOUND (ol_dictionaries^)) DO
      IF ol_dictionaries^ [i].kind = llc$module_dictionary THEN
        found := TRUE;
      ELSE
        i := i + 1;
      IFEND;
    WHILEND;
    IF NOT found THEN
      RETURN;
    IFEND;
    module_dictionary := #PTR (ol_dictionaries^ [i].module_dictionary, int_ol^);
    FOR i := 1 TO UPPERBOUND (module_dictionary^) DO
      IF module_dictionary^ [i].kind = llc$load_module THEN
        IF current_module_used AND (counter < predictor_header^.number_module_predictors) THEN
          REPEAT
            NEXT module_predictor_header IN predictor;
            RESET predictor TO module_predictor_header;
            NEXT module_predictor: [[REP module_predictor_header^.predictor_size OF cell]] IN predictor;
            IF module_predictor_header^.kind = llc$load_module THEN
              load_module_found := TRUE;
            ELSE
              load_module_found := FALSE;
            IFEND;
            current_module_used := FALSE;
            current_module_name := module_predictor_header^.module_name;
            counter := counter + 1;
          UNTIL load_module_found OR (counter >= predictor_header^.number_module_predictors);
        IFEND;
        IF load_module_found THEN
          module_header := #PTR (module_dictionary^ [i].module_header, int_ol^);
          IF llc$section_element IN module_header^.interpretive_header.elements_defined THEN
            section_definitions := #PTR (module_header^.interpretive_header.section_definitions, int_ol^);
            IF (module_dictionary^ [i].name <> current_module_name) AND (mod_dictionary_ocv <> NIL) THEN
              ocp$adjust_allotted_sections (mod_dictionary_ocv, section_definitions, int_ol);
            IFEND;
          IFEND;
          IF module_dictionary^ [i].name = current_module_name THEN
            IF llc$interpretive_element IN module_header^.elements_defined THEN
              idr := #PTR (module_header^.interpretive_element, int_ol^);
              RESET int_ol TO idr;
              NEXT idr IN int_ol;
              NEXT id_record IN int_ol;
              ALLOCATE section_directory: [0 .. id_record^.greatest_section_ordinal];
              ocp$build_section_directory (module_predictor, module_header, int_ol, section_directory);
              IF (llc$section_element IN module_header^.interpretive_header.elements_defined) THEN
                ocp$process_sections (int_ol, section_definitions, section_directory, mod_dictionary_ocv);
              IFEND;
              IF (llc$external_element IN module_header^.interpretive_header.elements_defined) THEN
                external_element := #PTR (module_header^.interpretive_header.external_linkages, int_ol^);
                ocp$process_exts (int_ol, external_element, section_directory);
              IFEND;
              IF (llc$entry_point_element IN module_header^.interpretive_header.elements_defined) THEN
                entry_points := #PTR (module_header^.interpretive_header.entry_points, int_ol^);
                ocp$process_epts (int_ol, entry_points, section_directory);
              IFEND;
              FREE section_directory;
            IFEND;
            current_module_used := TRUE;
          IFEND;
        IFEND;
      IFEND;
    FOREND;
  PROCEND ocp$process_interp_element;
MODEND ocm$process_interp_element;
