pax_global_header00006660000000000000000000000064144217506710014521gustar00rootroot0000000000000052 comment=b97d26b556c8b06bdb7c8c9ccaa136ad734d4ce3 ppx_cold-0.16.0/000077500000000000000000000000001442175067100134155ustar00rootroot00000000000000ppx_cold-0.16.0/.gitignore000066400000000000000000000000411442175067100154000ustar00rootroot00000000000000_build *.install *.merlin _opam ppx_cold-0.16.0/CONTRIBUTING.md000066400000000000000000000044101442175067100156450ustar00rootroot00000000000000This repository contains open source software that is developed and maintained by [Jane Street][js]. Contributions to this project are welcome and should be submitted via GitHub pull requests. Signing contributions --------------------- We require that you sign your contributions. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below (from [developercertificate.org][dco]): ``` Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` Then you just add a line to every git commit message: ``` Signed-off-by: Joe Smith ``` Use your real name (sorry, no pseudonyms or anonymous contributions.) If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with git commit -s. [dco]: http://developercertificate.org/ [js]: https://opensource.janestreet.com/ ppx_cold-0.16.0/LICENSE.md000066400000000000000000000021461442175067100150240ustar00rootroot00000000000000The MIT License Copyright (c) 2019--2023 Jane Street Group, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ppx_cold-0.16.0/Makefile000066400000000000000000000004031442175067100150520ustar00rootroot00000000000000INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),) default: dune build install: dune install $(INSTALL_ARGS) uninstall: dune uninstall $(INSTALL_ARGS) reinstall: uninstall install clean: dune clean .PHONY: default install uninstall reinstall clean ppx_cold-0.16.0/README.md000066400000000000000000000002221442175067100146700ustar00rootroot00000000000000Translates [@@cold] atributes to [@@inline never] [@@local never] [@@specialise never] Cf. discussion https://github.com/ocaml/ocaml/issues/8563 ppx_cold-0.16.0/dune-project000066400000000000000000000000201442175067100157270ustar00rootroot00000000000000(lang dune 1.10)ppx_cold-0.16.0/ppx_cold.opam000066400000000000000000000013521442175067100161040ustar00rootroot00000000000000opam-version: "2.0" version: "v0.16.0" maintainer: "Jane Street developers" authors: ["Jane Street Group, LLC"] homepage: "https://github.com/janestreet/ppx_cold" bug-reports: "https://github.com/janestreet/ppx_cold/issues" dev-repo: "git+https://github.com/janestreet/ppx_cold.git" doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/ppx_cold/index.html" license: "MIT" build: [ ["dune" "build" "-p" name "-j" jobs] ] depends: [ "ocaml" {>= "4.14.0"} "base" {>= "v0.16" & < "v0.17"} "dune" {>= "2.0.0"} "ppxlib" {>= "0.28.0"} ] available: arch != "arm32" & arch != "x86_32" synopsis: "Expands [@cold] into [@inline never][@specialise never][@local never]" description: " Part of the Jane Street's PPX rewriters collection. " ppx_cold-0.16.0/src/000077500000000000000000000000001442175067100142045ustar00rootroot00000000000000ppx_cold-0.16.0/src/dune000066400000000000000000000001731442175067100150630ustar00rootroot00000000000000(library (name ppx_cold) (public_name ppx_cold) (kind ppx_rewriter) (libraries base ppxlib) (preprocess no_preprocessing))ppx_cold-0.16.0/src/ppx_cold.ml000066400000000000000000000021651442175067100163520ustar00rootroot00000000000000open Base open Ppxlib let payload_never ~loc = let (module B) = Ast_builder.make loc in let open B in PStr [ pstr_eval (pexp_ident (Located.lident "never")) [] ] let expand_cold_attribute attr = assert (String.equal attr.attr_name.txt "cold"); let loc = { attr.attr_name.loc with loc_ghost = true } in let payload = payload_never ~loc in [ Loc.make ~loc "ocaml.inline", payload ; Loc.make ~loc "ocaml.local", payload ; Loc.make ~loc "ocaml.specialise", payload ] |> List.map ~f:(fun (name, payload) -> Ast_builder.Default.attribute ~loc ~name ~payload) class attributes_mapper = object inherit Ast_traverse.map as super method! attributes attrs = let attrs = List.concat_map attrs ~f:(function | { attr_name = { txt = "cold"; _ }; attr_payload = PStr []; attr_loc = _; } as attr -> Attribute.mark_as_handled_manually attr; expand_cold_attribute attr | attr -> [attr] ) in super#attributes attrs end let expand_cold = (new attributes_mapper)#structure let () = Driver.register_transformation "cold" ~impl:expand_cold ppx_cold-0.16.0/src/ppx_cold.mli000066400000000000000000000001311442175067100165120ustar00rootroot00000000000000open Ppxlib val expand_cold_attribute : Parsetree.attribute -> Parsetree.attribute list ppx_cold-0.16.0/tests/000077500000000000000000000000001442175067100145575ustar00rootroot00000000000000ppx_cold-0.16.0/tests/dune000066400000000000000000000004361442175067100154400ustar00rootroot00000000000000(library (name for_ppx_cold_test) (libraries) (preprocess (pps ppx_cold))) (rule (targets for_ppx_cold_test.pp-output) (mode fallback) (deps (:first_dep for_ppx_cold_test.ml.pp)) (action (bash "cp %{first_dep} %{targets}"))) (alias (name DEFAULT) (deps for_ppx_cold_test.pp-output))ppx_cold-0.16.0/tests/for_ppx_cold_test.ml000066400000000000000000000003711442175067100206270ustar00rootroot00000000000000(* Make sure [@cold] gets translated properly *) let[@cold] succ x = x + 1 (* Make sure [@@cold] gets translated properly *) let pred x = x - 1 [@@cold] (* Make sure other attributes are left untouched *) let[@cold] id x = x [@ocaml.warning "-8"] ppx_cold-0.16.0/tests/for_ppx_cold_test.pp-output000066400000000000000000000010321442175067100221670ustar00rootroot00000000000000let succ x = x + 1[@@ocaml.inline never][@@ocaml.local never][@@ocaml.specialise never] let pred x = x - 1[@@ocaml.inline never][@@ocaml.local never][@@ocaml.specialise never] let id x = ((x)[@ocaml.warning "-8"])[@@ocaml.inline never][@@ocaml.local never][@@ocaml.specialise never]