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

Stop using ECond(x,1,0) as a way to cast to boolean #50

Open
Lupus opened this issue Sep 10, 2020 · 0 comments
Open

Stop using ECond(x,1,0) as a way to cast to boolean #50

Lupus opened this issue Sep 10, 2020 · 0 comments

Comments

@Lupus
Copy link
Contributor

Lupus commented Sep 10, 2020

generate.ml emits very weird-looking code for converting to boolean with the following helper:

let bool e = J.ECond (e, one, zero)

Examples of use:

  register_bin_prim "caml_eq_float" `Pure (fun cx cy _ ->
      bool (J.EBin (J.FloatEqEq, float_val cx, float_val cy)));
  register_bin_prim "caml_neq_float" `Pure (fun cx cy _ ->
      bool (J.EBin (J.FloatNotEq, float_val cx, float_val cy)));
  register_bin_prim "caml_ge_float" `Pure (fun cx cy _ ->
      bool (J.EBin (J.FloatLe, float_val cy, float_val cx)));
  register_bin_prim "caml_le_float" `Pure (fun cx cy _ ->
      bool (J.EBin (J.FloatLe, float_val cx, float_val cy)));
  register_bin_prim "caml_gt_float" `Pure (fun cx cy _ ->
      bool (J.EBin (J.FloatLt, float_val cy, float_val cx)));
  register_bin_prim "caml_lt_float" `Pure (fun cx cy _ ->
      bool (J.EBin (J.FloatLt, float_val cx, float_val cy)));

Probably this deserves special Rehp tree node to express "cast to bool". Dumping this idea into the issue so that it's not forgotten.

@Lupus Lupus changed the title Stop using ECond(x,0,1) as a way to cast to boolean Stop using ECond(x,1,0) as a way to cast to boolean Sep 10, 2020
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

No branches or pull requests

1 participant