Wrap pointer to OCaml source text in UnsafeOcamlPtr
commit4dcbba18d3666a85bf2a35dfd124ed63489690c1
authorJake Bailey (Hacklang) <jakebailey@fb.com>
Wed, 23 Oct 2019 19:36:28 +0000 (23 12:36 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 23 Oct 2019 19:39:21 +0000 (23 12:39 -0700)
tree94ee1f9df8e51de210f7b05d3a161293553ce745
parent783493d2afe6d211e6691da4508745544d0e5fe7
Wrap pointer to OCaml source text in UnsafeOcamlPtr

Summary:
I think it would be helpful to represent pointers to live OCaml values using a dedicated type rather than usize. For instance, this allows us to communicate to ocamlrep_derive that fields of type UnsafeOcamlPtr should not be converted (rather than uselessly converting the usize to an OCaml int). It also helps call out that the pointer is only valid for some unchecked lifetime, and hopefully will encourage the reader to carefully think about what that lifetime is.

This diff introduces the type and begins using it in SourceText.

Reviewed By: 2BitSalute

Differential Revision: D18051130

fbshipit-source-id: 43fc63876b1d77343edb0925fa8d9b652396f416
hphp/hack/src/ocamlrep/lib.rs
hphp/hack/src/ocamlrep/ptr.rs [new file with mode: 0644]
hphp/hack/src/parser/ocaml_coroutine_state.rs
hphp/hack/src/parser/source_text.rs