Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[enhance] compiler, opa: Propagates exported idents along passes

  • Loading branch information...
commit adefa42a651e058e4e457e09b29907a27602ab6f 1 parent 9df2b9c
@BourgerieQuentin BourgerieQuentin authored
View
5 compiler/opa/pass_JavascriptCompilation.ml
@@ -192,6 +192,7 @@ let full_serialize
~closure_map
~is_distant
~renaming
+ ~exported
~client_roots
~typing:_
~bsl_pp
@@ -304,6 +305,7 @@ let full_serialize
with Not_found ->
OManager.error "Function %S not registered in Opacapi@\n" name in
let env_js_input =
+ let exported = IdentSet.union client_roots exported in
Qml2js.Sugar.for_opa
~bsl:bsl_and_plugin_ast
~val_:env_js_input_val_
@@ -311,6 +313,7 @@ let full_serialize
~is_distant
~renaming
~bsl_lang:BslLanguage.js
+ ~exported
back_end
jsoptions
bsl_client
@@ -377,6 +380,7 @@ let process
~closure_map
~is_distant
~renaming
+ ~exported
~client_roots
~typing
~bsl_pp
@@ -396,6 +400,7 @@ let process
~closure_map
~is_distant
~renaming
+ ~exported
~client_roots
~typing
~bsl_pp
View
1  compiler/opa/pass_JavascriptCompilation.mli
@@ -59,6 +59,7 @@ val process :
closure_map:Ident.t IdentMap.t ->
is_distant:(Ident.t -> bool) ->
renaming:QmlRenamingMap.t ->
+ exported:IdentSet.t ->
client_roots:IdentSet.t ->
typing:QmlTyper.env -> (* currently unused *)
bsl_pp:(name:string-> string -> string) ->
View
3  compiler/opa/passes.ml
@@ -192,6 +192,7 @@ type 'tmp_env env_Gen = {
local_typedefs : QmlAst.TypeIdentSet.t;
stdlib_gamma : QmlTypes.gamma; (* used to get the tsc of the stdlib ident *)
doc_types : Ident.t doc_types; (** opadoc specific data *)
+ exported : IdentSet.t;
temporary_env : 'tmp_env;
}
@@ -224,6 +225,7 @@ let change_temporary (temporary_env : 'b) (env_gen : 'a env_Gen) = ({
local_typedefs = env_gen.local_typedefs;
stdlib_gamma = env_gen.stdlib_gamma;
doc_types = env_gen.doc_types;
+ exported = env_gen.exported;
temporary_env = temporary_env;
} : ('b env_Gen))
@@ -376,6 +378,7 @@ type env_NewFinalCompile = {
newFinalCompile_qml_milkshake : QmlBlender.qml_milkshake ;
newFinalCompile_renaming_server : QmlRenamingMap.t;
newFinalCompile_renaming_client : QmlRenamingMap.t;
+ newFinalCompile_exported : IdentSet.t;
newFinalCompile_closure_map : Ident.t IdentMap.t; (* see QmlUncurry.mli *)
newFinalCompile_stdlib_gamma : QmlTypes.gamma;
}
View
10 compiler/opa/s3Passes.ml
@@ -712,6 +712,8 @@ let pass_SaToQml =
the annotations.
*)
+ let exported_values_idents = env.P.sa_exported_values_idents in
+
let typerEnv =
let bypass_typer =
BslLib.BSL.ByPassMap.bypass_typer
@@ -723,7 +725,7 @@ let pass_SaToQml =
~explicit_instantiation: options.O.explicit_instantiation
~value_restriction: options.O.value_restriction
~display: options.O.show_types
- ~exported_values_idents: env.P.sa_exported_values_idents () in
+ ~exported_values_idents: exported_values_idents () in
let env_Gen =
{ P.
@@ -732,6 +734,7 @@ let pass_SaToQml =
typerEnv = typerEnv;
doc_types = env.P.sa_doc_types;
temporary_env = ();
+ exported = exported_values_idents;
local_typedefs = QmlAst.TypeIdentSet.empty;
stdlib_gamma = QmlTypes.Env.empty;
} in
@@ -1737,6 +1740,7 @@ let pass_SlicedToFinal =
newFinalCompile_qml_milkshake = blender_milkshake;
newFinalCompile_renaming_server = eenv.P.sliced_env.P.server.P.original_renaming;
newFinalCompile_renaming_client = eenv.P.sliced_env.P.client.P.original_renaming;
+ newFinalCompile_exported = e.PH.env.P.env_gen.P.exported;
newFinalCompile_closure_map = IdentMap.empty;
newFinalCompile_stdlib_gamma = e.PH.env.P.env_gen.P.stdlib_gamma;
} in
@@ -1819,6 +1823,7 @@ let pass_JavascriptCompilation =
let other = client_finalenv.P.newFinalCompile_renaming_server in
EnvUtils.jsutils_from_renamings ~here ~other
in
+ let exported = client_finalenv.P.newFinalCompile_exported in
let bsl_pp =
let ppenv = Pprocess.fill_with_sysenv Pprocess.empty_env in
let ppenv = OpaEnv.Options.to_ppenv options ppenv in
@@ -1830,6 +1835,7 @@ let pass_JavascriptCompilation =
~closure_map
~is_distant
~renaming
+ ~exported
~client_roots
~typing
~bsl_pp
@@ -2217,6 +2223,7 @@ let pass_ServerJavascriptCompilation =
let here = env.P.newFinalCompile_renaming_server in
EnvUtils.jsutils_from_renamings ~here ~other
in
+ let exported = env.Passes.newFinalCompile_exported in
let env_js_input = JsBackend.compile
~runtime_ast:false
~bsl:loaded_bsl.Qml2js.generated_ast
@@ -2225,6 +2232,7 @@ let pass_ServerJavascriptCompilation =
~is_distant
~renaming
~bsl_lang:BslLanguage.nodejs
+ ~exported
jsoptions
env_bsl
env.Passes.newFinalCompile_qml_milkshake.QmlBlender.env
View
9 compiler/qml2js/qml2js.ml
@@ -573,6 +573,7 @@ sig
is_distant:(Ident.t -> bool) ->
renaming:QmlRenamingMap.t ->
bsl_lang:BslLanguage.t ->
+ exported:IdentSet.t ->
(module Qml2jsOptions.JsBackend) ->
Qml2jsOptions.t ->
BslLib.env_bsl ->
@@ -583,9 +584,13 @@ sig
end
=
struct
- let for_opa ~val_ ?bsl:bsl_code ~closure_map ~is_distant ~renaming ~bsl_lang back_end argv env_bsl env_typer code =
+ let for_opa ~val_ ?bsl:bsl_code ~closure_map ~is_distant ~renaming ~bsl_lang ~exported
+ back_end argv env_bsl env_typer code =
let module M = (val back_end : Qml2jsOptions.JsBackend) in
- let env_js_input = M.compile ~val_ ?bsl:bsl_code ~closure_map ~is_distant ~renaming ~bsl_lang argv env_bsl env_typer code in
+ let env_js_input =
+ M.compile ~val_ ?bsl:bsl_code ~closure_map ~is_distant ~renaming ~bsl_lang ~exported
+ argv env_bsl env_typer code
+ in
env_js_input
let dummy_for_opa backend =
let module M = (val backend : Qml2jsOptions.JsBackend) in
View
19 compiler/qml2js/qml2jsOptions.ml
@@ -89,20 +89,23 @@ type env_js_input =
| `ast of (BslInterface.unicity_index * JsAst.code_elt) list
| `string of string
]) list ;
+ exported : JsIdentSet.t ;
js_code : JsAst.code ; (** will be split according to argv_options *)
}
module type JsBackend = sig
val dynloader : BslPluginInterface.plugin -> unit
- val compile : ?runtime_ast:bool ->
- ?val_:(string -> QmlAst.ident) ->
- ?bsl:JsAst.code ->
- ?closure_map:Ident.t IdentMap.t ->
- renaming:QmlRenamingMap.t ->
- is_distant:(Ident.t -> bool) ->
- bsl_lang:BslLanguage.t ->
- t -> BslLib.env_bsl -> QmlTyper.env -> QmlAst.code -> env_js_input
+ val compile :
+ ?runtime_ast:bool ->
+ ?val_:(string -> QmlAst.ident) ->
+ ?bsl:JsAst.code ->
+ ?closure_map:Ident.t IdentMap.t ->
+ renaming:QmlRenamingMap.t ->
+ is_distant:(Ident.t -> bool) ->
+ bsl_lang:BslLanguage.t ->
+ exported:IdentSet.t ->
+ t -> BslLib.env_bsl -> QmlTyper.env -> QmlAst.code -> env_js_input
val name : string
val runtime_libs : cps:bool -> extra_lib list
val dummy_compile : unit -> unit (* if the back end is not called because the input code is empty
Please sign in to comment.
Something went wrong with that request. Please try again.