Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 56 lines (47 sloc) 2.126 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
4 This file is part of Opa.
fccc685 Initial open-source release
MLstate authored
5
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
6 Opa is free software: you can redistribute it and/or modify it under the
fccc685 Initial open-source release
MLstate authored
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
10 Opa is distributed in the hope that it will be useful, but WITHOUT ANY
fccc685 Initial open-source release
MLstate authored
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
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
16 along with Opa. If not, see <http://www.gnu.org/licenses/>.
fccc685 Initial open-source release
MLstate authored
17 *)
18 module Format = Base.Format
19 module List = Base.List
20 module String = Base.String
21 module Q = QmlAst
22
23 (*-----------------------------------*)
24 (*---- removing distant bypasses ----*)
25 (*-----------------------------------*)
26
27 let locally_defined_bypass ~bymap ~lang bypass =
28 match BslLib.BSL.ByPassMap.find_opt bymap bypass with
29 | None -> true (* may happen with wrong bypasses, so just say true
30 * so that it is left untouched *)
31 | Some bypass ->
32 let langs = BslLib.BSL.ByPass.langs bypass in
33 List.mem lang langs
34
35 (* assuming bypass hoisting has been done
36 * so bypass are named and are only at the toplevel *)
37 let gather_info ~bymap ~lang ~annotmap (code : QmlAst.code) =
38 QmlAstWalk.CodeExpr.fold_map
3394108 [clean] most passes: removing @expanded_bypass
Valentin Gatien-Baron authored
39 (QmlAstWalk.Expr.traverse_foldmap
40 (fun tra annotmap e ->
41 match e with
42 | Q.Bypass (label,key) when not (locally_defined_bypass ~bymap ~lang key) ->
43 let error_string =
44 Printf.sprintf "Error: trying to use a discarded remote call to %s"
45 (BslKey.to_string key) in
46 let annotmap, error_string_expr = QmlAstCons.TypedExpr.string annotmap error_string in
47 annotmap, Q.Directive (label,`fail,[error_string_expr],[])
48 | _ ->
49 tra annotmap e
50 )
fccc685 Initial open-source release
MLstate authored
51 ) annotmap code
52
53 let discard_remote_bypasses ~bymap ~lang gamma annotmap code =
3394108 [clean] most passes: removing @expanded_bypass
Valentin Gatien-Baron authored
54 let annotmap, code = gather_info ~bymap ~lang ~annotmap code in
fccc685 Initial open-source release
MLstate authored
55 (gamma, annotmap), code
Something went wrong with that request. Please try again.