Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 79 lines (67 sloc) 2.024 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 This module implements a pass to lighten deep record expressions
21
22 @author Esther Baruk
23 *)
24
25 (**
26 What this pass does :
27 it goes deep into a record expression and when the maximum depth is reached,
28 expressions contained in the record are lifted into let-bindings which are
29 inserted just before the record expression.
30
31 Example :
32 {[
33 r =
34 { hd =
35 { hd =
36 { hd =
37 { hd = { hd = "foo" ; tl = { nil = { } } };
38 tl = { hd = "bar" ; tl = { nil = { } } }
39 };
40 tl = { nil = { } }
41 };
42 tl = { nil = { } }
43 };
44 tl = { nil = { } }
45 }
46 ]}
47
48 is rewritten in
49
50 {[
51 r =
52 v0_r = { }
53 v1_r = { nil = v0_r }
54 v2_r = "foo"
55 v3_r = { hd = v2_r ; tl = v1_r }
56 v4_r = { }
57 v5_r = { nil = v4_r }
58 v6_r = "bar"
59 v7_r = { hd = v6_r ; tl = v5_r }
60 v8_r = { hd = v3_r ; tl = v7_r }
61 v9_r = { }
62 v10_r = { nil = v9_r }
63 { hd =
64 { hd = { hd = v8_r ; tl = v10_r };
65 tl = { nil = { } }
66 };
67 tl = { nil = { } }
68 }
69 ]}
70 *)
71
72 (** The function that does the modification on the code *)
73 val process_code :
74 typed:bool ->
75 QmlTypes.gamma ->
76 QmlAst.annotmap ->
77 QmlAst.code ->
78 (QmlTypes.gamma * QmlAst.annotmap) * QmlAst.code
Something went wrong with that request. Please try again.