-
Notifications
You must be signed in to change notification settings - Fork 102
Alias more when strengthening #653
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
Merged
jonludlam
merged 8 commits into
ocaml:master
from
jonludlam:alias-all-when-strengthening
Apr 22, 2021
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abcfe13
Strengthen _all_ modules
jonludlam 064fb0a
Strengthen everything inside includes
jonludlam ddcf45d
When simplifying canonical aliases, don't strip aliases
jonludlam 5bb2c84
Better canonical path simplification
jonludlam f19caea
Update tests
jonludlam 9c6d154
Add thtml backend
jonludlam 32ba659
A little more delayed evaluation
jonludlam 5c74107
Formatting
jonludlam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,21 +20,30 @@ open Delayed | |
| let rec signature : | ||
| Cpath.module_ -> ?canonical:Cpath.module_ -> Signature.t -> Signature.t = | ||
| fun prefix ?canonical sg -> | ||
| let sg', strengthened_modules = sig_items prefix ?canonical sg in | ||
| (* Format.eprintf "Invalidating modules: %a\n%!" (Format.pp_print_list Ident.fmt) strengthened_modules; *) | ||
| let substs = | ||
| List.fold_left | ||
| (fun s mid -> Subst.path_invalidate_module (mid :> Ident.path_module) s) | ||
| Subst.identity strengthened_modules | ||
| in | ||
| Subst.signature substs sg' | ||
|
|
||
| and sig_items prefix ?canonical sg = | ||
| let open Signature in | ||
| let items, strengthened_modules = | ||
| let items, ids = | ||
| List.fold_left | ||
| (fun (items, s) item -> | ||
| match item with | ||
| | Module (id, r, m) -> ( | ||
| | Module (id, r, m) -> | ||
| let name = Ident.Name.module_ id in | ||
| let canonical = | ||
| match canonical with | ||
| | Some p -> Some (`Dot (p, name)) | ||
| | None -> None | ||
| in | ||
| match module_ ?canonical (`Dot (prefix, name)) (get m) with | ||
| | None -> (item :: items, s) | ||
| | Some m' -> (Module (id, r, put (fun () -> m')) :: items, id :: s)) | ||
| let m' = module_ ?canonical (`Dot (prefix, name)) (get m) in | ||
| (Module (id, r, put (fun () -> m')) :: items, id :: s) | ||
|
||
| | ModuleType (id, mt) -> | ||
| ( ModuleType | ||
| ( id, | ||
|
|
@@ -52,29 +61,22 @@ let rec signature : | |
| type_decl (`Dot (prefix, Ident.Name.type_ id)) (get t)) ) | ||
| :: items, | ||
| s ) | ||
| | Include i -> | ||
| let i', strengthened = include_ prefix i in | ||
| (Include i' :: items, strengthened @ s) | ||
| | Exception _ | TypExt _ | Value _ | External _ | Class _ | ClassType _ | ||
| | Include _ | ModuleSubstitution _ | TypeSubstitution _ | Comment _ | ||
| | Open _ -> | ||
| | ModuleSubstitution _ | TypeSubstitution _ | Comment _ | Open _ -> | ||
| (item :: items, s)) | ||
| ([], []) sg.items | ||
| in | ||
| (* Format.eprintf "Invalidating modules: %a\n%!" (Format.pp_print_list Ident.fmt) strengthened_modules; *) | ||
| let substs = | ||
| List.fold_left | ||
| (fun s mid -> Subst.path_invalidate_module (mid :> Ident.path_module) s) | ||
| Subst.identity strengthened_modules | ||
| in | ||
| Subst.signature substs { sg with items = List.rev items } | ||
| ({ sg with items = List.rev items }, ids) | ||
|
|
||
| and module_ : | ||
| ?canonical:Cpath.module_ -> | ||
| Cpath.module_ -> | ||
| Component.Module.t -> | ||
| Component.Module.t option = | ||
| fun ?canonical prefix m -> | ||
| match m.type_ with | ||
| | Alias _ -> None | ||
| | ModuleType _ -> Some { m with canonical; type_ = Alias (prefix, None) } | ||
| Component.Module.t = | ||
| fun ?canonical prefix m -> { m with canonical; type_ = Alias (prefix, None) } | ||
|
|
||
| (* nuke the expansion as this could otherwise lead to inconsistencies - e.g. 'AlreadyASig' *) | ||
| and module_type : | ||
|
|
@@ -113,3 +115,8 @@ and type_decl : Cpath.type_ -> TypeDecl.t -> TypeDecl.t = | |
| } | ||
| in | ||
| { t with equation } | ||
|
|
||
| and include_ : Cpath.module_ -> Include.t -> Include.t * Ident.module_ list = | ||
| fun path i -> | ||
| let expansion_, strengthened = sig_items path i.expansion_ in | ||
| ({ i with expansion_; strengthened = Some path }, strengthened) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can apply this only if
strengthened_modulesis not empty.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't measure a performance improvement (it is smaller than the noise).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly hesitant to do this because it would mean the identifiers don't get fresh names even though they're changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't thought the identity subst would still have an effect. It makes sense here.