/
jsPasses.mli
60 lines (47 loc) · 2.03 KB
/
jsPasses.mli
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
59
60
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
This module contains some passes for the javascript AST.
@author Maxime Audouin
*)
type jsp = JsAst.code -> JsAst.code
(**
Transform recursive code element on element code using [tailrec_machine].
Replace call to function by call using the [t] and [tco] function prototype
cf ["qmlJsfunClientLib.js"]
for the implementation of prototype [t] and [tso].
This transformation is made in 2 kind of location for function applications:
1) in terminal call position, instead of beeing recursive, and returning a call to itself,
it returns potentially a [TailCall] object, containing the rest of the execution to
process, using the prototype [tco] of the [Function] class.
2) in other call positions, instead of calling the function direclty (it would not type
because the function potentially has previously returned a [TailCall] object instead of
the restul) it used the prototype [t] of the [Function] class, which loops until the
final result is returned.
*)
val mktl : jsp
(**
This function makes an alpha renaming on each local value:
-function parameters
-local function variables
-local letin
using a short ident generator, using a reset for each toplevel declaration,
for keeping identifier short, even on a huge code.
*)
val local_alpha_stm : JsAst.statement -> JsAst.statement
val local_alpha : jsp
(**
Split too deep expressions.
*)
val split : jsp