Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 185 lines (144 sloc) 5.848 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 (**
20 The Core of the Bypass Standard Library.
21
22 See the manual for more documentation.
23
24 @author Mathieu Barbin
25 @author Mehdi Bouaziz
26 *)
27
28 (**
29 TODO: defunc.
30 Although it brings type safety about its manipulation,
31 it is too complex.
32
33 The table should be shared between different instance of back-end,
34 since we have a lot of backends with which we may choose to togle
35 dynamically.
36 *)
37
38 (* Implementation Note :
39 the modules in the implementation can share the abstract types because
40 there is no coercion of module there,
41 until the final compilation of the module BslLib *)
42
43 open BslInterface
44
45 (** {6 Parser} *)
46
47 (** This module offers a High-level API for calling the [BslRegisterParser] module (trx) *)
48 module HLParser :
49 sig
50
51 (**
52 The list of all include formats used by default by the parser of {b bslregister}
53 for processing {b opa} files.
54 *)
55 val default_opa_iformats : (string * string) list
56
57 (**
58 Add some more format to the table.
59 *)
60 val add_iformat : ('a * string) list -> unit (** suggar : call format *)
61
62 (**
63 Print all currently loaded iformats.
64 *)
65 val show_iformats : Format.formatter -> unit -> unit
66
67 (** {6 Exported rules} *)
68
69 (**
70 Parse a directive available in an Opa file.
71 *)
72 val opalang_directive : string -> (BslTags.parsed_t, BslDirectives.opalang_directive) BslDirectives.decorated_source_elt
73
74 (**
75 Parse a directive available in a bypass file. (Ocaml, Javascript)
76 *)
77 val bypasslang_directive : string -> (BslTags.parsed_t, BslDirectives.bypasslang_directive) BslDirectives.decorated_source_elt
78
79 end
80
81 module Arg :
82 sig
83
84 (**
85 Defines some common options.
86 + [--show-iformats] for printing the default iformats available in opa.
87 {[
88 ##include <format> path
89 ]}
90 *)
91 val options : (Base.Arg.key * Base.Arg.spec * Base.Arg.doc) list
92 end
93
94 (** {6 Generation} *)
95
96 (**
97 Get the map of types, usefull to generate projection code.
98 If runtime is set to true, the module will appear in the Runtime.Module.Path
99 *)
100 val record_path_map_of_typesmap : ?complete:bool -> ?runtime:bool -> typesmap -> string StringMap.t
101
102 (** ----- *)
103 (** Extra tools on type generation with ocaml *)
104 val map_type_from_type_map_and_path : typesmap -> string list -> ?definition:bool -> BslTypes.t -> BslTypes.t
105
106 (** A sugar to get the string boxed in a meta_code *)
107 val meta_code : meta_code -> string
108
109 (** {6 Bypass scopes} *)
110
111 (**
112 This function is used for warning the user when some import-plugin are missing
113 in the code, and detected thanks to the autobuild mode
114 *)
115 val declare_visibility : ObjectFiles.package_name -> BslPluginInterface.plugin_basename -> unit
116
117 (** {6 Constructors of custom BSL} *)
118
119 (** Creating a new BSL from all I,CTrans. This is the constructor for advanced utilisation *)
120 module MakeLibBSL :
121 functor (ML_ITrans : ML_ITRANS) ->
122 functor (ML_CTrans : ML_CTRANS) ->
123 functor (JS_CTrans : JS_CTRANS) ->
124 BSLINTROSPECTION with type ml_ctrans_env = ML_CTrans.env
125 and type js_ctrans_env = JS_CTrans.env
126
127 (** Dummy modules - for simple users, like bslbrowser - or some verificator *)
128 module Dummy_ML_ITrans : ML_ITRANS
129 module Dummy_ML_CTrans : ML_CTRANS
130 module Dummy_JS_CTrans : JS_CTRANS
131
132 (** If you write a qml compiler, you don't need the tools on transtyping on dynamic loading
133 but you do not take care on JS trans.
134 This is built with MakeLibBSL with all Dummy_* but ML_CTRANS *)
135 module LibBSLForQml2Ocaml :
136 functor (ML_CTrans : ML_CTRANS) ->
137 BSLINTROSPECTION with type ml_ctrans_env = ML_CTrans.env
138
139 (** If you write a js compiler, you don't need the tools on transtyping on dynamic loading
140 but you do not take care on ML trans.
141 This is built with MakeLibBSL with all Dummy_* but JS_CTRANS *)
142 module LibBSLForQml2Js :
143 functor (JS_CTrans : JS_CTRANS) ->
144 BSLINTROSPECTION with type js_ctrans_env = JS_CTrans.env
145
146 (** If you write a interpreter, you don't need the tools on auto code generation.
147 Currently, qmltop does not use ML_ITRANS, and does not use this module *)
148 module LibBSLForQmlTopLevel :
149 functor (ITrans : ML_ITRANS) ->
150 BSLINTROSPECTION
151
152 (** A BSL for all use but the transtyping tools *)
153 module BSL : BSLINTROSPECTION
154
155 (** A type used several time in the framework, mostly by backends *)
156 type env_bsl =
157 {
158 bymap : BSL.ByPassMap.t ;
159 plugins : BslPluginInterface.plugin list
160 }
161
162 (** {6 Extra common tools for projection} *)
163
164 (** A common tools for the ML_CTrans
165 This function is shared by the two translation functions
166 _qml_of_ocaml and _ocaml_of_qml
167 It is used to project functions.
168 Sample of generated code :
169 [ let f' x1 x2 x3 =
170 let r = f x1 (px2 x2) x3 in
171 pr r in f')
172 ]
173 *)
174 val ml_function_projection :
175 inputs:(BslTypes.t -> meta_ident -> meta_code option) ->
176 outputs:(BslTypes.t -> meta_ident -> meta_code option) ->
177 BslTypes.t list -> BslTypes.t -> meta_ident -> meta_code option
178
179
180 (** A common tools for the JS_CTrans *)
181 val js_function_projection :
182 inputs:(BslTypes.t -> meta_ident -> meta_code option) ->
183 outputs:(BslTypes.t -> meta_ident -> meta_code option) ->
184 BslTypes.t list -> BslTypes.t -> meta_ident -> meta_code option
Something went wrong with that request. Please try again.