Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (47 sloc) 2.076 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 This module contains some passes for the javascript AST.
20 @author Maxime Audouin
21 *)
22
23 type jsp = JsAst.code -> JsAst.code
24
25 (**
26 Transform recursive code element on element code using [tailrec_machine].
27 Replace call to function by call using the [t] and [tco] function prototype
28
29 cf ["qmlJsfunClientLib.js"]
30 for the implementation of prototype [t] and [tso].
31
32 This transformation is made in 2 kind of location for function applications:
33
34 1) in terminal call position, instead of beeing recursive, and returning a call to itself,
35 it returns potentially a [TailCall] object, containing the rest of the execution to
36 process, using the prototype [tco] of the [Function] class.
37
38 2) in other call positions, instead of calling the function direclty (it would not type
39 because the function potentially has previously returned a [TailCall] object instead of
40 the restul) it used the prototype [t] of the [Function] class, which loops until the
41 final result is returned.
42 *)
43 val mktl : jsp
44
45 (**
46 This function makes an alpha renaming on each local value:
47 -function parameters
48 -local function variables
49 -local letin
50
51 using a short ident generator, using a reset for each toplevel declaration,
52 for keeping identifier short, even on a huge code.
53 *)
54 val local_alpha_stm : JsAst.statement -> JsAst.statement
55 val local_alpha : jsp
56
57 (**
58 Split too deep expressions.
59 *)
60 val split : jsp
Something went wrong with that request. Please try again.