Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 300 lines (196 sloc) 9.709 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 (** The main program for the OPA compiler. S3 version. *)
20
21 (* Opening the generic pass system. *)
22 module PH = PassHandler
23
24 (* FIXME: define a module InfixOperators in PassHandler *)
25 (* this could by the only case an 'open' is allowed *)
26 let (|+>) = PH.(|+>)
27 let (|>) = PH.(|>)
28 let (<?>) = PH.(<?>)
29 let (&) = PH.(&)
30 let (|?>) = PH.(|?>)
ccded04 @BourgerieQuentin [enhance] compiler: (big) added mongo accessors generation + database ba...
BourgerieQuentin authored
31 let (|?|) = PH.(|?|)
fccc685 Initial open-source release
MLstate authored
32 let (or) = PH.(or)
33
34 (* Shorthands for accessing options of compilation *)
35 module If = Main_utils.If
ccded04 @BourgerieQuentin [enhance] compiler: (big) added mongo accessors generation + database ba...
BourgerieQuentin authored
36 module Switch = Main_utils.Switch
fccc685 Initial open-source release
MLstate authored
37
38 (* The deprecated passes *)
39 (* FIXME: adapt to the new PassHandler *)
40 module S2 = Passes
41
42 (* S3 implementations. *)
43 module S3 = S3Passes
44
45 (* Set title of generic pass system. *)
46 let _ = PH.set_title "Opa.exe"
47
48 (* Load warnings of opa s3 applications *)
49 let _ = WarningClass.load_set S3Warnings.warning_set
50
51 (* Run all passes *)
52 let () =
53 (**********************************************)
54 (* INITIALIZATION *****************************)
55 PH.init
56
57 |+> ("Welcome", S3.pass_Welcome)
58
59 |+> ("CheckOptions", S3.pass_CheckOptions)
60
61 |+> ("AddStdlibFiles", S3.pass_AddStdlibFiles)
62
63 |> PH.old_handler
64 "OpenFiles" S2.pass_OpenFiles
65
66 |+> ("PreProcess", S3.pass_PreProcess)
67
68 |+> ("Parse", S3.pass_Parse)
69
70 |+> ("RegisterAppSrcCode", S3.pass_RegisterAppSrcCode)
71
6019e3a @BourgerieQuentin [feature] dbGen: Import database runtime corresponding to the selected b...
BourgerieQuentin authored
72 |+> ("DbEngineImportation", S3.pass_DbEngineImportation)
73
fccc685 Initial open-source release
MLstate authored
74 (**********************************************)
75 (* SURFACE AST PASSES *************************)
76 |> PH.handler ~count_time:false "LoadObjects" (S3.pass_LoadObjects (fun e -> e
77
78 |+> ("BslLoading", S3.pass_BslLoading)
79
80 |+> ("ConvertStructure", S3.pass_ConvertStructure)
81
82 |> PH.old_handler
83 "CheckOptionsConsistency" Pass_CheckOptionsConsistency.process_code
84
85 |+> ("CheckServerEntryPoint", S3.pass_CheckServerEntryPoint)
86
87 |+> ("ParserGeneration", S3.pass_ParserGeneration)
88
89 |+> ("CheckDuplication", S3.pass_CheckDuplication)
90
4692879 @OpaOnWindowsNow [feature] Internationalisation: add @i18n directive and start support fo...
OpaOnWindowsNow authored
91 (* I18n, exit if generating template *)
92 |+> ("I18nAndComputedString", S3.pass_I18nAndComputedString)
93
fccc685 Initial open-source release
MLstate authored
94 |+> ("ConvertStructure2", S3.pass_ConvertStructure2 ())
95
51f92b4 [feature] adding: a no_client_calls directive
Hugo Heuzard authored
96 |+> ("TreatNoClientCalls",S3.pass_TreatNoClientCalls ())
97
fccc685 Initial open-source release
MLstate authored
98 |> PH.old_handler
99 "ReplaceCompileTimeDirective" S2.pass_ReplaceCompileTimeDirective
100
101 |> PH.old_if_handler
102 "StaticInclusionDirectory" S2.pass_static_inclusion_directory
103
104 |> PH.old_if_handler
105 "StaticInclusions" S2.pass_static_inclusions
106
107 |> PH.old_if_handler ~if_:If.server
108 "ServerEntryPoint" S2.pass_resolve_server_entry_point
109
110 (* inserting doctype directive for a collection later
111 currently always enable until an automated test verify that nobody breaks it
112 *)
113 |+> ((*PH.old_if_handler ~if_:If.generate_interface, *)
114 "AddDocApiDirectives", (S3.pass_AddDocApiDirectives ()))
115
116 |> PH.old_if_handler
117 "TupleTypeGeneration" S2.pass_tuple_types
118
119 |+> ("Reorder", (S3.pass_ReorderToplevel ()))
120
121 |+> ("RewriteModules", (S3.pass_RewriteModules ()))
122
123 |> PH.old_if_handler ~if_:If.server
124 "AddingServer" S2.pass_adding_server
125
126 (**********************************************)
127 (* QML AST PASSES *****************************)
128 |+> ("SAtoQML", S3.pass_SaToQml)
129
130 |+> ("AddCSS", S3.pass_AddCSS)
131
132 |+> ("FunActionLifting", S3.pass_FunActionLifting)
133
134 |+> ("TypesDefinitions", S3.pass_TypesDefinitions)
135
136 |+> ("DbSchemaGeneration", S3.pass_DbSchemaGeneration)
137
138 |+> ("DbPathCoercion", S3.pass_DbPathCoercion)
139
140 |+> ("MacroExpansion", S3.pass_MacroExpansion)
141
142 |+> ("Typing", S3.pass_Typing)
143
144 (* Extracting interesting types for documentation *)
145 |+> ("DocApiGeneration", S3.pass_DocApiGeneration)(*~if_:If.generate_interface*)
146
147 |+> ("CheckPatternMatching", S3.pass_CheckPatternMatching)
148
149 |+> ("WarnCoerce", S3.pass_WarnCoerce)
150
151 |+> ("CompileRecursiveValues", S3.pass_CompileRecursiveValues)
152
8edc001 [feature] adding: an @async directive on bindings to perform asynchronou...
Valentin Gatien-Baron authored
153 |+> ("RewriteAsyncLambda", S3.pass_RewriteAsyncLambda)
154
fccc685 Initial open-source release
MLstate authored
155 (*|+> ("Retyping", S3.pass_Retyping)*)
156
ccded04 @BourgerieQuentin [enhance] compiler: (big) added mongo accessors generation + database ba...
BourgerieQuentin authored
157 |?| ( Switch.database, function
5fdc6b9 @BourgerieQuentin [enhance] compiler: (big) Common path typing beetween several backend + ...
BourgerieQuentin authored
158 | `db3 -> ("BadopCodeGeneration", S3.pass_BadopCodeGeneration)
159 | `mongo -> ("MongoCodeGeneration", S3.pass_MongoCodeGeneration)
ccded04 @BourgerieQuentin [enhance] compiler: (big) added mongo accessors generation + database ba...
BourgerieQuentin authored
160 )
fccc685 Initial open-source release
MLstate authored
161
00818f9 [refactor] removing most typing directives sooner
Valentin Gatien-Baron authored
162 (* could be just after typing, if dbgen didn't complain that it can't find its coercions :/ *)
163 |+> ("PurgeTypeDirectivesAfterTyping", S3.pass_PurgeTypeDirectiveAfterTyping)
164
fccc685 Initial open-source release
MLstate authored
165 |> PH.handler ~count_time:false "EndOfSeparateCompilation" (S3.pass_EndOfSeparateCompilation (fun e -> e
166
167 |+> ("BypassHoisting", S3.pass_BypassHoisting)
168
169 |+> ("RegisterFields", S3.pass_RegisterFields)
170
171 |?> (If.undot,
172 "Undot", S3.pass_QmlUndot)
173
174 |+> ("CodingDirectives", S3.pass_CodingDirectives)
175
176 <?> (If.closure,
177 ("EnrichMagic", S3.pass_EnrichMagic),
178 ("EnrichMagicPurge", S3.pass_EnrichMagicPurge))
179
180 |+> ("SimplifyEquality", S3.pass_SimplifyEquality)
181
182 |+> ("SimplifyMagic", S3.pass_SimplifyMagic)
183
184 |+> ("JustReorder1", S3.pass_ReorderEnvGen)
185
186 |> PH.old_if_handler
187 "EarlyLambdaLifting" S2.pass_EarlyLambdaLifting
188
936d60a [feature] closure serialisation: adding closure instrumentation (compile...
Valentin Gatien-Baron authored
189 |+> ("InstrumentForClosureSerialization", S3.pass_InstrumentForClosureSerialization)
190
fccc685 Initial open-source release
MLstate authored
191 (**********************************************)
192 (* SLICED PASSES ******************************)
193 <?> (If.server or If.separated or If.slicer_test,
194 ("Slicing" , S3.pass_SimpleSlicer),
195 ("NoSlicing", S3.pass_NoSlicer))
196
197 |+> ("Assertion", S3.pass_Assertion)
198
199 |?> (PH.neg (If.no_discard_of_unused_stdlib or If.separated),
200 "SlicedCleaning", S3.pass_SlicedCleaning)
201
202 (* Fun action resolution, step 2/3 *)
203 |?> (If.server or If.separated,
204 "FunActionEnvSerialize", S3.pass_FunActionEnvSerialize)
205
206 (* Explicit instantiation *)
207 |?> (If.explicit_instantiation,
208 "ExplicitInstantiation", S3.pass_ExplicitInstantiation)
209
210 |?> (If.explicit_instantiation,
211 "OptimizeExplicitInstantiation", S3.pass_OptimizeExplicitInstantiation)
212
213 (* Fun action resolution, step 3/3 *)
214 |?> (If.server or If.separated,
215 "FunActionJsCallGeneration", S3.pass_FunActionJsCallGeneration)
216
00818f9 [refactor] removing most typing directives sooner
Valentin Gatien-Baron authored
217 |+> ("PurgeTypeDirectivesAfterEi", S3.pass_PurgeTypeDirectiveAfterEi)
fccc685 Initial open-source release
MLstate authored
218
219 |?> (If.explicit_instantiation & (If.server or If.separated),
220 "ResolveRemoteCalls", S3.pass_ResolveRemoteCalls)
221
222 |?> (If.explicit_instantiation,
223 "InsertMemoizedTypes", S3.pass_InsertMemoizedTypes)
224
225 |+> ("JustReorder2", S3.pass_SlicedReorder)
226
227 (* ***********************************************)
228 (* FINAL COMPILATION *****************************)
229 |+> ("SlicedToFinal", S3.pass_SlicedToFinal)
230
231 (* ***********************************************)
232 (* FINAL CLIENT COMPILATION **********************)
233 (* ~precond:[check_ident_final_client] *)
234
235 |?> (If.cps_client,
236 "ClientQmlCpsRewriter", S3.pass_ClientCpsRewriter)
237
238 |?> (If.closure,
239 "ClientQmlLambdaLifting", S3.pass_ClientLambdaLifting)
240
241 (* |?> (If.closure,
242 "ClientQmlUncurry", S3.pass_ClientQmlUncurry)
243
244 |?> (If.closure,
245 "ClientQmlClosure", S3.pass_ClientQmlClosure)*)
246
247 |?> (If.constant_sharing_client,
248 "QmlClientConstantSharing", S3.pass_ClientQmlConstantSharing)
249 (* Insert client code like a js string on server (if
250 necessary) - After that client qml code have no more
251 place to exist and it dropped *)
252 |+> ("JavascriptCompilation", S3.pass_JavascriptCompilation)
253
254 |?> (If.server or If.separated,
255 "ResolveJsIdent", S3.pass_ResolveJsIdent)
256
257 <?> (If.server or If.separated,
258 ("GenerateServerAst", S3.pass_GenerateServerAst true),
259 ("DontGenerateServerAst", S3.pass_GenerateServerAst false))
260
261 (* ***********************************************)
262 (* FINAL SERVER COMPILATION **********************)
263
264 |+> ("CleanLambdaLiftingDirectives", S3.pass_CleanLambdaLiftingDirectives)
265
266 |?> (If.init,
267 "InitializeBslValues", S3.pass_InitializeBslValues)
268
269 |+> ("ServerQmlCpsRewriter", S3.pass_ServerCpsRewriter)
270
271 |> PH.old_if_handler ~if_:If.closure (* ~precond:[check_ident_final] *)
272 "ServerQmlLambdaLifting" (S2.pass_LambdaLifting2 ~typed:false ~side:`server)
273
274 |> PH.old_if_handler ~if_:If.closure
275 "ServerQmlUncurry" (S2.pass_QmlUncurry2 ~typed:false ~side:`server)
276
277 |?> (If.closure,
278 "ServerQmlClosure", S3.pass_ServerQmlClosure)
279
280 |?> (If.constant_sharing,
281 "QmlConstantSharing", S3.pass_QmlConstantSharing)
282
283 |+> ("QmlCompilation", S3.pass_QmlCompilation)
284
285 |+> ("OcamlSplitCode", S3.pass_OcamlSplitCode)
286
287 |+> ("OcamlGeneration", S3.pass_OcamlGeneration)
288
289 |+> ("OcamlCompilation", S3.pass_OcamlCompilation)
290
291 |+> ("CleanUp", S3.pass_CleanUp)
292
293 |+> ("ByeBye", S3.pass_ByeBye)
294
295 |> PH.return )) (* end of the pass endOfSeparateCompilation *)
296 |> PH.return )) (* end of the pass loadObjects *)
297 |> PH.return
298
299 let () = OManager.exit 0
Something went wrong with that request. Please try again.