blob: cb593eb0ed9b6e511517936e8b8f23b07204419d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
[@@@ocaml.warning "+a-4-30-40-41-42"]
let raw_clambda_dump_if ppf
((ulambda, _, structured_constants) : Clambda.with_constants) =
if !Clflags.dump_rawclambda || !Clflags.dump_clambda then
begin
Format.fprintf ppf "@.clambda:@.";
Printclambda.clambda ppf ulambda;
List.iter (fun { Clambda. symbol; definition; _ } ->
Format.fprintf ppf "%s:@ %a@."
symbol
Printclambda.structured_constant definition)
structured_constants
end;
if !Clflags.dump_cmm then Format.fprintf ppf "@.cmm:@."
let lambda_to_clambda ~backend ~filename:_ ~prefixname:_ ~ppf_dump
(lambda : Lambda.program) =
let clambda =
Closure.intro ~backend ~size:lambda.main_module_block_size lambda.code
in
let provenance : Clambda.usymbol_provenance =
{ original_idents = [];
module_path =
Path.Pident (Ident.create_persistent (Compilenv.current_unit_name ()));
}
in
let preallocated_block =
Clambda.{
symbol = Compilenv.make_symbol None;
exported = true;
tag = 0;
fields = List.init lambda.main_module_block_size (fun _ -> None);
provenance = Some provenance;
}
in
let constants = Compilenv.structured_constants () in
Compilenv.clear_structured_constants ();
let clambda_and_constants =
clambda, [preallocated_block], constants
in
raw_clambda_dump_if ppf_dump clambda_and_constants;
clambda_and_constants
|