Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 47 lines (38 sloc) 1.4 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 Q = QmlAst
19
20 let iter_deep f code =
21 QmlAstWalk.CodeExpr.iter
22 (fun expr ->
23 f expr;
24 QmlAstWalk.Expr.iter f expr)
25 code
26
27 let perform register code =
28 iter_deep
29 (fun expr ->
30 match expr with
31 | Q.Record (_, lst) -> List.iter (fun (name, _) -> register name) lst
32
33 | Q.Dot (_, _, name)
34 | Q.ExtendRecord (_, name, _, _) -> register name
35
36 | Q.Match (_, _, lst) ->
37 List.iter
38 (fun (pat, _) ->
39 QmlAstWalk.Pattern.iter_down
40 (function
41 | Q.PatRecord (_, fields, _) -> List.iter (fun (name, _) -> register name) fields
42 | _ -> ()
43 ) pat
44 ) lst
45 | _ -> ()
46 ) code
Something went wrong with that request. Please try again.