-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minor] switch.ml: distinguish types for arguments, tests and actions
Before this change, Switch will use 'make_if' either with tests explicitly constructed from the provided primitives, or with a matching scrutinee/argument directly to check that it is non-zero. (Arguments are expected to be implicitly coercible to booleans for the 'make_if' functions.) This assumption may not always hold, for example if we tried to define a switch construct on tagged integers in asmcomp/cmm_helpers.ml. (I have a followup commit doing just that.) The comparison primitives of Cmm return untagged booleans, the conditional test is untagged, but a tagged integer cannot be tested for non-zeroness by just using untagged 'if' directly. The present commit clarifies the matter by separating the type of actions, tests and arguments at the Switch level. It does not change behavior in any way, but it makes it much easier to follow these distinctions. (In particular, it the new typing discipline demonstrates that the dangerous use of 'make_if' only happens exactly once in the Switch functor.)
- Loading branch information
Showing
5 changed files
with
51 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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