Skip to content

Commit

Permalink
Redefine 'Stdlib.raise' in the 'Landmark' to allow using landmark wit…
Browse files Browse the repository at this point in the history
…h -no-stdlib (as 'raise' is used to wrap exception in the generated code).
  • Loading branch information
mlasson committed Dec 7, 2018
1 parent 856b2e2 commit b5d809f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -4,6 +4,7 @@ version 1.3, 6 dec 2018
* migrate to opam 2.0
* adds two new primitives: push/pop_profiling_state
* prepare migration for Pervasives deprecation
* redefine 'Stdlib.raise' in the 'Landmark' to allow using landmark with -no-stdlib (as 'raise' is used to wrap exception in the generated code).

version 1.2, 20 may 2018
------------------------
Expand Down
13 changes: 1 addition & 12 deletions ppx/mapper.ml
Expand Up @@ -93,18 +93,7 @@ let new_landmark landmark_name loc =

let qualified ctx name = String.concat "." (List.rev (name :: ctx))

let raise_ident =
let stdlib_raise = "Stdlib.raise" in
try
let major, minor =
Scanf.sscanf Sys.ocaml_version "%d.%d" (fun major minor -> major, minor)
in
if major = 4 && minor < 7 then
"Pervasives.raise"
else
stdlib_raise
with Scanf.Scan_failure _ -> stdlib_raise

let raise_ident = "Landmark.raise"

let wrap_landmark ctx landmark_name loc expr =
let landmark_name = qualified ctx landmark_name in
Expand Down
1 change: 1 addition & 0 deletions src/landmark.ml
Expand Up @@ -815,3 +815,4 @@ let () = match Sys.getenv "OCAML_LANDMARKS" with
try start_profiling ~profiling_options:(parse_env_options str) ()
with Exit -> ()

external raise : exn -> 'a = "%raise"
5 changes: 4 additions & 1 deletion src/landmark.mli
Expand Up @@ -146,4 +146,7 @@ val push_profiling_state: unit -> unit
(** Save the state of the profiler on a stack to be retrieved later by [pop_profiling_state ()]. *)

val pop_profiling_state: unit -> unit
(** See [push_profiling_state ()]. *)
(** See [push_profiling_state ()]. *)

external raise : exn -> 'a = "%raise"
(** This a redefinition of [Stdlib.raise] to allow generated code to work with -no-stdlib.*)

0 comments on commit b5d809f

Please sign in to comment.