Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 62 lines (48 sloc) 1.972 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 module J = JsAst
19
20 type env = {
21 options : Qml2jsOptions.t;
22 gamma : QmlTypes.gamma;
23 annotmap : QmlAst.annotmap;
24 val_ : string -> Ident.t;
25 private_bymap : Imp_Bsl.JsImpBSL.ByPassMap.t;
26 renaming_client : QmlRenamingMap.t;
27 renaming_server : QmlRenamingMap.t;
28 }
29
30 type private_env = {
31 local_vars : J.ident list;
32 renaming : J.ident IdentMap.t;
33 no_warn_x : unit;
34 }
35
36
37 let next_param name = J.ExprIdent (Ident.next name)
38
39 let next_exprident private_env ident =
40 let ident = J.ExprIdent ident in
41 let private_env = {private_env with local_vars = ident :: private_env.local_vars} in
42 private_env, ident
43
44 (* Generate a fresh identifier and add it to the list of local variables *)
45 let next private_env name =
46 next_exprident private_env (Ident.next name)
47
48 let declare_local_vars private_env =
49 let local_vars = private_env.local_vars in
50 let private_env = {private_env with local_vars = []} in
51 let declarations = List.map (fun v -> JsCons.Statement.var v) local_vars in
52 private_env, JsCons.Statement.block declarations
53
54 let maybe_declare_local_vars private_env =
55 if private_env.local_vars = [] then
56 private_env, None
57 else
58 let private_env, statement = declare_local_vars private_env in
59 private_env, Some statement
60
61 let reset_renaming private_env = {private_env with renaming = IdentMap.empty}
Something went wrong with that request. Please try again.