Permalink
Browse files

continue separation of backends

  • Loading branch information...
1 parent f54ec69 commit 62370f0ea49254d864380ca39435701a001d6a74 @Aqua-Ye Aqua-Ye committed Oct 3, 2012
View
@@ -3,10 +3,10 @@
# COMPILER TAGS
#
-<{buildinfos,compilerlib,jslang,libbsl,libqmlcompil,libtrx,ocamllang,opa,opacapi,opalang,opalib,opatop,passes,passlib,pplib,protocols,qml2js,qml2ocaml,qmlcompilers,qmlcps,qmlflat,qmljsimp,qmlpasses,qmlslicer}>: traverse
+<{backend_passes,buildinfos,compilerlib,jslang,libbsl,libqmlcompil,libtrx,ocamllang,opa,opacapi,opalang,opalib,opatop,passes,passlib,pplib,protocols,qml2js,qml2ocaml,qmlcompilers,qmlcps,qmlflat,qmljsimp,qmlpasses,qmlslicer}>: traverse
-<main.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib, use_libbsl, use_qml2ocaml, use_qml2js, use_qmlflatcompiler, use_opa
+<main.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib, use_libbsl, use_qml2ocaml, use_qml2js, use_qmlflatcompiler, use_backend_passes, use_opa
-<main.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi, use_opa
+<main.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi, use_backend_passes, use_opa
<main.ml>: with_mlstate_debug
@@ -0,0 +1,2 @@
+compiler/backend_passes/QmljsPasses
+compiler/backend_passes/QmlflatPasses
@@ -0,0 +1,7 @@
+# -*- conf -*- (for emacs)
+
+<**/*.{ml,mli}>: use_buildinfos, use_libbase, use_compilerlib, use_opacapi
+
+<pass_ServerJavascriptOptimization.{ml,mli}>: use_jslang, use_libqmlcompil, use_passlib
+
+<{qmljsPasses,qmlflatPasses}.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlslicer, use_passlib, use_opapasses, use_qml2ocaml, use_opalang, use_libbsl, use_qmlfakecompiler, use_ocamllang, use_qmlpasses, use_qml2js, use_jslang, use_qmlflatcompiler, use_opa
@@ -39,6 +39,71 @@ type env_OcamlCompilation = {
ocamlCompilation_returned_code : int ;
}
+let pass_OpaOptionsToQmlOptions ~(options:Passes.opa_options) qml_milkshake =
+ (** PASSING OPTIONS TO QML2OCAML : we must absolutly here use the syntax \{ with \} because
+ the interface of qmlfake options is unfrozen (and need to stay so) (don't need to update this code) *)
+ let argv_options = Qml2ocamlOptions.ArgvOptions.default (OpaEnv.string_of_available_back_end options.OpaEnv.back_end) in
+ let argv_options =
+ let compilation_directory =
+ if options.OpaEnv.build_dir = ""
+ then Filename.concat "_build" (File.chop_extension options.OpaEnv.target)
+ else options.OpaEnv.build_dir
+ in
+ let split_ocaml_value =
+ let mindeclfile = 20 (* desire *) in
+ let maxfiles = 500 (* approximate constraint *) in
+ let nb_decl = List.length qml_milkshake.QmlBlender.code in
+ let split_for_maxfiles = int_of_float (ceil ((float nb_decl ) /. (float maxfiles))) in
+ (* min 2 *) (max mindeclfile split_for_maxfiles)
+ in
+ let cclib = List.map (Printf.sprintf "-cclib %s") options.OpaEnv.cclib in
+ let ccopt = List.map (Printf.sprintf "-ccopt %s") options.OpaEnv.ccopt in
+ { argv_options with Qml2ocamlOptions.
+ bypass_plugin = options.OpaEnv.bypass_plugin ;
+ camlp4o = false ; (* options.OpaEnv.camlp4o *)
+ compilation_directory = compilation_directory ; (* options.OpaEnv.build_dir *)
+ compile_via_makefile = true; (* not Base.is_windows; *) (** use _build/Makefile except on Windows *)
+ cps = options.OpaEnv.cps ;
+ cps_toplevel_concurrency = options.OpaEnv.cps_toplevel_concurrency ;
+ server_side = true;
+ display_schema = options.OpaEnv.dump_dbgen_schema ;
+ exe_argv = Option.default [] options.OpaEnv.run_server_options ;
+ extra_lib = argv_options.Qml2ocamlOptions.extra_lib @ options.OpaEnv.extralibs ;
+ extra_path = OpaEnv.Parameters.server_include_dir @
+ (List.map (Filename.concat (Lazy.force InstallDir.getenv)) OpaEnv.Parameters.server_include_mlstate_dir) @
+ options.OpaEnv.extrapath ;
+ exe_run = Option.is_some options.OpaEnv.run_server_options ;
+ hacker_mode = options.OpaEnv.hacker_mode ;
+ makefile_rule = options.OpaEnv.makefile_rule ;
+ mlcopt = argv_options.Qml2ocamlOptions.mlcopt @ options.OpaEnv.mlcopt @ ccopt ;
+ mllopt = argv_options.Qml2ocamlOptions.mllopt @ options.OpaEnv.mllopt @ ccopt @ cclib ;
+ no_assert = options.OpaEnv.no_assert ;
+ ocamlc = options.OpaEnv.ocamlc ;
+ ocamlopt = options.OpaEnv.ocamlopt ;
+ profile = options.OpaEnv.profile ;
+ qml_closure = options.OpaEnv.closure;
+ show_compilation = options.OpaEnv.show_compilation ;
+ split_ocaml_value = split_ocaml_value ;
+ target = options.OpaEnv.target ;
+ (* hack for "cannot generalize"; in rare cases of Opa code helps, and can be complementary with eta_expand *)
+ top_magic = true ;
+ } in
+ argv_options
+
+let pass_QmlCompiler ~(options:Passes.opa_options) (env:Passes.env_NewFinalCompile) : Passes.env_BinaryGeneration =
+ let qml_milkshake = env.Passes.newFinalCompile_qml_milkshake in
+ let env_bsl = env.Passes.newFinalCompile_bsl in
+ let argv_options = pass_OpaOptionsToQmlOptions ~options qml_milkshake in
+ (** Choice of back-end *)
+ let qml_to_ocaml = Flat_Compiler.qml_to_ocaml in
+ (* This pass is splitten in 3 in opas3 *)
+ let return = Qml2ocaml.Sugar.for_opa qml_to_ocaml argv_options env_bsl qml_milkshake in
+ let out = {
+ Passes.binaryGeneration_success = return = 0
+ }
+ in let () = if return <> 0 then prerr_endline "OCAML COMPILER FAIL"
+ in out
+
let pass_QmlCompilation =
let transform pass_env =
let options = pass_env.PH.options in
@@ -48,7 +113,7 @@ let pass_QmlCompilation =
let qml2ocaml_qml_milkshake = env.Passes.newFinalCompile_qml_milkshake in
(* renaming is not used *)
(* 1) transform options *)
- let qmlCompilation_options = Passes.pass_OpaOptionsToQmlOptions ~options qml2ocaml_qml_milkshake in
+ let qmlCompilation_options = pass_OpaOptionsToQmlOptions ~options qml2ocaml_qml_milkshake in
(* 2) selection of the back-end *)
let qml_to_ocaml = Flat_Compiler.qml_to_ocaml in
(* proceed *)
View
@@ -0,0 +1 @@
+compiler/opa/Compiler
View
@@ -9,7 +9,7 @@
# it help as well to see what depends still on liboldqml.
# Please, keep it so until the refactoring is finished
-<checkopacapi.{ml,byte,native}>: use_opalang, use_opabsl_for_compiler, use_libbsl, use_libqmlcompil, use_compilerlib, use_pplib
+<checkopacapi.{ml,byte}>: use_opalang, use_opabsl_for_compiler, use_libbsl, use_libqmlcompil, use_compilerlib, use_pplib, use_qml2ocaml
<compilationUtils.ml>: use_opalib
<pass_FunActionEnvSerialize.{ml,mli}>: use_libqmlcompil, use_opalang, use_opalib, use_jslang, use_qmlpasses
@@ -35,8 +35,8 @@
<pass_CodingDirectives.{ml,mli}>: use_compilerlib, use_libqmlcompil, use_opalang
<pass_MacroExpansion.{ml,mli}>: use_libqmlcompil, use_passlib, use_opalib, use_opalang
<pass_OpaDocApi.{ml,mli}>: use_libqmlcompil, use_opalib, use_opalang, use_opapasses, use_qmlpasses, with_mlstate_debug
-<pass_JavascriptCompilation.{ml,mli}>: use_libqmlcompil, use_libbsl, use_opalib, use_qml2js, use_opalang, use_jslang, use_qml2ocaml, use_qmljsimp, use_pplib
-<pass_ServerJavascriptOptimization.{ml,mli}>: use_jslang, use_libqmlcompil, use_passlib
+<pass_JavascriptCompilation.{ml,mli}>: use_libqmlcompil, use_libbsl, use_opalib, use_qml2js, use_opalang, use_jslang, use_qmljsimp, use_pplib
+
<pass_RegisterAppSrcCode.{ml,mli}>: use_libqmlcompil, use_opapasses, use_opalang
<pass_TreatNoClientCalls.{ml,mli}>: use_libqmlcompil, use_opapasses, use_opalang
<pass_DbEngineImportation.{ml,mli}>: use_libqmlcompil, use_opalang
@@ -45,24 +45,24 @@
<pass_AddStdlibFiles.{ml,mli}>: use_compilerlib, use_opalib
-<pass_BslLoading.{ml,mli}>: use_libbsl, use_opalib, use_opabsl_for_compiler, use_qmlflatcompiler, use_qmljsimp, use_qml2ocaml, use_qml2js, use_opalang, use_libqmlcompil
+<pass_BslLoading.{ml,mli}>: use_libbsl, use_opalib, use_opabsl_for_compiler, use_qmlflatcompiler, use_qmljsimp, use_qml2js, use_opalang, use_libqmlcompil
<s3Warnings.{ml,mli}>: use_compilerlib, use_libqmlcompil, use_qmlpasses, use_opapasses, use_qmljsimp, use_qmlflatcompiler, use_qmlslicer, use_opalang
# thing about it
-<passes.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qml2js, use_libbsl, use_opalang, use_opapasses, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_qmlpasses, use_passlib
+<passes.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2js, use_libbsl, use_opalang, use_opapasses, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_qmlpasses, use_passlib
# main
<main_utils.{ml,mli}>: use_libqmlcompil, use_opalang, use_opalib, use_opapasses, use_libbsl
<opa_parse.ml>: use_opalib, use_opalang, use_opapasses
# s3 main
-<{s3Passes,qmljsPasses,qmlflatPasses}.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlslicer, use_passlib, use_opapasses, use_qml2ocaml, use_opalang, use_libbsl, use_qmlfakecompiler, use_ocamllang, use_qmlpasses, use_qml2js, use_jslang, use_qmlflatcompiler
-<{compiler,gen_opa_manpage}.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib, use_libbsl, use_qml2ocaml, use_qml2js
-<syntaxHelper.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib
+<s3Passes.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlslicer, use_passlib, use_opapasses, use_opalang, use_libbsl, use_qmlfakecompiler, use_ocamllang, use_qmlpasses, use_qml2js, use_jslang, use_qmlflatcompiler
+<{compiler,gen_opa_manpage}.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_passlib, use_libbsl, use_qml2js
+<syntaxHelper.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_passlib
# linking
-<{opa_parse,checkopacapi,gen_opa_manpage,syntaxHelper}.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi
+<{opa_parse,checkopacapi,gen_opa_manpage,syntaxHelper}.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi, use_qml2ocaml
<opa_InsertRemote.ml>: with_mlstate_debug
<main_utils.ml>: with_mlstate_debug
View
@@ -631,72 +631,6 @@ type env_BinaryGeneration = {
binaryGeneration_success : bool
}
-let pass_OpaOptionsToQmlOptions ~(options:opa_options) qml_milkshake =
- (** PASSING OPTIONS TO QML2OCAML : we must absolutly here use the syntax \{ with \} because
- the interface of qmlfake options is unfrozen (and need to stay so) (don't need to update this code) *)
- let argv_options = Qml2ocamlOptions.ArgvOptions.default (OpaEnv.string_of_available_back_end options.OpaEnv.back_end) in
- let argv_options =
- let compilation_directory =
- if options.OpaEnv.build_dir = ""
- then Filename.concat "_build" (File.chop_extension options.OpaEnv.target)
- else options.OpaEnv.build_dir
- in
- let split_ocaml_value =
- let mindeclfile = 20 (* desire *) in
- let maxfiles = 500 (* approximate constraint *) in
- let nb_decl = List.length qml_milkshake.QmlBlender.code in
- let split_for_maxfiles = int_of_float (ceil ((float nb_decl ) /. (float maxfiles))) in
- (* min 2 *) (max mindeclfile split_for_maxfiles)
- in
- let cclib = List.map (Printf.sprintf "-cclib %s") options.OpaEnv.cclib in
- let ccopt = List.map (Printf.sprintf "-ccopt %s") options.OpaEnv.ccopt in
- { argv_options with Qml2ocamlOptions.
- bypass_plugin = options.OpaEnv.bypass_plugin ;
- camlp4o = false ; (* options.OpaEnv.camlp4o *)
- compilation_directory = compilation_directory ; (* options.OpaEnv.build_dir *)
- compile_via_makefile = true; (* not Base.is_windows; *) (** use _build/Makefile except on Windows *)
- cps = options.OpaEnv.cps ;
- cps_toplevel_concurrency = options.OpaEnv.cps_toplevel_concurrency ;
- server_side = true;
- display_schema = options.OpaEnv.dump_dbgen_schema ;
- exe_argv = Option.default [] options.OpaEnv.run_server_options ;
- extra_lib = argv_options.Qml2ocamlOptions.extra_lib @ options.OpaEnv.extralibs ;
- extra_path = OpaEnv.Parameters.server_include_dir @
- (List.map (Filename.concat (Lazy.force InstallDir.getenv)) OpaEnv.Parameters.server_include_mlstate_dir) @
- options.OpaEnv.extrapath ;
- exe_run = Option.is_some options.OpaEnv.run_server_options ;
- hacker_mode = options.OpaEnv.hacker_mode ;
- makefile_rule = options.OpaEnv.makefile_rule ;
- mlcopt = argv_options.Qml2ocamlOptions.mlcopt @ options.OpaEnv.mlcopt @ ccopt ;
- mllopt = argv_options.Qml2ocamlOptions.mllopt @ options.OpaEnv.mllopt @ ccopt @ cclib ;
- no_assert = options.OpaEnv.no_assert ;
- ocamlc = options.OpaEnv.ocamlc ;
- ocamlopt = options.OpaEnv.ocamlopt ;
- profile = options.OpaEnv.profile ;
- qml_closure = options.OpaEnv.closure;
- show_compilation = options.OpaEnv.show_compilation ;
- split_ocaml_value = split_ocaml_value ;
- target = options.OpaEnv.target ;
- (* hack for "cannot generalize"; in rare cases of Opa code helps, and can be complementary with eta_expand *)
- top_magic = true ;
- } in
- argv_options
-
-let pass_QmlCompiler ~(options:opa_options) (env:env_NewFinalCompile) : env_BinaryGeneration =
- let qml_milkshake = env.newFinalCompile_qml_milkshake in
- let env_bsl = env.newFinalCompile_bsl in
- let argv_options = pass_OpaOptionsToQmlOptions ~options qml_milkshake in
- (** Choice of back-end *)
- assert (OpaEnv.Backend "qmlflat" = options.OpaEnv.back_end);
- let qml_to_ocaml = Flat_Compiler.qml_to_ocaml in
- (* This pass is splitten in 3 in opas3 *)
- let return = Qml2ocaml.Sugar.for_opa qml_to_ocaml argv_options env_bsl qml_milkshake in
- let out = {
- binaryGeneration_success = return = 0
- }
- in let () = if return <> 0 then prerr_endline "OCAML COMPILER FAIL"
- in out
-
let macro_pass_CompilationSuccess ((options:opa_options), _) =
flush stderr; flush stdout;
(*List.iter (fun s->Printf.printf "%s" s) (get_warnings ());flush stdout;*)
View
@@ -327,12 +327,6 @@ end = struct
end
-(* (\** Select the good register function according to back-end *\) *)
-(* let register_fields options = *)
-(* match options.O.back_end with *)
-(* | OpaEnv.Backend "qmlflat" -> *)
-(* | _ -> (fun _ -> ()) *)
-
(**********************************************************)
(* Public : MAKE YOUR PASSES HERE *************************)
View
@@ -22,6 +22,7 @@ internal libsession ocamllib/libsession
internal libtools ocamllib/libtools
internal oparuntime ocamllib/oparuntime
+internal backend_passes compiler/backend_passes
internal buildinfos compiler/buildinfos
internal compilerlib compiler/compilerlib
internal jslang compiler/jslang
@@ -185,7 +185,7 @@ let opa_opacapi_plugins = ["badop"] in
(* used in mkinstall *)
let opacapi_validation = "opacapi.validation" in
rule "Opa Compiler Interface Validation (opacapi)"
- ~deps:("compiler/opa/checkopacapi.native" :: opa_opacapi_files
+ ~deps:(tool_deps "checkopacapi" @ opa_opacapi_files
@ List.map (fun x -> Printf.sprintf "lib/plugins/%s/%s.oppf" x x)
opa_opacapi_plugins)
~prod:opacapi_validation
View
@@ -50,6 +50,7 @@ internal odeplink tools/odeplink.native
internal opa2opa compiler/opalang/opa2opa.native
internal ofile tools/ofile.native
internal opa-translate compiler/opa/syntaxHelper.native
+internal checkopacapi compiler/opa/checkopacapi.native
# The name of opa raw executable, following unix guidelines (e.g. firefox distrib)
# when there is a wraper used to call a raw exe

0 comments on commit 62370f0

Please sign in to comment.