Module Flambda2_to_jsir.To_jsir_env
val create :
module_symbol:Flambda2_identifiers.Symbol.t ->
return_continuation:Flambda2_identifiers.Continuation.t ->
exn_continuation:Flambda2_identifiers.Continuation.t ->
tCreate a new environment.
return_continuation and exn_continuation refer to the top-level return/exception continuations, and does not change once the environment is created.
val return_continuation : t -> Flambda2_identifiers.Continuation.tval exn_continuation : t -> Flambda2_identifiers.Continuation.tval enter_function_body :
t ->
return_continuation:Flambda2_identifiers.Continuation.t ->
exn_continuation:Flambda2_identifiers.Continuation.t ->
tEnter a function body, with the corresponding return and exception continuations.
val module_symbol : t -> Flambda2_identifiers.Symbol.tSymbol corresponding to the module currently compiling.
val add_continuation :
t ->
Flambda2_identifiers.Continuation.t ->
Jsoo_imports.Import.Jsir.Addr.t ->
tMap a Flambda2 continuation to the address of the corresponding block. Not to be used for continuations used as exception handlers (use add_exn_handler).
val add_exn_handler :
t ->
Flambda2_identifiers.Continuation.t ->
addr:Jsoo_imports.Import.Jsir.Addr.t ->
exn_param:Jsoo_imports.Import.Jsir.Var.t ->
extra_args:Jsoo_imports.Import.Jsir.Var.t list ->
tAdd continuations used as exception handlers, along with its exception parameter and any variables used to pass in extra_args.
val add_var :
t ->
Flambda2_identifiers.Variable.t ->
Jsoo_imports.Import.Jsir.Var.t ->
tMap a Flambda2 variable to a JSIR variable.
val add_var_alias_of_var_exn :
t ->
var:Flambda2_identifiers.Variable.t ->
alias_of:Flambda2_identifiers.Variable.t ->
tSet var to be an alias of alias_of. Raises if alias_of is not found in the environment.
val add_symbol :
t ->
res:To_jsir_result.t ->
Flambda2_identifiers.Symbol.t ->
Jsoo_imports.Import.Jsir.Var.t ->
t * To_jsir_result.tMap a Flambda2 symbol to a JSIR variable, and register it to the global symbol table.
val add_symbol_without_registering :
t ->
Flambda2_identifiers.Symbol.t ->
Jsoo_imports.Import.Jsir.Var.t ->
tSymbols added through this function must be registered to the global symbol table after the definitions for them are added to the result, using register_symbol_exn. Otherwise, they will not be available to other compilation units.
val register_symbol_exn :
t ->
res:To_jsir_result.t ->
Flambda2_identifiers.Symbol.t ->
To_jsir_result.tRegister the given symbol to the global symbol table. Raises if the symbol is not in the environment.
Note that calling this function is usually a mistake, as most functions that add symbols will automatically call this function. However, it is necessary for add_symbol_without_registering.
val add_var_alias_of_symbol_exn :
t ->
res:To_jsir_result.t ->
var:Flambda2_identifiers.Variable.t ->
alias_of:Flambda2_identifiers.Symbol.t ->
t * To_jsir_result.tSet var/symbol to be an alias of alias_of. Raises if alias_of is from the current compilation unit and is not found in the environment.
val add_symbol_alias_of_var_exn :
t ->
res:To_jsir_result.t ->
symbol:Flambda2_identifiers.Symbol.t ->
alias_of:Flambda2_identifiers.Variable.t ->
t * To_jsir_result.tval add_code_id :
t ->
Flambda2_identifiers.Code_id.t ->
addr:Jsoo_imports.Import.Jsir.Addr.t ->
params:Jsoo_imports.Import.Jsir.Var.t list ->
closure:Jsoo_imports.Import.Jsir.Var.t ->
tMap a Flambda2 code ID to the address of the corresponding JSIR block, its parameters, and the JSIR varible corresponding to its closure.
val add_function_slot :
t ->
Flambda2_identifiers.Function_slot.t ->
Jsoo_imports.Import.Jsir.Var.t ->
tMap a Flambda2 function slot to the corresponding JSIR closure variable.
val add_value_slot :
t ->
Flambda2_identifiers.Value_slot.t ->
Jsoo_imports.Import.Jsir.Var.t ->
tMap a Flambda2 value slot to the corresponding JSIR closure variable.
val get_continuation_exn :
t ->
Flambda2_identifiers.Continuation.t ->
Jsoo_imports.Import.Jsir.Addr.tReturn the block address for the given continuation. Raises if given an unbound continuation.
val get_exn_handler_exn :
t ->
Flambda2_identifiers.Continuation.t ->
exn_handlerReturn the block address and parameters for exception-handling continuations. Raises if given an unbound exception handler.
val get_var_exn :
t ->
Flambda2_identifiers.Variable.t ->
Jsoo_imports.Import.Jsir.Var.tReturn the JSIR variable for the given Flambda variable. Raises if given an unbound variable.
val get_symbol :
t ->
res:To_jsir_result.t ->
Flambda2_identifiers.Symbol.t ->
(Jsoo_imports.Import.Jsir.Var.t * To_jsir_result.t) optionReturn the JSIR variable for the given Flambda symbol.
If the symbol is from the current compilation unit, we look it up in the environment; otherwise, we fetch from the global symbol table.
val get_symbol_exn :
t ->
res:To_jsir_result.t ->
Flambda2_identifiers.Symbol.t ->
Jsoo_imports.Import.Jsir.Var.t * To_jsir_result.tval get_code_id_exn : t -> Flambda2_identifiers.Code_id.t -> code_idReturn the block address, parameter variables and closure variable corresponding to the given Code_id.t.
val get_function_slot :
t ->
Flambda2_identifiers.Function_slot.t ->
Jsoo_imports.Import.Jsir.Var.t optionReturn the variable corresponding to a function slot.
val get_function_slot_exn :
t ->
Flambda2_identifiers.Function_slot.t ->
Jsoo_imports.Import.Jsir.Var.tval get_value_slot :
t ->
Flambda2_identifiers.Value_slot.t ->
Jsoo_imports.Import.Jsir.Var.t optionReturn the variable corresponding to a value slot.
val get_value_slot_exn :
t ->
Flambda2_identifiers.Value_slot.t ->
Jsoo_imports.Import.Jsir.Var.tThese functions first check whether the given item exists in the environment. If it exists, the environment is unchanged. Otherwise, we create a fresh variable, and add the mapping to the environment.
val add_function_slot_if_not_found :
t ->
Flambda2_identifiers.Function_slot.t ->
tval add_value_slot_if_not_found : t -> Flambda2_identifiers.Value_slot.t -> tval set_my_closure :
t ->
Flambda2_identifiers.Variable.t ->
Jsoo_imports.Import.Jsir.Var.t ->
tKeep track of the my_closure of the current code block being translated, and maintain a mapping to its JSIR equivalent.
val is_my_closure : t -> Flambda2_identifiers.Variable.t -> bool