Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tentative support for OCaml 5.3 #203

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Add tentative support for OCaml 5.3 #203

wants to merge 4 commits into from

Conversation

cristianoc
Copy link
Collaborator

The cmt format has changed, this tries to support value dependencies just based on the type of what's available in the new Cmt_format.cmt_infos.

#202

The cmt format has changed, this tries to support value dependencies just based on the type of what's available in the new `Cmt_format.cmt_infos`.

#202

let extractValueDependencies (cmt_infos : CL.Cmt_format.cmt_infos) =
#if OCAML_VERSION >= (5, 3, 0)
let deps = ref [] in
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tentatively tries to extract the old cmt_value_dependencies.

@cristianoc cristianoc requested a review from cknitt December 31, 2024 09:21
@cristianoc cristianoc removed the request for review from cknitt December 31, 2024 16:59
@cristianoc
Copy link
Collaborator Author

The dependencies seems to have changed, currently none are found, and this attempt does not seem to work either:

let extractValueDependencies (cmt_infos : Cmt_format.cmt_infos) =
#if OCAML_VERSION >= (5, 3, 0)
  let deps = ref [] in
  let ident_occurrences = cmt_infos.cmt_ident_occurrences in
  Printf.eprintf "ident_occurrences: %d\n" (List.length ident_occurrences);
  let process_id ({Location.txt; loc}, res) = match res with
     | Shape_reduce.Resolved uid | Resolved_alias (uid, _) | Approximated (Some uid) ->
      (match Types.Uid.Tbl.find_opt cmt_infos.cmt_uid_to_decl uid with  
      | Some (Value v) ->
        deps := (loc, v.val_loc) :: !deps
      | Some (Type td) ->
        deps := (loc, td.typ_loc) :: !deps
      | Some (Value_binding vb) ->
        deps := (loc, vb.vb_loc) :: !deps
      | Some (Module_binding mb) ->
        deps := (loc, mb.mb_loc) :: !deps
      | Some (Module_type mt) ->
        deps := (loc, mt.mtd_loc) :: !deps
      | Some (Constructor cd) ->
        deps := (loc, cd.cd_loc) :: !deps
      | Some (Class c) ->
        deps := (loc, c.ci_loc) :: !deps
      | Some (Class_type ct) ->
        deps := (loc, ct.ci_loc) :: !deps
      | Some (Extension_constructor ec) ->
        deps := (loc, ec.ext_loc) :: !deps
      | Some (Label ld) ->
        deps := (loc, ld.ld_loc) :: !deps
      | Some (Module m) ->
        deps := (loc, m.md_loc) :: !deps
      | Some (Module_substitution ms) ->
        deps := (loc, ms.ms_loc) :: !deps
      | _ -> ())
     | _ -> () in
  List.iter process_id ident_occurrences;
  List.rev !deps

Moving this to draft.

@cristianoc cristianoc marked this pull request as draft December 31, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant